I have a jar plugin but it's not running because it isn't including the external dependencies in the jar. I can't seem to figure out how to include these dependencies, I seem to be finding a bunch of different solutions that conflict with each other for some reason. I ideally would like it to run on systems without the need for any special maven commands.
Asked
Active
Viewed 57 times
0
-
you mean you want to export your plugin with all the jars packaged along with it? Can http://stackoverflow.com/q/574594/2231632 help? – Praba May 05 '14 at 04:47
-
I basically mean I want my java application to be command line executable. I don't want the user of my executable jar to have to have maven to run it. So ideally I would like a different solution than the one you linked. – user3056052 May 05 '14 at 05:17
-
You could use maven assembly plugin to create a jar with dependencies [jar-with-dependencies](http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies) – Skizzo May 05 '14 at 07:30
2 Answers
0
create maven pom.xml with
<packaging>jar</packaging>
By default it should not pack into your jar all dependent libraries.
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

Aditya Ekbote
- 1,493
- 3
- 15
- 29
-
If you dont have a manifest in your jar invoking java -jar will not work. Use this command if you dont have a manifest:"java -cp foo.jar full.package.name.ClassName" or this is common command "java -jar
.jar" Now can you vote up my answer please? – Aditya Ekbote May 05 '14 at 05:56
0
What you are looking for is to build an über-jar. The Maven Shade plugin can do that - http://maven.apache.org/plugins/maven-shade-plugin/. It even allows for renaming of classes.

Hardy
- 18,659
- 3
- 49
- 65