maven project does compile with erroneous source code

已回答

Hello,

I just built a maven project with archetype “archetype” as template - it is supposed to be a small interpreter. I need to write tests but once I switched the pom.xml from junit 3.8.1 to junit.jupiter.api reloading the maven project and rebuilding the maven project does not work. To test it, I wrote import asda; and I still do not see any error messages when I execute “build” → “rebuild project”.

So all I need is this dependency junit jupiter version 5.4.0 M1 to be fetched and the project to be compiled.

Can someone help me? if not directly - where else can I ask?

Thanks! :)

0

Hello, David!

For Maven-based Projects it's best to use Maven Tool Window and Maven Run Configurations, options from the Build Menu rely on IDEA's Native Build System by default.

For your scenario you have to:

  1. Update the dependencies in the pom.xml and click “Reload All Maven Projects” or “Load Maven Changes” pop-up icon.
  2. Run Maven's compile Lifecycle.
0

hey thank you for your quick answer!

I did what you suggested but the project still compiles even though it shouldnt. I attached a screenshot.

Note that there are two pom.xml files. I have updated them both to org.junit.jupiter instead of junit 3.8.1

0

David Schuldes It looks like your Content Roots are invalid and your code is ignored by both IDEA and the compiler because of that.

Please refer to Maven's Standard Directory Layout and adjust your Project's structure accordingly.

0

Dear Mr Vatagin,

Thanks again for your help. I created the project once more but selected “quickstart” as archetype and it seems to work. Thanks a lot!

0

请先登录再写评论。