From build that takes minutes to build that take seconds
Jenkins - Maven - Java - JUnit - Other
How does it work?
Git diff with last tag from master pushed in artifactory
Dependency graph The system has a file dependency graph of the files
Maven wrapper The system has a maven execute wrapper plugins and check git changes before executing the real target
Use artifactory already build files of a previous build for files that don't need to be compiled
Examples
As the product is still in Beta, some scenario might be slightly different.
You have a Maven project with 6 sub-modules: 1,2,3,4,5,6. Modules 4 and 5 have dependencies with module 3.
You're asked to make modification in module 3
After push, Incremental build will not compile/test modules 1, 2 and 6
For module 3, 4 and 5, Incremental build will detect which classes needs to be recompiled
If you change 1 file, the file will be recompiled as well as all files using that file
Incremental build will detect which test is using this file (dependency graph) or a mock of the file and rerun these tests
The last build / test / deploy to artifactory of your feature branch was successful
During the review a colleague as you to add a unit test.
You had the unit test and push the changes
Incremental build notices that only a unit test was added, compiles and runs the unit test file
The same data are pushed to the artifactory.
You changed a file which is defined in Incremental build to have no effect on the build / test (e.g. documentation) -> no rebuild / retest is performed
You changed a file which is undefined (e.g. pom.xml) -> normal rebuild / retest
Advantages
Minimal code changes. The maven plugin(s) is added to the existing pom.xml
No CI changes. The same goal is executed, it just finishes faster.
Extendable. Using special plug-ins (e.g. generated sources), specify file dependencies manually (with regular expressions)
No local environment. As the build is just building, testing what has changed, pushing changes may get the feature environment faster updated that starting it locally.
Save costs. Are you building in the cloud and paying CPU time? What would be the saving a 10x build & test time reduction?
Environment. Faster build means less electricity usage and reduce your company CO² footprint.
Joined effort. All companies using Incremental build will improve in the long term the productivity of the tool, documentation, maintenance, costs.