0

我正在使用 GMaven 插件在 Maven 中编写我的 groovy 代码。当我执行 mvn clean install 时,它显示构建成功,但是当我检查目标文件夹时,它没有为我生成任何 jar。我指的是这个atlassian链接

<plugins>
  <plugin>
 <executions>
      <execution>
        <goals>
          <goal>generateStubs</goal>
          <goal>compile</goal>
          <goal>generateTestStubs</goal>
          <goal>testCompile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

但是为此我收到了 pom 错误execution。请帮帮我

下面是我的pom文件

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.myproject</groupId>
    <artifactId>mydata</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>mydata</name>
    <url>http://maven.apache.orgurl>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <gmaven.version>1.5</gmaven.version>
    <groovy.version>2.1.8</groovy.version>
    </properties>

<dependencies>
    

        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.11</version>
        </dependency>
    
</dependencies>
<build>
<!-- <pluginManagement> -->
<plugins>
   <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <version>${gmaven.version}</version>
            <configuration>
                <providerSelection>2.0</providerSelection>
            </configuration>
            <dependencies>
            
                <dependency>
                    <groupId>org.codehaus.gmaven.runtime</groupId>
                    <artifactId>gmaven-runtime-2.0</artifactId>
                    <version>${gmaven.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>${groovy.version}</version>
                </dependency>
            </dependencies>
           <!--  <executions>
                <execution>
                    <goals>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions> -->
        </plugin>
        </plugins>
<!--         </pluginManagement> -->
        </build>
        
      
</project>

更新 1:

我可以看到 jar,但它没有我的 groovy 代码

4

1 回答 1

0

请您尝试以下方法:

  <plugin>
    <groupId>org.codehaus.gmavenplus</groupId>
    <artifactId>gmavenplus-plugin</artifactId>
    <version>1.5</version>
    <executions>
      <execution>
        <goals>
          <goal>addSources</goal>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <sources>
        <source>
          <directory>${project.basedir}/src</directory>
          <includes>
            <include>**/*.groovy</include>
          </includes>
        </source>
      </sources>
    </configuration>
  </plugin>

实际上这就是我正在使用的并且正确生成了jar

PS:确保 source.directory 指向您的 .groovy 文件所在的位置

于 2017-12-04T10:45:53.043 回答