pranay
pranay

Reputation: 2369

maven not updating jar in local repo with new build number

i have added the build number plugin in the pom of one of my modules as follows:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.0-beta-4</version>
        <executions>
            <execution>
                <phase>validate</phase>        
                <goals>
                    <goal>create</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <doCheck>false</doCheck>
            <doUpdate>true</doUpdate>
            <format>${project.version}.{0,number}</format>
            <items>
                <item>buildNumber</item>
            </items>
        </configuration>
    </plugin>

Also i tried that the jar built is kept inside a folder ./ and the jar also gets buildnumber appended to its version name by using the jar plugin as:

<plugin>

    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <archive>
        <manifest>
          <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
        </manifest>
        <manifestEntries>
          <Implementation-Build>${buildNumber}</Implementation-Build>
        </manifestEntries>
      </archive>
      <outputDirectory>target/${buildNumber}</outputDirectory>
    </configuration>
</plugin>

The build works fine and the jar is created inside target as target//myjar-.jar (Where version is 1.0 suppose and buildnumber is incremented with each build starting with 1) However in local repository the jar is stored as package//myjar-.jar , i.e the buildnumber is not getting added there. Is there a way to achieve this? Thanks.

Upvotes: 0

Views: 1285

Answers (1)

Adrian Shum
Adrian Shum

Reputation: 40036

If I understand your question correctly, everything seems fine (artifact in target directory, manifest etc), except the filename in local repository is not what you want, am I right?

If so, and if I remember correctly, that's exactly it should work. Artifact file name in local/remote repository is generated according to artifact name, version number, modifier and qualifier, and timestamp in case of snapshot. It have nothing to do with the output filename in the target directory.

Upvotes: 2

Related Questions