views:

108

answers:

2

Hi,

I have this project made of multiple jars and war to make an ear. I build everything in snapshot and it works great. Then I made a release for every single project and saw that the jars and the war were slightly different in size than the snapshot ones.

Comparing file to file I realized that the .class files were all there, but slightly larger or bigger, nothing more than 40 bytes generally.

I force compilation to use java 1.5 using this tag in Maven:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target> 
                </configuration>

I use this tag for the release plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.0</version>
    <configuration>
        <releaseProfiles>release</releaseProfiles>
        <goals>deploy</goals>
    </configuration>
</plugin>

Could it be that the release plugin is compiling in 1.6 or other, explaining the classes size difference ? If so can I make the release plugin compile in 1.5 ?

Thanks for your input.

+1  A: 

You can verify the version a class is compiled for by using the javap utility included with the JDK. From the command line:

javap -verbose MyClass

In the output of javap look for "minor version" and "major version" about ten lines down.

Then use this table:

major       minor       Java platform version
45          3           1.0
45          3           1.1
46          0           1.2
47          0           1.3
48          0           1.4
49          0           1.5
50          0           1.6

The .class size difference may be due to compile version but also may be due to other compile options like compiling with debug information (line numbers in stacktraces).

A: 

Could it be that the release plugin is compiling in 1.6 or other, explaining the classes size difference ?

Can't be IMO. The Maven Release Plugin doesn't compile anything, it just triggers a phase that will itself trigger the compile phase and the Maven Compiler Plugin. In other words, the Maven Compiler Plugin and its settings will be used.

You can use the following commands to control what is happening exactly:

mvn help:active-profiles -Prelease

to check profiles. And

mvn help:effective-pom -Prelease

to check the effective pom.

Pascal Thivent