maven - Cannot get unpack-dependencies to run before jar:jar, no matter what I try -
no matter how try:
i cannot maven-dependency-plugin/unpack-dependencies run before maven-jar-plugin/jar when running mvn clean install command line.
every damn time, see running jar:jar before unpack stuff runs, saw in googling talk of adding pre-package phase maven lifecycle, doesn't seem working thought.
basically want create single jar file containing necessary classes (all 2600 of them). jar gets manifest enables run in manner of:
java -jar blah.jar
if ever work...
and here's xml snippet...
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.2</version> <executions> <execution> <id>unpack-dependencies</id> <phase>package</phase> <goals> <goal>unpack-dependencies</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactid>maven-jar-plugin</artifactid> <configuration> <archive> <manifest> <mainclass>archivedb.read</mainclass> </manifest> </archive> </configuration> </plugin>
i'm dangerously close crying uncontrolably baby here.... hey! that's maven!
the answer:
as can't answer own question 8 hours, here's solution..
it seems maven has moved on in last 8 months, seems have plugin, express purpose of build 'fat' jars'. documentation @ following url:
http://maven.apache.org/plugins/maven-shade-plugin/examples/executable-jar.html
i've changed configuration following , works well, thank you:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-shade-plugin</artifactid> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.manifestresourcetransformer"> <mainclass>archivedb.read</mainclass> </transformer> </transformers> </configuration> </execution> </executions> </plugin>
in original question, replace phase following phase.
<phase>prepare-package</phase>
this cause jars extracted first. problem, shade solution better, still post here reference other similar problems shade not help.
the output path set make sure jar's contents end in dir jar:jar goal packages (target/classes).
full plugin execution xml snippet:
<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <version>2.4</version> <executions> <execution> <id>unpack-dependencies</id> <phase>prepare-package</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includes>**/*.class</includes> <excludes>**/*.properties</excludes> <outputdirectory>${project.build.outputdirectory}</outputdirectory> </configuration> </execution> </executions> </plugin>
Comments
Post a Comment