Retrieve svn last changed revision number with the buildnumber-maven-plugin
<p>I'm currently developing a microservice based architecture for my application. I've got a maven multi-module project which has many services, so I can easily deploy them to the docker hub using the maven deploy command and also a <a href="https://github.com/spotify/docker-maven-plugin" rel="noreferrer">maven docker plugin</a>. </p>

<p>Still, the docker image tags are based in the project version number, while I would like to have them tagged with each repository's last changed revision number. From the time being, I'm trying just to add this field as a manifest entry using the <a href="http://maven.apache.org/plugin-developers/cookbook/add-svn-revision-to-manifest.html" rel="noreferrer">buildnumber-maven-plugin</a>:</p>

<p>Let's say that's my multi-module project:</p>

<pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
...

    &lt;modules&gt;
        &lt;module&gt;module-a&lt;/module&gt;
        &lt;module&gt;module-b&lt;/module&gt;
    &lt;/modules&gt;

...

&lt;/project&gt;
</code></pre>

<p>And the model for module-a would be:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    ...


    &lt;scm&gt;
        &lt;connection&gt;scm:svn:http://myrepo.com/svn/application/module-a&lt;/connection&gt;
    &lt;/scm&gt;

    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                &lt;artifactId&gt;buildnumber-maven-plugin&lt;/artifactId&gt;
                &lt;version&gt;1.4&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;phase&gt;validate&lt;/phase&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;create&lt;/goal&gt;
                        &lt;/goals&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
                &lt;configuration&gt;
                    &lt;doCheck&gt;false&lt;/doCheck&gt;
                    &lt;doUpdate&gt;true&lt;/doUpdate&gt;
                    &lt;useLastCommittedRevision&gt;true&lt;/useLastCommittedRevision&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt;
                &lt;configuration&gt;
                    &lt;archive&gt;
                        &lt;manifestEntries&gt;
                            &lt;SCM-Revision&gt;${buildNumber}&lt;/SCM-Revision&gt;
                        &lt;/manifestEntries&gt;
                    &lt;/archive&gt;
                &lt;/configuration&gt;
            &lt;/plugin&gt;
            ....
        &lt;/plugins&gt;
    &lt;/build&gt;

    &lt;dependencies&gt;
        ...
    &lt;/dependencies&gt;

&lt;/project&gt;
</code></pre>

<p>The issue is that {buildNumber} evaluates to my working copy number, which is the one referring to the last commit made to the repository and not to the <code>scm:svn:http://myrepo.com/svn/application/module-a</code> location. To explain it better, when I display the properties of module-a from tortoise I've got this:</p>

<p><a href="https://i.stack.imgur.com/VLNfu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VLNfu.png" alt="enter image description here"></a></p>

<p>What I want is to retrieve 3248 which refers to the last real change made to module-a, instead of 3257 (working copy), which is what I'm getting from the plugin. That way the docker plugin would know if it's a different image tag and push it only if changes were made to the module in the repo.</p>