将gradle / sbt / maven项目转换为裤子构建系统

时间:2019-01-21 13:43:54

标签: maven gradle build sbt pants

我正在为项目(scala)使用裤子构建系统,我需要使用一些第三方依赖项,这些依赖项可以作为gradle,sbt或maven导入。是否存在从gradle.build/pom.xml/build.sbt/plugin转换为裤子构建文件的标准方法?

下面的pom(插件部分)是需要以某种方式转换为裤子的示例。

谢谢


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

1 个答案:

答案 0 :(得分:0)

我不认为有任何工具可以将现有的pom转换为裤子。我不相信还有几乎与任何Maven插件一样的Pants插件。

似乎最好的选择是为无法摆脱的转型打造Pants插件,然后将构建转换为要迁移到的构建工具的标准(不好)。

以下是有关创建新插件的文档:

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

一个示例插件,可将代码Avro转换为某些Java代码(对于基于Java的代码转换,它似乎像任何入门工具一样好):

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

或者,您可以使用jvm_prep_command并以一种更hacky的方式运行所需的Java进程:

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