MR AND
MR AND

Reputation: 406

Making absolute reference to a classpath in Maven

I have a customized jar that the application uses. Instead of installing jar in maven I want to make reference to it by defining absolute location for that jar in the manifest file. I am using the code shown below to update information in manifest file. However, I am not sure how can I reference to the jar location that uses absolute path like : D:/Shared_library/Test.jar . This might not be a good practice but I want to see if there is anything like that:

  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.ad.MainClass</mainClass>
                            <addClasspath>true</addClasspath>

                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

Upvotes: 0

Views: 333

Answers (1)

Ramu
Ramu

Reputation: 681

You can add it using <manifestEntries> tag.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Class-Path>file:///D:/Shared_library/Test.jar</Class-Path>
                        </manifestEntries>
                        <manifest>
                            <mainClass>org.ad.MainClass</mainClass>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

Upvotes: 1

Related Questions