Hi,
I'm working on Apache AVRO (Issue 570) and I'm having a maven issue that I
was hoping to get some help with. The pre-existing pom.xml
is using the shade plugin to build a jar which includes all of the
dependencies, unpacked. The configuration is below.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<!-- primary artifact is shaded -->
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.apache.avro.tool.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
The net result of running the shade plugin is three jars
1. avro-tools-1.6.0-SNAPSHOT.jar - which includes all of the dependency
jars as well as the classes specific to this project.
2. original-avro-tools-1.6.0-SNAPSHOT.jar - which doesn't include any
dependency files
3. avro-tools-1.6.0-SNAPSHOT-nodeps.jar - which seems to be the same
as original-avro-tools-1.6.0-SNAPSHOT.jar.
Now I need to build another jar, avro-tools-1.6.0-SNAPSHOT-job.jar, which
places all the jars on which we depend in the directory "lib"
inside avro-tools-1.6.0-SNAPSHOT-job.jar. avro-tools-1.6.0-SNAPSHOT-job.jar
should also contain the class files for avro-tools.
Because the shaded plugin causes avro-tools-1.6.0-SNAPSHOT.jar to contain
unpacked versions of all dependencies, I set my maven assembly configuration
to use the "nodeps" version of the avro-tools jar.
Unfortunately, this prevents any of the tools code from being included in
the jar built by the assembly plugin.
This is the configuration for my assembly file.
<assembly
xmlns="
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>job</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>false</unpack>
<scope>runtime</scope>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>org.apache.avro:avro-tools</exclude>
</excludes>
</dependencySet>
<dependencySet>
<unpack>true</unpack>
<scope>runtime</scope>
<outputDirectory>/</outputDirectory>
<includes>
<include>org.apache.avro:avro-tools:jar:${project.version}:nodeps</include>
</includes>
<unpackOptions>
<excludes>
<exclude>META-INF</exclude>
<exclude>META-INF/**</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
</assembly>
If I remove "nodeps" then the jar built by the assembly plugin ends up
containing unpacked as well as packed versions of the dependencies because
its using
avro-tools-1.6.0-SNAPSHOT.jar
Can anyone tell me how I can leave the shaded plugin configured as is, and
still use the assembly plugin to build avro-tools-1.6.0-SNAPSHOT-job.jar?
Thanks
Jeremy