2

I'm using pants build system for a project (scala) and I need to use some 3rd party dependencies which are available for import as either gradle, sbt or maven. Is there a standard way to convert from a gradle.build/pom.xml/build.sbt/plugin to pants build files?

The below pom (the plugins part) is an example of what would need to be converted to pants somehow.

Thanks


    <build>
    <sourceDirectory>src/main/scala</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.lightbend.akka.grpc</groupId>
        <artifactId>akka-grpc-maven-plugin</artifactId>
        <version>${akka.grpc.version}</version>
        <configuration>
          <language>Scala</language>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- disable surefire -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>

      <!-- enable scalatest -->
      <plugin>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest-maven-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
          <junitxml>.</junitxml>
          <filereports>TestSuite.txt</filereports>
          <argLine>-javaagent:${org.mortbay.jetty.alpn:jetty-alpn-agent:jar}</argLine>
        </configuration>
        <executions>
          <execution>
            <id>test</id>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.5.1</version>
        <executions>
          <execution>
            <id>getClasspathFilenames</id>
            <goals>
              <!-- provides the jars of the classpath as properties inside of maven
                   so that we can refer to one of the jars in the exec plugin config below -->
              <goal>properties</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>server</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>java</executable>
              <arguments>
                <argument>-javaagent:${org.mortbay.jetty.alpn:jetty-alpn-agent:jar}</argument>
                <argument>-classpath</argument>
                <classpath />
                <argument>com.example.helloworld.GreeterServer</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>client</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>java</executable>
              <arguments>
                <argument>-classpath</argument>
                <classpath />
                <argument>com.example.helloworld.GreeterClient</argument>
                <argument>${GreeterClient.user}</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>      
      </plugin>
    </plugins>
  </build>
user1467422
  • 121
  • 8
  • I would suggest to read the docs like https://www.pantsbuild.org/from_maven.html ? – khmarbaise Jan 21 '19 at 14:01
  • I have, it's useful, but not sufficiently detailed to help me convert a plugin configuration from a pom to pants. Also I'm wondering if there's a common tool for conversion. – user1467422 Jan 21 '19 at 14:23
  • What have you tried so far? Can you show the things which are not working ? – khmarbaise Jan 21 '19 at 14:26
  • I'll upload the pom I'm looking to convert. It's from a sample project here: https://developer.lightbend.com/guides/akka-grpc-quickstart-scala/streaming.html – user1467422 Jan 21 '19 at 14:32

1 Answers1

1

I do not believe there are any tools that can convert existing poms to Pants. I do not believe there are Pants plugins equivalent to almost any Maven plugin yet.

It seems like the best alternative is to craft Pants plugins for the transformations you cannot live without, and convert your builds to the standards of the build tool you are migrating to (sadly).

Here's some documentation on creating new plugins:

https://www.pantsbuild.org/dev_tasks.html

An example plugin that transforms code Avro into some Java code (seems like as good a starter as any for a Java-based code transform):

https://github.com/pantsbuild/pants/tree/master/contrib/avro/src/python/pants/contrib/avro

Alternatively, you can use the jvm_prep_command and run the java processes you need in a more hackish way:

https://www.pantsbuild.org/build_dictionary.html

Quartz
  • 1,731
  • 1
  • 14
  • 17
  • I'm actually disappointed with the state of build tools that support monorepo, they seem pretty limited, poorly supported, somewhat buggy, and all have large amounts of manual setup that has to be added and maintained, from class-to-class dependencies on the code you build, to library inherited dependencies that have to be maintained (looking at you Bazel). – Quartz Jan 15 '20 at 22:56