Is there an option in Maven (2.0.9) to turn off jar compression for the entire operation? I'm using Maven both in the build server and in my work station and I'd like to disable jar compression on the work station builds (development only). However, I don't want to touch all the poms and create two versions for each.
Is there an option for turning off jar compression by environment variable, file or by touching a single pom.xml?
The maven jar plugin provides the capability to build jars files, if you define that your project is packaged as a jar file, maven will call implicitely to this plugin. We don´t need to define it inside pom. xml it will be downloaded and executed when maven needs it.
This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies.
jar file contains Spring boot framework class files having this contents while the . jar. original file contains actual class files of my application. Snapshot of target folder.
Apparently it's possible by defining this:
<profile><id>...</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<configuration>
<archive>
<compress>false</compress>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
in the top-level pom.xml. As a side note - this didn't really solved my initial problem of the build taking too much time.
Add the following to the build.plugins section in your project's pom.xml file.
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<compress>false</compress>
</archive>
</configuration>
</plugin>
This turns off jar file compression for your maven project.
finally I found the answer of this topic (turn off the jar compression), configuring directly into the pom, also I found other two interesting details: putting a different jar's name and includ a "manifest" definition. Here is my pom fragment.
<build>
<finalName>***FileName***</finalName>
<plugins>
<!-- Set a JDK compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Make this jar executable -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!-- Jar file entry point -->
<mainClass>***package.test.ClassTest***</mainClass>
</manifest>
<compress>***false***</compress>
</archive>
</configuration>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With