2012-03-28 69 views
3

我產生一個空的項目用:GMaven項目:產生不`MVN compile`

mvn archetype:generate -DarchetypeGroupId=org.codehaus.gmaven.archetypes -DarchetypeArtifactId=gmaven-archetype-basic -DarchetypeVersion=1.4

,並不能mvn compile與一羣消息"package groovy.lang does not exist"

(爲archetypeVersion我只是拿起最後GMaven發行版本)

這有什麼錯我的Maven/GMaven/Groovy的?

<?xml version="1.0" encoding="UTF-8"?> 
<!-- 
    Generated from archetype; please customize. 
--> 

<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>a</groupId> 
    <artifactId>asd</artifactId> 
    <name>asd project</name> 
    <version>1.0-SNAPSHOT</version> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.2</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.codehaus.gmaven</groupId> 
       <artifactId>gmaven-plugin</artifactId> 
       <version>1.4</version> 
       <configuration> 
        <providerSelection>1.8</providerSelection> 
       </configuration> 
       <executions> 
        <execution> 
         <goals> 
          <goal>generateStubs</goal> 
          <goal>compile</goal> 
          <goal>generateTestStubs</goal> 
          <goal>testCompile</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 

</project> 
+0

您能顯示pom嗎? – khmarbaise 2012-03-28 19:51:28

+0

添加了絨球。 – 2012-03-28 20:44:49

回答

2

我做了一個完整的例子Groovy in Maven。看看它。

+0

謝謝你的樣品。我的不好,到那時我已經有了一個可行的配置。我會將其作爲備選答案發布。 – 2012-04-30 14:02:34

1

得到它的工作我自己的路 - 這是版本的問題。 @khmarbaise的版本有一些很好的想法,比如版本的靈活性。

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <groovy.version>2.0.0-beta-2</groovy.version> 
</properties> 

<dependencies> 

    <!-- ... something ... --> 

    <dependency> 
     <groupId>org.codehaus.groovy</groupId> 
     <artifactId>groovy</artifactId> 
     <version>${groovy.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.gmaven.runtime</groupId> 
     <artifactId>gmaven-runtime-1.7</artifactId> 
     <version>1.3</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.codehaus.groovy</groupId> 
       <artifactId>groovy-all</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
</dependencies> 

<!-- ... something ... --> 

<build> 
    <!-- make Java compile from groovy folders as well... --> 
    <sourceDirectory>src/main/groovy</sourceDirectory> 
    <testSourceDirectory>src/test/groovy</testSourceDirectory> 

<plugins> 
    <plugin> 
     <groupId>org.codehaus.gmaven</groupId> 
     <artifactId>gmaven-plugin</artifactId> 
     <version>1.3</version> 
     <dependencies> 
      <dependency> 
       <groupId>org.codehaus.groovy</groupId> 
       <artifactId>groovy</artifactId> 
       <version>${groovy.version}</version> 
      </dependency> 
      <dependency> 
       <groupId>org.codehaus.gmaven.runtime</groupId> 
       <artifactId>gmaven-runtime-1.7</artifactId> 
       <version>1.3</version> 
       <exclusions> 
        <exclusion> 
         <groupId>org.codehaus.groovy</groupId> 
         <artifactId>groovy</artifactId> 
        </exclusion> 
       </exclusions> 
      </dependency> 
     </dependencies> 
     <executions> 
      <execution> 
       <configuration> 
        <providerSelection>1.7</providerSelection> 
       </configuration> 
       <goals> 
        <goal>generateStubs</goal> 
        <goal>compile</goal> 
        <goal>generateTestStubs</goal> 
        <goal>testCompile</goal> 
       </goals> 
      </execution> 
     </executions> 
    </plugin> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
      <source>1.5</source> 
      <target>1.5</target> 
     </configuration> 
    </plugin> 
</plugins> 
+1

顯然它不適用於Groovy 2中的某個人,因爲我得到了一個downvote。 – 2014-07-17 08:05:42