Description
For quite a long time I've had to deal with a problem where when I import any of many different applications we maintain, Eclipse either doesn't note that is a Java application or it doesn't know it's a Maven application, even though both of those facts are clearly evident in the repository. I've tried to report these issues before, but I've never been able to produce a repeatable test case. All of our applications have similarities. They all use the same parent pom and many of the same dependencies and plugins. I still don't quite have a fully reproducible test case, but I think I have enough information for one of you to comment on.
Today I took one of our simpler applications and made a copy of it and started iteratively removing things until I saw a change in the results on import. I now have it down to the "pom.xml" and a single Java source file, although I don't think the latter matters, although I don't know how it's supposed to determine it's a Java application otherwise.
I then started iterating on removing items from the pom.xml, commenting them out first and then removing them if they made no difference. After each iteration, I delete the Eclipse project and all the dot files in the directory (.project, et cetera).
I'm now focusing on the "parent" element in the pom.xml. I now have a reasonably minimal pom.xml, and when I import it, the .project file only gets the "maven2Nature" and no .classpath file is created. It also doesn't have the "Maven Dependencies" entry (which would go in the classpath, which doesn't exist anyway). If I then comment out the "parent" element and reimport, it gets the "javanature", the .classpath file, and "Maven Dependencies".
So I then made a copy of the parent pom project, which is just the pom.xml, and started the same process with that, installing it locally (first changing the artifact name and the reference from the other project) until I saw interesting changes. That narrowed it down to something that doesn't reallly surprise me, but I need to get your POV on this before I create a ticket elsewhere.
In my parent pom, I have this in my plugins block:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<parameters>true</parameters>
<release>${maven.compiler.release}</release>
<compilerId>groovy-eclipse-compiler</compilerId>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>3.9.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>4.0.20-03</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>compile</phase>
</execution>
</executions>
</plugin>
If I comment out the configuration and dependencies block and use that, the project imports properly, getting the Java nature and the Maven Dependencies.
So, it's down to Groovy. Again, I can't say this surprises me too much. It's caused me many other problems in the past. However, I'd like to try to understand why this would cause the project import to do what it's been doing. Can one of you give me your viewpoint on this before I create a ticket in the Groovy github repo?
Note that I don't currently have the Eclipse Groovy plugin installed in Eclipse. It had created other problems for me in the past. Perhaps I simply have to struggle with solving those other problems. I wish I could get it to just ignore that part of the plugin.
Note that this problem is a big annoyance, but whenever it happens I just manually edit the .project file and copy in a .classpath file that I know works, and then do some additional editing. There is no way I would expect other developers on our related teams to know to do this, or do it correctly.