Bruce
Bruce

Reputation: 3538

eclipse not recognizing maven project as java

I have downloaded a fresh copy of Eclipse IDE for Java Developers for Mac Cocoa 64-bit running on my macOS High Sierra 10.13.1

I have a maven project (not an eclipse project) which I have cloned into a directory within my eclipse workspace.

I have gone to file -> import -> existing maven projects and imported it.

However, eclipse doesn't recognize anything as java, when I right click on any folder and go to 'build path' everything is greyed out.

How do I get it to recognize that I have a java project? I have tried many of the fixes I have seen online but nothing seems to work. Also, shouldn't it recognize it as java out of the box? It's a valid maven project imported into an IDE explicitly for java developers?

Many thanks!

EDIT: If I run mvn clean install at the command line, the build succeeds so I don't think there's anything wrong with the maven side of things.

EDIT: I tried the suggestion from @pobu of running mvn eclipse:eclipse. This completes successfully but doesn't appear to create any new files. There is this line in the output that suggests it's not running properly:

[INFO] --- maven-eclipse-plugin:2.10:eclipse (default-cli) @ acsohn ---
[INFO] Not running eclipse plugin goal for pom project`

Upvotes: 1

Views: 2377

Answers (1)

Bruce
Bruce

Reputation: 3538

Ah, I've figured out what it was, by creating a working maven java project in eclipse and then comparing it with what I have. Turns out for some reason I had

<packaging>pom</packaging>

in my pom.xml whereas the successfully imported project had

<packaging>jar</packaging>

Not sure how pom got in there or why it has to be jar if I don't care about the packaging but I guess perhaps eclipse looks at this to figure out if it's a java project?

Upvotes: 1

Related Questions