For my project, I have used the below configuration to generate the thin jar
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>
com.aaa.bbb.MainClass
</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/libs</outputDirectory>
<includeScope>compile</includeScope>
</configuration>
</execution>
</executions>
</plugin>
My jar is created without the dependent jars and using maven copy commands all the jars get copied into the respective folders.
Going forward I need to separate some selected jars from external jars, I have below two options
- I want to add some selected jars(some other jars from the related project) to be a part of the main jar and exclude the external jars like hibernate, springfox, etc.. creating a semi-fat jar. But don't know to add some selected jars to be a part of main jar.
- The selected jars can be placed in a folder inside the target folder(the main jar is still a thin jar) and then use the maven copy command to download only the external jars.
0 Answer(s)