I have a maven project which does the following:
- Generates the jar and copies it into
target/dist
directory. - Copies all dependency jars into
target/dist/lib
directory. - Distributes the
dist
folder. - Requires the dependency jars to be executed in the classpath when running the jar.
When I added this code in my pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
It generated the following classpath in the jar:
Class-Path: lib/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar lib/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar
Obviously, this won't work because the classpath I need is as follows:
Class-Path: lib/commons-logging-1.1.1.jar lib/gson-2.8.2.jar
I went tothis page. According the documentation, what I need is the default classpathLayoutType
of simple
. But the classpath generated is in a repository layout. I even tried explicitly adding the below tag, but with no success.
<classpathLayoutType>simple</classpathLayoutType>
Why isn't the simple
layout type not working?
EDIT
I have achieved what I need using custom layout type as follows:
<classpathLayoutType>custom</classpathLayoutType>
<customClasspathLayout>lib/$${artifact.artifactId}-$${artifact.version}$${dashClassifier?}.$${artifact.extension}</customClasspathLayout>