gmaven 没有为 groovy 代码生成 jar 文件

gmaven is not generating jar file for groovy code

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

中提到了这个atlassian link
<plugins>
  <plugin>
 <executions>
      <execution>
        <goals>
          <goal>generateStubs</goal>
          <goal>compile</goal>
          <goal>generateTestStubs</goal>
          <goal>testCompile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>

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

下面是我的 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:

我能看到罐子,但它没有我的 groovy 代码

能否请您尝试以下操作:

  <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 文件所在的位置