2

Instead of changing the version manually, is there any way to update it with the build number?

 <version>1.2.132-SNAPSHOT</version>

In the above code, I need the build number instead of 132.

I've used the following code to generate the build number.

       <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <format>{0,number}.{1,number}.{2,number}</format>
                <items>
                    <item>buildNumber0</item>
                    <item>buildNumber1</item>
                    <item>buildNumber2</item>
                </items>
            </configuration>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

And I need the build number just before -SNAPSHOT. Any ideas ?

coder247
  • 2,913
  • 19
  • 50
  • 70
  • 1
    Why do you need that? You have SNAPSHOT's. If you change the version manually you're doing things wrong (use release plugin to make a release cycle). – khmarbaise Jan 02 '13 at 12:59

1 Answers1

0

I think you can just append your buildNumber variables to your version property:

<version>1.2.${buildNumber0}${buildNumber1}${buildNumber2}-SNAPSHOT</version>
natke
  • 743
  • 1
  • 9
  • 21