Hi,
I have a strange problem when building an assembly with Maven 3.0.3, and I
don't know where to debug...:
My project uses a combination of the appassembler mojo (1.1.1) and
assembly plugin (2.2.1), both attached to the "package" phase, to create a
tar.gz archive that basically has the following structure:
my-prg/
my-prg/bin/
my-prg/bin/my-prg.cmd
my-prg/bin/my-prg.sh
my-prg/bin/local-log4j.xml
my-prg/bin/log4j.dtd
my-prg/lib/
(lots of Jar files)
my-prg/log/
my-prg/log/readme.txt
An end user unzips the archive and starts the program by one of the shell
scripts (.cmd for Windows, .sh for Unix).
Today I released a new version of my program, and just before informing my
colleages that it's available I tested it by myself from a Windows box and
finally got ClassNotFoundException because of a missing dependency Jar in
the lib folder; more precisely xalan:serializer:2.7.1
Looking into the tar.gz archive I couldn't see that jar although it is
used as a transitive compile-time dependency somewhere in the dependency
tree of my program. The latter is verifiable by for example mvn
dependency:tree:
thorsten$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building my-prg 0.4.6
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ my-prg ---
[INFO] prg:my-prg:jar:0.4.6
...
[INFO] | +- lib:v-base:jar:1.8:compile
[INFO] | | +- org.apache.axis:axis-saaj:jar:1.4:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.1.1:compile (version
managed from 1.0.4)
[INFO] | | +- commons-validator:commons-validator:jar:1.0.2:compile
[INFO] | | | +- commons-beanutils:commons-beanutils:jar:1.5:compile
[INFO] | | | \- commons-collections:commons-collections:jar:2.1:compile
[INFO] | | +- commons-digester:commons-digester:jar:1.8:compile
[INFO] | | +- oro:oro:jar:2.0.8:compile
[INFO] | | +- commons-discovery:commons-discovery:jar:0.4:compile
[INFO] | | +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] | | +- xerces:xercesImpl:jar:2.9.1:compile
[INFO] | | \- xalan:xalan:jar:2.7.1:compile
[INFO] | | \- xalan:serializer:jar:2.7.1:compile
...
For curiosity I did a "mvn package" on my project by using Maven 2.2.1 and
exactly the same code base. Comparing the resulting archives shows an
interesting phenomenon:
* The archive created by Maven 3.0.3 contains a dependency to
org.apache.xmlgraphics:batik-js:1.7 (not shown by dependency:tree) and is
missing one to xalan:serializer:jar
* The archive created by Maven 2.2.1 contains only those dependencies that
are listed in the dependency tree with scope "compile".
>From my pom.xml:
(...)
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<targetPath>../my-prg</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version><!--$NO-MVN-MAN-VER$ -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.5</version>
<configuration>
<providerImplementations>
<cvs>cvs_native</cvs>
</providerImplementations>
<goals>install</goals>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-3</version>
<configuration>
<locales>de</locales>
</configuration>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>attach-appassembler</id>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<platforms>
<platform>unix</platform>
<platform>windows</platform>
</platforms>
<binFileExtensions>
<unix>.sh</unix>
<windows>.cmd</windows>
</binFileExtensions>
<assembleDirectory>
${project.build.directory}/my-prg</assembleDirectory>
<repositoryLayout>flat</repositoryLayout>
<repositoryName>lib</repositoryName>
<includeConfigurationDirectoryInClasspath>
false</includeConfigurationDirectoryInClasspath>
<programs>
<program>
<mainClass>my.prg.MyTool</
mainClass>
<name>
${project.artifactId}</name>
</program>
</programs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version><!--$NO-MVN-MAN-VER$ -->
<configuration>
<descriptors>
<descriptor>src/assembly/bin.xml</
descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>create-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
So, no big magic there.
What I have seen so far is that according to the pom of batik-script which
is referenced somewhere in the dependency tree it has a dependency to
batik-js:
*snip*
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>batik-js</artifactId>
<version>1.7</version>
</dependency>
*snip*
but dependency:tree doesn't list it. Why that?
Looking at the output of "mvn -e -X package" there seems to be a
discrepancy in the way the assembly and appassembler plugins retrieve /
fetch the dependency tree:
(...)
[DEBUG]
-----------------------------------------------------------------------
[DEBUG] Goal:
org.apache.maven.plugins:maven-assembly-plugin:2.2.1:attached
(create-assembly)
[DEBUG] Style: Aggregating
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
(...)
[DEBUG] org.apache.axis:axis-saaj:jar:1.4:compile
[DEBUG] commons-logging:commons-logging:jar:1.1.1:compile
[DEBUG] commons-validator:commons-validator:jar:1.0.2:compile
[DEBUG] commons-beanutils:commons-beanutils:jar:1.5:compile
[DEBUG] commons-collections:commons-collections:jar:2.1:compile
[DEBUG] commons-digester:commons-digester:jar:1.8:compile
[DEBUG] oro:oro:jar:2.0.8:compile
[DEBUG] commons-discovery:commons-discovery:jar:0.4:compile
[DEBUG] wsdl4j:wsdl4j:jar:1.6.1:compile
[DEBUG] xerces:xercesImpl:jar:2.9.1:compile
[DEBUG] xalan:xalan:jar:2.7.1:compile
[DEBUG] xalan:serializer:jar:2.7.1:
(...)
(yes, exactly, no "compile" at the right side of serializer. I guess that
explains why the dependency isn't contained in the archive.)
and basically the same list printed as debug output of the appassmbler.
Do you have any idea what is causing this? I.e. why the resulting archives
are different using Maven 2.2.1 or 3.0.3?
Regards
Thorsten
PS: I tested it with Maven 3.0.3 using Java 1.6.0_24, first on Solaris 11
Express and then on Mac OS X 10.6.7.