tags:

views:

429

answers:

4

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?

A: 

There is no such option in the standard plugin, See all options in the maven-jar-plugin page

Edit You can add an antrun task that will run after the package phase and then delete he created jar (or rename it) and re-create the jar from the classes directory. Then you can put compress="false" in the jar task definition - see here. I did similar thing using the proguard post processor.

Edit 2 Given Ran's new reason, the ant task will definite won't help to shorten the build time.

David Rabinowitz
yes, been there. I don't usually ask things I can find by a simple search.
Ran Biron
Hm. That might have come off a little too sharp - meant no offense.
Ran Biron
No problem, we don't know each other... :-)
David Rabinowitz
found another solution
David Rabinowitz
I see I forgot to add the reason - I want to shorten the build time - I don't really care about the jars sizes :)
Ran Biron
A: 

Well, you could define different jar plugin by profile. Would that be acceptable?

mikek
how? Can it be done in the top-level pom.xml?
Ran Biron
@Ran Biron: I'm not completely sure, but as you may know you can redefine plugins on a per profile basis. I've worked to little on multi level POM projects to have tested whether profile selection is passed in to child poms, but I can very well imagine that it may be so. I would test it myself, but it's time to leave the office =)
mikek
see my own answer for details. Thanks.
Ran Biron
+4  A: 

Apparently it's possible by defining this:

<profile><id>...</id>
  <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <configuration>
                    <archive>
                        <compress>false</compress>

...(close all tags)

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.

Ran Biron
does this has the bonus of working with war and ear files?
sal
no idea - try and tell us :)
Ran Biron
Why did you accepted the other answer. Yours is better ;)
victor hugo
1. I provided the details, the original answerer provided the idea.2. I think it's better to give "accepted" to another person for partial idea than to myself for a full idea.
Ran Biron
A: 

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.

walter