-1

I am trying to append folder before for all classpath entries in manifest file.

As you can see in pom file below, I am using jar plugin to add classpath entries to manifest.

With dependency plugin I am copying dependencies to ${project.build.directory}/${finalName}-lib folder.

I want to keep these dependencies in that folder and change classpath entries to match ${finalName}-lib folder path.

pom:

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <finalName>${jarpluginoutput}</finalName>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>desktop.core.Main</mainClass>
                    </manifest>
                </archive>
                <excludes>
                    <exclude>log4j2-test.properties</exclude>
                    <exclude>**/.keep</exclude>
                </excludes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.2.0</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <includeScope>compile</includeScope>
                        <outputDirectory>${project.build.directory}/${finalName}-lib</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

1 Answer 1

0

Solution is made by adding <classPathPrefix>.

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <finalName>${jarpluginoutput}</finalName>
                <archive>
                    <manifest>
                        <classpathPrefix>${finalName}-lib</classpathPrefix>
                        <addClasspath>true</addClasspath>
                        <mainClass>desktop.core.Main</mainClass>
                    </manifest>
                </archive>
                <excludes>
                    <exclude>log4j2-test.properties</exclude>
                    <exclude>**/.keep</exclude>
                </excludes>
            </configuration>
        </plugin>
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.