turn off buildnumber-maven-plugin for submodules
Asked Answered
C

3

1

Parent:

    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.0</version>
            <executions>
                <execution>
                    **<inherited>false</inherited>**
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <format>${project.version}-b{0,number}</format>
                <items>
                    <item>buildNumber0</item>
                </items>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
            </configuration>
        </plugin>
    </plugins>

<modules>
    <module>module1</module>
    <module>module2</module>
</modules>

During 'mvn buildnumber:create' each module generate buildnumber. Is it possible to turn it off for submodules? In other word, during 'mvn buildnumber:create' build number should be generated only once in parent module.

I tryed set <phase>none</phase> and <skip>true</skip> in submodules but without any changes.

Suggestions?

Chas answered 1/2, 2012 at 13:3 Comment(3)
For your multi-module project, are you using it to eventually build up a single artifact (like a war or ear)? If so, you could just use the buildnumber plugin for that single module instead of at the root.Karie
@Karie I could, but anyway buildnumber plugin executes for all modules. What I did wrong?Chas
you didn't do anything wrong. You specified a build directive in your root pom, which in a multi-module pom flows downward. Your child modules use your parent pom as parent which means they do everything in there also. So your code is doing exactly what you asked it to.Karie
P
3

This: Execute Maven plugin goal on parent module, but not on children

You can add <inherited>false</inherited> to the plugin configuration to avoid inheritance in children POMs:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>buildnumber-maven-plugin</artifactId>
    <version>1.0</version>
    <inherited>false</inherited>
    ...
  </plugin>
Pertinacity answered 18/11, 2015 at 16:50 Comment(0)
B
1

I would take a look into the:

<pluginManagement>...</pluginManagement>

element: http://maven.apache.org/pom.html#Plugin_Management

I've had success defining my plugins in my master/parent/root pom file through the plugin-management section, and then simply enabling their behaviour in my child pom files by simply specifying the group/artifact combination.

In your case, I'd try the following...

In your root pom.xml (notice the <pluginManagement> element):

...
<build>
  ...
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.0</version>
        <executions>
            <execution>
                <goals>
                    <goal>create</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <format>${project.version}-b{0,number}</format>
            <items>
                <item>buildNumber0</item>
            </items>
            <doCheck>false</doCheck>
            <doUpdate>false</doUpdate>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>
...
</build>
...

And then simply enable the behaviour in your module1 (or module2) pom.xml by (NO <pluginManagement> element):

<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>buildnumber-maven-plugin</artifactId>
    <plugin>
  <plugins>
  ...
</build>
...

This was all from memory, give it a shot and if it doesn't work, let me know.

Barrybarrymore answered 22/2, 2012 at 21:28 Comment(0)
C
-1

Update your pom to use version 1.3 of the plugin, then configure the plugin in each sub module with true

Camey answered 16/10, 2014 at 17:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.