views:

36

answers:

2

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</providerSelection>
                    </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>
A: 

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".

Brian M. Carr
A: 

I use build-helper-maven-plugin as described here: http://mackaz.de/304 The advantage of the use of this plugin is that the folder will be automatically re-added to eclipse source folder if you clean your project settings.

Phương Nguyễn