0

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>
6
  • You are perfectly right that this is not a good practise. Commented Nov 22, 2019 at 15:35
  • but is it even possible to do so? Commented Nov 22, 2019 at 17:06
  • 3
    Never use an absolute / OS dependent classpath in a JAR file...I would suggest to create script to start your application. Commented Nov 22, 2019 at 18:50
  • @khmarbaise when we have full access to the application server, how can things go wrong with absolute classpath in a Jar file Commented Nov 22, 2019 at 19:15
  • 1
    Another reason is not use such things in an application server...there is no need for such things... Commented Nov 22, 2019 at 19:26

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.