Friday, May 18, 2018

 

Basic Maven 2 POM for Groovy 2.4

I recently had to switch a Groovy 2 project from an Ant build to a Maven 2 build. This involved a fair amount of searching and trail and error so I thought I'd post the basic pom.xml that got the job done.

I elected to use the groovy-eclipse plugin instead of the alternatives described in the Compiling Groovy documentation. I also chose the "Do Nothing" option of putting the .groovy files under src/main/java because they were already mostly there in the existing project. This went fairly smoothly once I got past some problems with the plugin versions. Note that I included the pluginRepository for the compiler plugin in my pom.xml. I did that for getting this up and running, but I'll eventually move it to settings.xml.

Here's the pom.xml...
<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.xyz</groupId>
  <artifactId>abc</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>abc</name>
  <url>http://maven.apache.org</url>

  <pluginRepositories>
    <pluginRepository>
      <id>bintray</id>
      <name>Groovy Bintray</name>
      <url>https://dl.bintray.com/groovy/maven</url>
      <snapshots><enabled>false</enabled></snapshots>
    </pluginRepository>
  </pluginRepositories>

  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <classifier>indy</classifier>
      <version>2.4.15</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.6.1</version>
        <configuration>
          <compilerId>groovy-eclipse-compiler</compilerId>
          <compilerArguments>
            <indy/>
          </compilerArguments>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <version>2.9.2-04</version>
          </dependency>
          <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-batch</artifactId>
            <version>2.4.15-01</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

Labels: , , ,


This page is powered by Blogger. Isn't yours?