Reputation: 721
I have maven project. I need compile this project for test and for production.
production should not contain private.key file. I excluded it like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<excludes>
<exclude>license/private.key</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>parking.application.Starter</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
project don't have maven profiles. Should I create profiles for this little exception or there are another way? and If I have to create profiles, how do I do this without repeating too much code?
Upvotes: 1
Views: 87
Reputation: 721
I found only one solution use invalid property for profile and real for default
<profiles>
<profile>
<id>privateKey</id>
<properties>
<exclude.private.key>none</exclude.private.key>
</properties>
</profile>
</profiles>
<properties>
<exclude.private.key>license/private.key</exclude.private.key>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<excludes>
<exclude>${exclude.private.key}</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>parking.application.Starter</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
run for production: mvn
run for test: mvn -P privateKey
Upvotes: 1
Reputation: 172628
You can try using the packagingExcludes
parameter. Something like this:-
<configuration>
<packagingExcludes>META-INF/abc.xml</packagingExcludes>
</configuration>
Upvotes: 0