I'm using the maven-assembly-plugin
to package my jar file with dependencies, which works fine and correctly generates a jar file. The output file from this is specified with finalName
:
<plugin>
<!--Many lines omitted-->
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>MyFinalJar-${project.version}</finalName>
</configuration>
</plugin>
Now, I need to access this finalName
in another plugin, which does some packaging of the jar file. I have the ${project.build.finalName}
variable, but that doesn't give me the jar-with-dependencies, it just gives me the plain jar that I don't want.
How can I access this final jar filename without repeating myself?
On the top of your pom file declare:
<properties>
<finalproject.name>someprojectname</finalproject.name>
</properties>
and then use it everywhere else using:
${finalproject.name}
for example:
<configuration>
<finalName>${finalproject.name}</finalName>
</configuration>