如何并行化 maven-assembly-plugin?



我通过以下方式使用maven-assumbly-plugin

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
<!-- necessary in order to avoid
`Error reading assemblies: No assembly
descriptors found.` -->
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

并注意到在打包大型依赖项时,它非常慢,例如具有多个 100MB 的斯坦福 CoreNLP 模型。这是一个罕见的用例,但我认为并行实现是可用的,因为多核处理器已经存在了几十年。如何使用?

Maven 3.x具有执行并行构建的能力。命令如下:

mvn -T 4 clean install # Builds with 4 threads
mvn -T 1C clean install # 1 thread per cpu core
mvn -T 1.5C clean install # 1.5 thread per cpu core

最新更新