Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [m2e-users] Why is one maven project imported into Eclipse unable to see JUnit or Mockito artifacts?

Maybe you have some standalone util classes + tests in the project to try out first? Also, could there be a version conflict so that you'r pulling JUnit 5 while the tests are written for JUnit 4 (or vice versa)?

About your earlier "In any case, I wouldn’t think this would matter at all". I'm not sure how obvious this is, but starting with Eclipse Photon the Eclipse compiler distinguishes between test-scope and "normal"-scope. A class in a folder with "Contains test sources: No" will not see Maven artefacts imported with scope=test.


On Sun, May 26, 2019 at 6:50 AM KARR, DAVID <dk068x@xxxxxxx> wrote:

Good question.  The errors do appear when I add the source files back.  Now I guess I’m looking at some sort of bisect process, with 291 source files, and over 31k lines.  Yay.

 

 

From: m2e-users-bounces@xxxxxxxxxxx <m2e-users-bounces@xxxxxxxxxxx> On Behalf Of Fred Bricon
Sent: Saturday, May 25, 2019 8:20 PM
To: Maven Integration for Eclipse users mailing list <m2e-users@xxxxxxxxxxx>
Subject: Re: [m2e-users] Why is one maven project imported into Eclipse unable to see JUnit or Mockito artifacts?

 

So if you add all sources back the error shows up?

 

On Sat, May 25, 2019 at 9:56 PM KARR, DAVID <dk068x@xxxxxxx> wrote:

Well, the first thing I tried in the copy was deleting all of the source files, leaving the pom file, then added a hello world java and test class.  I then built it from the command line, and it was successful. I then imported it to Eclipse as an Existing Maven Project.  No errors.

 

So, I then deleted the original imported project, removed the dot files, then instead of importing from the git repository, I imported as “Existing Maven Project”.  Same compile errors.

 

This points to something in the source files themselves as causing this.  I can’t really provide these source files.  Any idea of anything I can look for?

 

From: m2e-users-bounces@xxxxxxxxxxx <m2e-users-bounces@xxxxxxxxxxx> On Behalf Of KARR, DAVID
Sent: Saturday, May 25, 2019 8:14 AM
To: Maven Integration for Eclipse users mailing list <m2e-users@xxxxxxxxxxx>
Subject: Re: [m2e-users] Why is one maven project imported into Eclipse unable to see JUnit or Mockito artifacts?

 

That’s going to be pretty unlikely, but if I don’t get any other ideas I’ll try copying this project and pulling everything I can out of it.

 

From: m2e-users-bounces@xxxxxxxxxxx <m2e-users-bounces@xxxxxxxxxxx> On Behalf Of Fred Bricon
Sent: Saturday, May 25, 2019 7:58 AM
To: Maven Integration for Eclipse users mailing list <m2e-users@xxxxxxxxxxx>
Subject: Re: [m2e-users] Why is one maven project imported into Eclipse unable to see JUnit or Mockito artifacts?

 

can you provide a sample project reproducing this issue?

 

On Sat, May 25, 2019 at 10:56 AM KARR, DAVID <dk068x@xxxxxxx> wrote:

The “Sources” entry for “src/test/java” has “Contains test sources: Yes”.

 

The effective pom shows the “junit” artifact with “<scope>test</scope>”.  Curiously, the same search for “mockito-core” doesn’t find a scope attribute.  However, when I search for mockito in “Dependency Hierarchy”, I see that the artifact that references mockito is in scope test, and it displays mockito-core in scope test also.  In any case, I wouldn’t think this would matter at all.  If the artifact is present at all, whether in scope test or not, I wouldn’t see compile errors saying the artifact is not found.

 

And remember that the command-line “mvn” build works fine. I’ve tested this both outside of Eclipse in a shell window, and in Eclipse, with “Run As Maven Build”.

 

From: m2e-users-bounces@xxxxxxxxxxx <m2e-users-bounces@xxxxxxxxxxx> On Behalf Of Simon Niederberger
Sent: Saturday, May 25, 2019 1:37 AM
To: Maven Integration for Eclipse users mailing list <m2e-users@xxxxxxxxxxx>
Subject: Re: [m2e-users] Why is one maven project imported into Eclipse unable to see JUnit or Mockito artifacts?

 

Are your test classes on a path marked as Java Build Path -> Sources -> Contains test sources: Yes ? (And can you confirm that JUnit / Mockito are defined in scope=test in your pom.xml ?

 

 

 

On Sat, May 25, 2019 at 8:27 AM KARR, DAVID <dk068x@xxxxxxx> wrote:

I'm using Eclipse 2019-03 with Java 8 on Win7, with m2e installed.

I have a bunch of projects all built with Maven, that present SpringBoot REST services in different subdomains. All of them build fine from the command line, and all but one have no compile issues in Eclipse.

I just inherited responsibility for a new project which has already been running, but which was maintained by a separate team. All the projects were constructed from a template, so many things are the same as I expect. It builds fine from the command line with Maven, including all the unit tests.

When I import the project from my local git repo, it consistently reports that it can't find the "Junit" or "Mockito" artifacts, which causes compile errors in all of the unit tests. Those artifacts clearly show up in the effective POM, and in the "Maven Dependencies" tree in the Package Explorer. There are no red marks in the pom.xml.

I've tried "Update Project". I've tried deleting the project and reimporting.

I've looked at the entire set of compile errors, and there's nothing else unusual, besides not being able to find these artifacts.

I've compared this project with a similar project that doesn't have this symptom, including the .classpath and .project files. There are very minor differences, but I haven't seen any differences that seem like they might be significant.

I also tried deleting the imported project, then making sure that all eclipse dot files are removed from the repository, and reimporting.  Also no change.
_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/m2e-users

_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/m2e-users


 

--

"Have you tried turning it off and on again" - The IT Crowd

And if that fails, then http://goo.gl/tnBgH5

_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/m2e-users


 

--

"Have you tried turning it off and on again" - The IT Crowd

And if that fails, then http://goo.gl/tnBgH5

_______________________________________________
m2e-users mailing list
m2e-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/m2e-users

Back to the top