1

I am using Spring boot 2.0.5,and added code to generate build number using maven build number plugin. The build number is generating fine. I can see on jar and in the builNumber.properties file but its not being substituted in finalName in version.txt file.

Additional details:

Here is my POM.

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <id>buildNumber</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>create</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <format>{0,number}</format>
                <items>
                    <item>buildNumber</item>
                </items>
                <doCheck>false</doCheck>
                <doUpdate>false</doUpdate>
                <revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
            </configuration>
        </plugin>
    </plugins>
    <resources>
  <resource>
    <directory>src/main/resources</directory>
     <filtering>true</filtering>
  </resource>
</resources>
    <finalName>${project.artifactId}-${project.version}.${buildNumber}</finalName>
</build>

I have created version.txt file in resources folder and it has following text.

@project.build.finalName@

On maven clean install this file is updated in target folder. In below logs line # 2 you can see build number is added to jar file name.

[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ try ---
[INFO] Building jar: /home/ubuntu/Spring/SpringBootData-REST/target/try-0.0.1-SNAPSHOT.10.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.0.5.RELEASE:repackage (default) @ try ---
[INFO] 
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ try ---
[INFO] Installing /home/ubuntu/Spring/SpringBootData-REST/target/try-0.0.1-SNAPSHOT.10.jar to /home/ubuntu/.m2/repository/com/try/0.0.1-SNAPSHOT/try-0.0.1-SNAPSHOT.jar
[INFO] Installing /home/ubuntu/Spring/SpringBootData-REST/pom.xml to /home/ubuntu/.m2/repository/com/try/0.0.1-SNAPSHOT/try-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

But buildNumber is not replaced in version.txt. Here is how it looks after maven clean install.

try-0.0.1-SNAPSHOT.${buildNumber}

Here is buildNumber.properties file with the buildNumber.

#maven.buildNumber.plugin properties file
#Sat Mar 09 11:51:51 CST 2019
buildNumber=10

Can you point out whats wrong?

1 Answer 1

2

So I found a workaround. Changed my Version.txt to below instead of @project.build.finalName@ and its working fine now.

@project.artifactId@
@project.version@
@buildNumber@

Output

SpringBootDataRest
1.0
15
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.