Skip to content

maven-turbo-reactor/maven-half-life-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Half-Life builder

Problem statement

By default, to build any module in a multi-module project Maven first resolves and executes all phases of upstream dependencies. This is a fundamental behaviour which is built-in and strongly enforced because of back compatibility. This significantly reduces possible concurrency and in a multi-core system CPU cores are loaded unevenly.

Proposed solution

It's a custom implementation of Maven builder that schedules modules build in an efficient way. The fundamental idea behind this implementation is to split the module build lifecycle to two parts (halves), let's call them "main" and "test".

  • The "main" part is the compilation and packaging of src/main source code which may be a dependency from the other module
  • The "test" part always depends on "main" and includes compilation and execution of tests (surefire and failsafe), verify and install

The build phases of the module are separated like this (some intermediate phases are ommitted to simplify explanation):

Phases

New build graph

The major outcome of this approach is better utilization of multi-core CPUs by multi-module projects. The advantage can be more than 35% in boost.

How to set up extension:

Configure your project .mvn/extensions.xml

<extensions>
    <extension>
        <!-- https://github.com/maven-turbo-reactor/maven-half-life-builder -->
        <groupId>com.github.seregamorph</groupId>
        <artifactId>maven-half-life-builder</artifactId>
        <version>0.3</version>
    </extension>
</extensions>

and specify custom builder on the command line to enable it, also specify the number of workers:

mvn clean install -bhalf-life -T1C

To enable this extension by default, add line to .mvn/maven.config under root of your project:

-bhalf-life
-T1C

Note, that for many setups, e.g. Apple MacBook Pro, -T0.5C can be more efficient and faster than -T1C (as only half of the CPU cores are powerful).

Naming

The "half-life" naming refers to the term from nuclear physics meaning the radioactive decay. This also refers to Maven multi-module build scheduler which is called "reactor".

About

☢️ Maven reactor next level

Topics

Resources

License

Stars

3 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages