Maven Incremental Module Builder

This POM contains the default configuration for all projects which are located in com.soebes

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.soebes.maven.extensions
ArtifactId

ArtifactId

incremental-module-builder
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

Maven Incremental Module Builder
This POM contains the default configuration for all projects which are located in com.soebes
Project Organization

Project Organization

SoftwareEntwicklung Beratung Schulung
Source Code Management

Source Code Management

https://github.com/khmarbaise/incremental-module-builder/

Download incremental-module-builder

How to add to project

<!-- https://jarcasting.com/artifacts/com.soebes.maven.extensions/incremental-module-builder/ -->
<dependency>
    <groupId>com.soebes.maven.extensions</groupId>
    <artifactId>incremental-module-builder</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.soebes.maven.extensions/incremental-module-builder/
implementation 'com.soebes.maven.extensions:incremental-module-builder:0.2.0'
// https://jarcasting.com/artifacts/com.soebes.maven.extensions/incremental-module-builder/
implementation ("com.soebes.maven.extensions:incremental-module-builder:0.2.0")
'com.soebes.maven.extensions:incremental-module-builder:jar:0.2.0'
<dependency org="com.soebes.maven.extensions" name="incremental-module-builder" rev="0.2.0">
  <artifact name="incremental-module-builder" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.soebes.maven.extensions', module='incremental-module-builder', version='0.2.0')
)
libraryDependencies += "com.soebes.maven.extensions" % "incremental-module-builder" % "0.2.0"
[com.soebes.maven.extensions/incremental-module-builder "0.2.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.codehaus.plexus : plexus-utils jar 3.0.24
org.codehaus.plexus : plexus-container-default jar 1.7
org.apache.maven.scm : maven-scm-manager-plexus jar 1.9.5
org.apache.maven : maven-core jar 3.2.5
commons-lang : commons-lang jar 2.6

provided (2)

Group / Artifact Type Version
org.codehaus.plexus : plexus-component-annotations jar 1.7
org.slf4j : slf4j-api jar 1.7.5

runtime (16)

Group / Artifact Type Version
org.apache.maven.scm : maven-scm-provider-accurev jar 1.9.5
org.apache.maven.scm : maven-scm-provider-bazaar jar 1.9.5
org.apache.maven.scm : maven-scm-provider-clearcase jar 1.9.5
org.apache.maven.scm : maven-scm-provider-cvsexe jar 1.9.5
org.apache.maven.scm : maven-scm-provider-cvsjava jar 1.9.5
org.apache.maven.scm : maven-scm-provider-gitexe jar 1.9.5
org.apache.maven.scm : maven-scm-provider-hg jar 1.9.5
org.apache.maven.scm : maven-scm-provider-jazz jar 1.9.5
org.apache.maven.scm : maven-scm-provider-local jar 1.9.5
org.apache.maven.scm : maven-scm-provider-perforce jar 1.9.5
org.apache.maven.scm : maven-scm-provider-starteam jar 1.9.5
org.apache.maven.scm : maven-scm-provider-svnexe jar 1.9.5
org.apache.maven.scm : maven-scm-provider-synergy jar 1.9.5
org.apache.maven.scm : maven-scm-provider-vss jar 1.9.5
org.apache.maven.scm : maven-scm-provider-tfs jar 1.9.5
com.perforce.p4maven : p4maven-provider jar 1.0.6

test (4)

Group / Artifact Type Version
org.assertj : assertj-core jar 2.1.0
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.19
org.slf4j : slf4j-nop jar 1.7.5

Project Modules

There are no modules declared in this project.

Maven Incremental Module Builder

Build Status Maven Central Apache License, Version 2.0, January 2004

If you are working with larger builds sometimes it is worth to think to build only parts of the whole reactor. So it would be nice to only build those modules which have been changed. This can be controled by using the --projects option on command line.

The problem here is that you need to identify those modules which have been changed manually which can become cumbersome.

This extension will handle this automatically.

Status

  • Currently in PoC state.
  • Code needs improvements.
  • Need to write more tests / integration tests.

Prerequisites

  • Maven 3.3.1+
  • Java 7 (as Maven 3.3.1+).

How to Configure?

If you like to use this extension you have to define the following in your .mvn/extensions.xml file:

<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
  <extension>
    <groupId>com.soebes.maven.extensions</groupId>
    <artifactId>incremental-module-builder</artifactId>
    <version>0.3.0</version>
  </extension>
</extensions>

How to use it?

The first step is to do a mvn install from the root of your whole reactor.

Afterwards you can simply call Maven via mvn -b incremental package which will print out things like this:

The following will show how it looks like if you have not changed anything:

~/ws-git/supose (master)$ mvn -b incremental package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Subversion Repository Search Engine
[INFO] SupoSE :: Test
[INFO] SupoSE :: Filter
[INFO] SupoSE :: Filter : Filter Model
[INFO] SupoSE :: Filter : Filter
[INFO] SupoSE :: Core
[INFO] SupoSE :: CLI
[INFO] SupoSE :: WAR
[INFO] SupoSE :: Integration Test
[INFO] SupoSE :: Users Guide
[INFO] SupoSE :: Assembly
[INFO]  ------------------------------------
[INFO]  Maven Incremental Module Builder
[INFO]  ------------------------------------
[INFO] Executing: /bin/sh -c cd '/Users/kama/ws-git/supose' && 'git' 'rev-parse' '--show-toplevel'
[INFO] Working directory: /Users/kama/ws-git/supose
[INFO] Executing: /bin/sh -c cd '/Users/kama/ws-git/supose' && 'git' 'status' '--porcelain' '.'
[INFO] Working directory: /Users/kama/ws-git/supose
[INFO]  Nothing has been changed.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Subversion Repository Search Engine ................ SKIPPED
[INFO] SupoSE :: Test ..................................... SKIPPED
[INFO] SupoSE :: Filter ................................... SKIPPED
[INFO] SupoSE :: Filter : Filter Model .................... SKIPPED
[INFO] SupoSE :: Filter : Filter .......................... SKIPPED
[INFO] SupoSE :: Core ..................................... SKIPPED
[INFO] SupoSE :: CLI ...................................... SKIPPED
[INFO] SupoSE :: WAR ...................................... SKIPPED
[INFO] SupoSE :: Integration Test ......................... SKIPPED
[INFO] SupoSE :: Users Guide .............................. SKIPPED
[INFO] SupoSE :: Assembly ................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.277 s
[INFO] Finished at: 2016-08-06T13:29:47+02:00
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------

Now you have changed some files in your modules so a git status (Using Subversion will work as well) will look like this:

~/ws-git/supose (master *)$ git st
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   supose-assembly/pom.xml

no changes added to commit (use "git add" and/or "git commit -a")

Which means in consequence you only need to build the single module supose-assembly. You can call Maven manually like this:

mvn -pl supose-assembly -amd package

Using this extension you don't need to think about which modules have been changed and change every time you call Maven the command line. This extension will automatically identify the changed modules and will run the build accordingly. You can simply do it like this:

~/ws-git/supose (master *)$ mvn -b incremental package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Subversion Repository Search Engine
[INFO] SupoSE :: Test
[INFO] SupoSE :: Filter
[INFO] SupoSE :: Filter : Filter Model
[INFO] SupoSE :: Filter : Filter
[INFO] SupoSE :: Core
[INFO] SupoSE :: CLI
[INFO] SupoSE :: WAR
[INFO] SupoSE :: Integration Test
[INFO] SupoSE :: Users Guide
[INFO] SupoSE :: Assembly
[INFO]  ------------------------------------
[INFO]  Maven Incremental Module Builder
[INFO]  ------------------------------------
[INFO] Executing: /bin/sh -c cd '/Users/kama/ws-git/supose' && 'git' 'rev-parse' '--show-toplevel'
[INFO] Working directory: /Users/kama/ws-git/supose
[INFO] Executing: /bin/sh -c cd '/Users/kama/ws-git/supose' && 'git' 'status' '--porcelain' '.'
[INFO] Working directory: /Users/kama/ws-git/supose
[INFO]  scmFile: supose-assembly/pom.xml modified
[INFO] Changed Project: com.soebes.supose:supose-assembly:pom:0.7.1-SNAPSHOT
[INFO] Calculated Reactor Order:
[INFO]  SupoSE :: Assembly
[INFO] Project: com.soebes.supose:supose-assembly:pom:0.7.1-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SupoSE :: Assembly 0.7.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) @ supose-assembly ---
[INFO]
[INFO] --- buildnumber-maven-plugin:1.4:create (default) @ supose-assembly ---
[INFO] Executing: /bin/sh -c cd '/Users/kama/ws-git/supose/supose-assembly' && 'git' 'rev-parse' '--verify' 'HEAD'
[INFO] Working directory: /Users/kama/ws-git/supose/supose-assembly
[INFO] Storing buildNumber: 2cf6fbf37dbd3a0922ebd607a5b0504e76a0fd76 at timestamp: 1470483260527
[INFO] Storing buildScmBranch: master
[INFO]
[INFO] --- maven-site-plugin:3.5.1:attach-descriptor (attach-descriptor) @ supose-assembly ---
[INFO]
[INFO] --- appassembler-maven-plugin:1.10:assemble (default) @ supose-assembly ---
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (default) @ supose-assembly ---
[INFO] Reading assembly descriptor: src/main/assembly/bin.xml
[INFO] Reading assembly descriptor: src/main/assembly/bin-unix.xml
[INFO] Reading assembly descriptor: src/main/assembly/src.xml
[INFO] Building zip: /Users/kama/ws-git/supose/supose-assembly/target/supose-assembly-0.7.1-SNAPSHOT-bin.zip
[INFO] Building tar: /Users/kama/ws-git/supose/supose-assembly/target/supose-assembly-0.7.1-SNAPSHOT-bin-unix.tar.gz
[INFO] Building tar: /Users/kama/ws-git/supose/supose-assembly/target/supose-assembly-0.7.1-SNAPSHOT-src.tar.gz
[INFO] Building zip: /Users/kama/ws-git/supose/supose-assembly/target/supose-assembly-0.7.1-SNAPSHOT-src.zip
[INFO] Starting building
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.159 s
[INFO] Finished at: 2016-08-06T13:34:23+02:00
[INFO] Final Memory: 29M/450M
[INFO] ------------------------------------------------------------------------

If you like to make your Maven call more convenient you can configure this into the .mvn/maven.config like this (see Release Notes):

-b incremental

So now you can call Maven simply via mvn package. If you want to run the usual build simply this can be achieved by using the following command line:

mvn -b multithreaded package

The multithreaded defines the default builder. This means you have turned off the incremental module builder.

ToDo

  • Better error handling
  • Better checks for prerequisites.
  • Checking if artifacts have been installed in local cache before?
  • Identify edge cases where it does not work?

Versions

Version
0.2.0
0.1.0