I have been maintaining a maven java project for year.
Recently, I learned Ruby and asked why haven't these nice features (of Ruby) existed in Java, and I am so happy to find Groovy the answer. It's already out there for more than 6 years and what a shame I didn't know about it sooner.
Now come to the story:
I have a lot of java code written already, organized in folder structures follow maven default convention (src/main/java
for logic & src/test/java
for test)
Now, I want to write some new stuff in Groovy, so I guess I should create src/main/groovy
for groovy logic and src/test/groovy
for test. However, both mvn eclipse:eclipse
and the latest m2eclipse
only understand and include src/main/groovy
as source code folder of the generated eclipse project, and don't not recognize src/test/groovy
at all.
Is this the correct behavior? Or am I missed any thing?
By the way, here is the gmaven plugin configured inside my POM:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>generateStubs</goal>
<goal>compile</goal>
<goal>generateTestStubs</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<providerSelection>1.7</providerSelectio开发者_StackOverflown>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.codehaus.gmaven.runtime</groupId>
<artifactId>gmaven-runtime-1.7</artifactId>
<version>1.2</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>groovy-all</artifactId>
<groupId>org.codehaus.groovy</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<configuration>
<providerSelection>1.7</providerSelection>
</configuration>
</plugin>
...
</plugins>
...
</build>
You may find that you have better luck with new version of m2eclipse instead of eclipse:eclipse. Either way, once your project is in eclipse, navigate your src/{main,test}/ folder, right-click and choose Build Path and "User as Source Folder".
Using eclipse can be more comfortable : Import your project into eclipse as "Maven project" 1) go to Eclipse Marketplace & install groovy compiler
2)right-click on project and configure it as groovy project
3)result :
精彩评论