BuildNumber not generated with buildnumber-maven-plugin

In my parent pom I have

<build>
 <plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
            <execution>
                <phase>validate</phase>
                <goals>
                <goal>create</goal>
                </goals>
            </execution>
        </executions>
            <configuration>
                <doCheck>true</doCheck>
                <doUpdate>true</doUpdate>
            </configuration>
        </plugin>

In a child module run a java Main class with the above default properties: buildName and scmBranch:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
    <execution>
        <id>my-execution</id>
        <phase>package</phase>
        <goals>
            <goal>exec</goal>
            </goals>
        </execution>
        </executions>
            <configuration>
            <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                        <classpath />
                        <argument>${MyMainClass}</argument>
                        <argument>test-${scmBranch}-${buildNumber}</argument>
                </arguments>
            </configuration>

But the variables are never substituted/expanded in my main class. Any ideas?

From the documentation:

required: false
type: java.lang.String
expression: ${maven.buildNumber.buildNumberPropertyName}
default: buildNumber

You can rename the buildNumber property name to another 
 property name if desired.

As I understand the buildNumber is a property provided when you include the buildnumber-maven-plugin

Answers


In your parent pom, you have not defined the pluginManagement tag. Without it, your child module does not inherit the plugins you have defined, they are used by the parent pom only. This is what you need to add to the parent pom:

<build>
    <!-- plugins used by this POM and all inheriting POMs -->
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>true</doCheck>
                    <doUpdate>true</doUpdate>
                </configuration>
            </plugin>
            <!-- other plugins -->
        </plugins>
    </pluginManagement>
</build>

Now your child module has access to the buildnumber-maven-plugin.


Need Your Help

Accessor of an inherited, synthesized property in Cocoa

cocoa properties subclass

I have two classes: Geometry and Circle. Circle is a subclass of Geometry.

Perform CRUD for todos/tasks/appointments from Outlook?

c++ com outlook outlook-vba

How can I perform CRUD (Create, Read, Update, Delete) for todos/tasks/appointments/etc from Outlook. Does Microsoft have a data api like Google that I can use to interact with Microsoft application...