1

我正在为一个项目(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>
4

1 回答 1

0

我不相信有任何工具可以将现有的 pom 转换为 Pants。我不相信有与几乎所有 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 并以更骇人听闻的方式运行所需的 java 进程:

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

于 2020-01-15T22:54:11.370 回答