I have few system dependencies in my maven project which I have included like this:
<dependency>
<groupId>Com.myCompany</groupId>
<artifactId>myArtifact</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${project.basedir}\lib\myArtifact-1.0.jar</systemPath>
</dependency>
I am trying to create a executable jar [fat jar] which includes all the required dependencies , so the jar can run standalone .
I am using "maven-assembly-plugin" for packaging in this way:
<plugin>
<artifactId>maven-assembly-plugin<artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true<addClasspath>
<mainClass>com.mycompany.Application</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
The problem is that when the package is created the system dependencies are not included in the jar and I encounter ClassNotFound exceptions while I run it.
Can someone guide me with the correct way of configurations?
Update:
As few people mentioned I could install of the dependencies to local repository . The problem here is that We have a automated build server which gets triggered when ever we commit to the repo. I really don't want to install them on the remote build server.
Digging deep , found this hacky configuration (NOT recommended!!)
Reference this xml in the maven assembly plugin:
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/assembly.xml</descriptor>
</descriptors>
</configuration>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>jar-with-all-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
<scope>system</scope>
</dependencySet>
</dependencySets>
</assembly>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.