I'm sharing this as I think it could be useful to others.

I like to build the java/sca tree before committing code changes to check that my changes are not going to break any other module.

This gives me a peace of mind as I don't have to worry about build breaks and is also nice to other contributors as I know that I'm not breaking their modules.

Unfortunately Maven is not particularly smart about detecting changes and rebuilding only impacted modules and the brute force "mvn clean install" on the whole tree takes long and makes my Thinkpad's CPU overheat.

So I thought it would be nice to teach Maven how to do more incremental builds:

- recompile and retest with mvn clean install the modules that have compile dependencies on the modules I've changed

- only retest the modules that have runtime and test dependencies on the modules I've changed.

I developed a little Maven plugin to do it. It's really simple and leverages the Maven dependency model, see for yourself at [1].

Here's how I use the plugin to run incremental builds:

1. To mark that a module has changed, create a .modified marker file at its root. This is what the plugin recognizes as an indication that the module has changed. I was thinking about running "svn st" automatically from the plugin but for now I've found simpler to just use a shell script like follows to create/remove these .modified marker files:

st=`svn st | grep -v ".modified"`
if [ "x$st" != "x" ]
then
  echo "Modified"
  echo "$st"
  touch .modified
else
  echo "Not modified"
  rm -f .modified
fi

This is for Linux, I'm sure that it can be translated to a Windows script.

2. To run the incremental build, from java/sca run:
mvn -o org.apache.tuscany.sca:tuscany-maven-incremental-build:build

This will recompile and/or retest only the modules affected by the changed modules. Faster and more reliable, and greener as my Thinkpad now uses less energy :)

Hope this helps. I'm interested in your feedback if you use it and like it, or not :) or want to help improve it.

[1] https://svn.apache.org/repos/asf/incubator/tuscany/java/sca/tools/maven/maven-incremental-build/src/main/java/org/apache/tuscany/sca/tools/incremental/build/plugin/IncrementalBuildMojo.java
--
Jean-Sebastien

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to