Get groovy, maven and eclipse to play well together?

So, we have some unit tests written in groovy. We have the Groovy Eclipse plugin, we have gmaven, but the problem is that the maven eclipse plugin does not automatically add the src / test / groovy directory as the source directory. So, I enlisted the build-helper plugin to add the source directory, but then the problem will become the source directory - in eclipse the filters will include ** / *. Java and exclude everything else that will lead to an eclipse Groovy plugin is confused. I handled the jury task using the build helper to add-test-resource with the correct .groovy file filter. Obviously, the problem is not in use here, if we decided to use Groovy classes in projects - .groovy classes will be included in .jar files.

How to fix it?

+3
source share
3 answers

I happened to check the maven eclipse plugin page and it turned out that this type of problem has already been solved: http://maven.apache.org/plugins/maven-eclipse-plugin/examples/specifying-source-path-inclusions-and-exclusions.html

I ended up just using build-helper-plugin to specify additional sources, and the added .groovy files for the source include the eclipse plugin.

0
source

gmaven groovy --, groovy . gmaven , .. -, groovy Eclipse , .

  <properties>
    <groovy.version>1.8.0</groovy.version>
    <groovy.provider>1.7</groovy.provider>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/groovy</source>
              </sources> 
            </configuration>
          </execution>
          <execution>
            <id>add-test-source</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/test/groovy</source>
              </sources>
            </configuration>
          </execution>    
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.1</version>
          <configuration>
            <compilerId>groovy-eclipse-compiler</compilerId>
            <verbose>true</verbose>
            <source>1.6</source>
            <target>1.6</target>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy-eclipse-batch</artifactId>
              <version>1.8.0-03</version>
            </dependency>        
            <dependency>
              <groupId>org.codehaus.groovy</groupId>
              <artifactId>groovy-eclipse-compiler</artifactId>
              <version>2.5.1</version>
              <exclusions>
                <exclusion>
                  <groupId>org.codehaus.groovy</groupId>
                  <artifactId>groovy-eclipse-batch</artifactId>
                </exclusion>
              </exclusions>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
+2

m2eclipse Groovy -Eclipse. -, m2eclipse:

http://m2eclipse.sonatype.org/sites/m2e

Groovy -Eclipse, :

http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/

Galileo:

http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.5/

, m2eclipse - -, , , .

0

Source: https://habr.com/ru/post/1754705/


All Articles