java - 如何并行化 maven-assembly-plugin?

标签 java maven 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

关于java - 如何并行化 maven-assembly-plugin?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45148408/

相关文章:

java - Maven + Spring MVC + LessCss + Wro4j

spring-boot - 当我设置 spring.active.profile 时,Spring Boot 不读取 Application.yml 文件

java - Maven 阴影插件不会将依赖类文件放入 jar 中

maven - 如何从现有原型(prototype)创建 Maven 原型(prototype)

java - 仅使用数组实现高效的数据结构

java - 在prepareCall后遇到符号\"CLOSE\"

java - 比较Hadoop MapReduce中的两个文件

java - 基本 Spring 应用程序的全局异常处理程序

java - Maven 程序集 : how package only imported/used dependencies for each execution

maven - 使用 maven 程序集插件解压 tar 时如何保留符号链接(symbolic link)