I've created a jar with all of the dependencies using the maven-shade-plugin
. The resulting jar I'd like to install in to a directory based on an environment variable. For instance, something like $SITE_HOME/container
. Additionally, I'd like to call the command to do this work using the normal maven command, so something like:
%> mvn copy
or
%> mvn package:copy
or something, I'm not sure what works best with maven because I'm fairly new to maven.
The idea though is that I ONLY want the fat jar, I don't want resource/ or dependencies for the project, or anything other than the resulting fat jar. How can I do this with maven, and hopefully without having to write my own maven plugin.
If I understand your needs you could use this:
http://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html
You can embed that inside a Maven phase callin' it automatically when you call the phase you choose..
here you can see the usage:
(copy artifacts) http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html (copy dependencies) http://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
I hope this helps..
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.