Graham Seed
Graham Seed

Reputation: 894

Adding jar dependency directory to Class-Path manifest using Maven maven-jar-plugin

I'm using the maven-jar-plugin plugin and trying to add dependency jars to my jar:

https://maven.apache.org/shared/maven-archiver/examples/classpath.html

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <index>true</index>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

The manifest.mf file then contains a list of all required dependencies; ie:

... Class-Path: netty-all-4.1.22.Final.jar ...

However, my maven-dependency-plugin plugin specifies that the dependencies are placed in the /dependency-jars folder:

<configuration>
    <outputDirectory>
            ${project.build.directory}/dependency-jars/
    </outputDirectory>
</configuration>

And so, the dependencies will not be found when we execute the jar.

Tag <addClasspath>true</addClasspath> automatically adds all specified dependencies, but how do I add a directory prefix to all of them?

Upvotes: 0

Views: 2248

Answers (1)

Graham Seed
Graham Seed

Reputation: 894

Looks like the answer is:

<classpathPrefix>lib/</classpathPrefix>

as detailed in:

https://maven.apache.org/shared/maven-archiver/examples/classpath.html

Upvotes: 0

Related Questions