Eclipse Helios + maven m2e + Groovy ==失败

时间:2011-09-07 05:44:23

标签: eclipse maven groovy m2e

自从我为maven安装了新的m2e插件后,我的Groovy项目不再构建。我正在使用如here所述的groovy-compiler-plugin。我得到maven-compiler-plugin的旧“插件执行未涵盖...”错误。我已尝试执行并忽略目标“testCompile”和“compile”,如错误中所述。

由于一些神秘的编译器问题,我无法使用GMaven。由于我公司的构建过程,我也被Maven 2.2.1锁定了。旧的m2eclipse插件已经不见了,m2e的文档非常糟糕。

我最终知道这件事。我没有其他地方看到这个问题。我不可能是唯一一个。

如果我很快找不到解决方案,我要么取消maven进行一些被黑客入侵的Gradle实现(虽然我也不能使用它),或者我要转移到NetBeans,这不是一个成功的主张。

根据要求,pom片段位于下方。

<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>
    <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>
    <plugins>
      <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
      <plugin>
        <groupId>org.eclipse.m2e</groupId>
        <artifactId>lifecycle-mapping</artifactId>
        <version>1.0.0</version>
        <configuration>
          <lifecycleMappingMetadata>
            <pluginExecutions>
              <pluginExecution>
                <pluginExecutionFilter>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
              <versionRange>[2.3.1,)</versionRange>
              <goals>
                    <goal>testCompile</goal>
                    <goal>compile</goal>
                  </goals>
                </pluginExecutionFilter>
                <action>
                  <execute />
                </action>
              </pluginExecution>
              <pluginExecution>
                <pluginExecutionFilter>
                  <groupId>org.codehaus.groovy</groupId>
                  <artifactId>groovy-eclipse-compiler</artifactId>
                  <versionRange>[2.5.1,)</versionRange>
                  <goals>
                    <goal>testCompile</goal>
                    <goal>compile</goal>
                  </goals>
                </pluginExecutionFilter>
                <action>
                  <execute />
                </action>
              </pluginExecution>
            </pluginExecutions>
          </lifecycleMappingMetadata>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>  
</build>

2 个答案:

答案 0 :(得分:8)

首先,您必须安装正确的配置程序。我假设您使用m2e版本1.0。如果是这种情况,则必须为m2e安装较新版本的Groovy-Eclipse配置程序。在此更新站点:

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

(不要使用groovy-m2eclipse-new更新站点。它已经过时,很快就会消失。)

我还没有对Eclipse 3.6上的配置程序进行过广泛的测试,但它应该可行。我建议您升级到Eclipse Indigo,因为在Indigo上通常可以更好地工作。

其次,您需要修复pom.xml。删除对org.eclipse.m2e插件的引用。

答案 1 :(得分:1)

看看我在groovy用户组中发布的以下link。注意,我使用的是春季STS,这只是一个更好的日食。我也将我的pom粘贴到测试套件供您参考,请仔细注意 sourceincludes 元素。我也在努力解决这个问题,但它现在肯定有效。此外,请确保eclipse中的maven指向您在机器中安装的maven,否则它也会导致问题。

[更新] 还可以根据您的eclipse版本安装以下任一插件,以提供Groovy-Maven集成 http://dist.codehaus.org/groovy/distributions/greclipse/groovy-m2eclipse-new/http://dist.codehaus.org/groovy/distributions/greclipse/groovy-m2eclipse/

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.org</groupId>
<artifactId>test-suite</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>test-suite</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<repositories>
    <repository>
        <id>jetlang.googlecode.com</id>
        <name>Jetlang Repository for Maven</name>
        <url>http://jetlang.googlecode.com/svn/repo/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.1.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-support</artifactId>
        <version>2.0.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jetlang</groupId>
        <artifactId>jetlang</artifactId>
        <version>0.2.5</version>
    </dependency>
    <!-- Database pool -->
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>
    <!-- ORACLE database driver -->
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc5</artifactId>
        <version>11.2.0.1.0</version>
    </dependency>
    <dependency>
        <groupId>jdom</groupId>
        <artifactId>jdom</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>jaxen</groupId>
        <artifactId>jaxen</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.1</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.14</version>
    </dependency>
    <!-- Groovy jar -->
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>1.8.0</version>
        <type>jar</type>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
                <compilerArgument>nowarn</compilerArgument>
                <!--<verbose>true</verbose> -->
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.5.1-1</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>1.8.0-03</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.eclipse.jdt.groovy.core.groovyNature</projectnature>
                </additionalProjectnatures>
                <sourceIncludes>
                    <sourceInclude>**/*.groovy</sourceInclude>
                </sourceIncludes>
            </configuration>
        </plugin>
    </plugins>
</build>