DM_Morpheus
DM_Morpheus

Reputation: 730

Bundle local JAR dependency within the target JAR

My project structure is something like this.

ProjectX - depends on ProjectY which is a local JAR, added as a dependency like this:

<dependency>
        <groupId>com.wow.projecty</groupId>
        <artifactId>projecty</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>/Users/somepath/ProjectY.jar</systemPath>
</dependency>

Now, I'm creating a JAR for ProjectX with all the dependencies bundled in the JAR using this.

<plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>ProjectXDriver</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

This is bundling all the dependencies from Maven but not the ones from local filesystem. In this case, classes from ProjectY are missing from the final JAR. (Also checked using jar tf)

What am I missing?

Upvotes: 0

Views: 69

Answers (1)

DM_Morpheus
DM_Morpheus

Reputation: 730

Quick fix I found for this. Just install the JAR in the local maven repository and use it normally (without system scope / systemPath.

mvn install:install-file -Dfile=ProjectY.jar -DpomFile=../pom.xml

Upvotes: 1

Related Questions