0

I'm trying to optimize my build process (in development) in term of time to build the whole tree of maven multi-module project. Some of the POM are actually aggregation of sources/libraries that rarelly (and typically) never change. So specific sub-questions are

  1. Is it possible to somehow configure maven to not build pom if there are no changes in sources specified in POM:project/build/sourceDirectory attribute?

  2. Or is it possible to (at least) conditionally disable maven-bundle-plugin? - it takes most of the time.

Google could not find anything relevant Q#1. Typical solution does not work for #2 - when i try to specify 'executions' for maven-bundle-plugin (like this)

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>${maven-bundle-plugin.version}</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <id>osgi-bundle</id>
            <phase>bundle</phase>
            <goals>
                <goal>bundle</goal>
            </goals>

i receive this error in output

[bundle:bundle]
Bundle artifact-id:bundle-id:bundle:0.1.0-SNAPSHOT : The JAR is empty: dot
Error(s) found in bundle configuration

Any help is appreciated. I'm aware about following:
* Disable a Maven plugin defined in a parent POM (maven-bundle-plugin can't work with 'executions' tag)
* Skip execution of a maven plugin if a file does not exist (maven-bundle-plugin does not have skip confiuration option)
* How to skip lifecycle phase in multi maven module (the same as previous)
* If entire maven-bundle-plugin is moved into profile, maven does not recognize packaging=bundle.

Community
  • 1
  • 1
Xtra Coder
  • 3,389
  • 4
  • 40
  • 59

4 Answers4

2

Finally I have to admit that (C) Eugene Kuleshov - "Maven generally don't track sources/changes, so it is always a full build."

But, returning back to Java after 5+ on .NET and 5+ years erlier on C++, it looks weird for me that such a common feature like incremental build is not support by widely used tool having a history of 10+ years. So I could not spend my time on waiting to rebuild each and every unchanged module in my multi-module project and decided to make customized version of Maven 3.0.4 :)

Feel free to grab it here http://code.google.com/p/maven-onchange-activator/, try and report issues.

Xtra Coder
  • 3,389
  • 4
  • 40
  • 59
0

Maven generally don't track sources/changes, so it is always a full build. However to disable any plugin you could move it into profile and then enable/disable the whole profile, e.g. either conditionally or from the command line.

Eugene Kuleshov
  • 31,461
  • 5
  • 66
  • 67
  • Unfortunately that specific solution does not work with maven-bundle-plugin - when it is moved to profile, maven start saying packaging=bundle is unknown. – Xtra Coder Jun 06 '12 at 09:49
0

You should check things like

mvn -am 

in relationship with

mvn -pl ...

so doing a build like:

mvn -am -pl SubModule clean package

will build only those modules which have been changed and which needed to be built as a result of a dependency to the change module.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • "pl" is "Build specified reactor projects instead of all projects" - this means I have to know beforehand which projects are changed and explicitly list them in command line. This is definitely not an applicable case. – Xtra Coder Sep 07 '12 at 22:45
0

I would suggest switching to Gradle. Gradle has such support out of the box (no configuration needed) and conversion from Maven should be easy.

Sergey
  • 3,253
  • 2
  • 33
  • 55