Migwell
Migwell

Reputation: 20147

Getting the filename of a jar-with-dependencies as a variable

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?

Upvotes: 0

Views: 325

Answers (1)

Irwan Hendra
Irwan Hendra

Reputation: 148

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>

Upvotes: 1

Related Questions