gmaven is not generating jar file for groovy code

266 views Asked by At

I am writing my groovy code in maven using GMaven plugin. when I do mvn clean install it is showing build success but when I checked my target folder it is not generating any jar for me. I am refering this atlassian link in that

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

but for this I am getting pom error on execution. please help me out here

Below is my pom file

<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>

UPDATE 1:

I am able to see the jar but it does not have my groovy code

1

There are 1 answers

1
Mehdi On BEST ANSWER

Can you please try the following:

  <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>

Actually that's what I'm using and jar is correctly generated

PS: Make sure that source.directory points to where your .groovy files exist