Include Maven profile name in assembly-plugin built (with dependencies) jar
java, maven-3, maven-assembly-plugin
Solution
Similar to Bhaskar's but slightly modified.
After the <build> tag, add
<finalName>${project.artifactId}-${lane}</finalName>
You can set the lane value as a property in the profile.
<profiles>
<profile>
<id>DEV</id>
<properties>
<lane>DEV</lane>
</properties>
</profile>
</profiles>
Then execute the build like you say: mvn ... -P DEV (e.g. mvn clean install -P DEV)
Problem
I'm using the maven-assembly-plugin to build an executable, monolithic jar with dependencies. I'm also using resource filtering to set some custom, lane-specific (dev, stage, prod, etc) properties. How do I make the finalName of the jar include the lane name (dev, stage, prod, etc)? I'd like the following mvn commands to result in jars that look something like this: - mvn clean install -P DEV --> ws-client-DEV.jar - mvn clean install -P STAGE --> ws-client-STAGE.jar - mvn clean install -P PROD --> ws-client-PROD.jar Is there a maven property somewhere I can't find? I would like to avoid using a redundant command line argument if possible (ie - 'mvn clean install -P DEV -Dlane=DEV'). Here's my assembly plugin configuration: ``` <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.2</version> <executions> <execution> <id>jar-with-dependencies</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <finalName>ws-client</finalName> <appendAssemblyId>false</appendAssemblyId> <archive> <manifest> <mainClass>Example</mainClass> </manifest> </archive> </configuration> </plugin> ```