How to parallelize maven-assembly-plugin?

Viewed 384

I'm using the maven-assumbly-plugin in the following way

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

and noticed that it's horribly slow when packaging large dependencies, like Stanford CoreNLP models with multiple 100MB. It's a rare usecase, but I assume that parallel implementation is available since multicore processors have been around for decades. How to use it?

1 Answers

Maven 3.x has the capability to perform parallel builds. The command is as follows:

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
Related