0

I have a locally created jar: scp-commons.jar classes of which I want to package in my executable jar: main.jar

package structure in scp-commons.jar: com.sample.commons.*

Package structure in main.jar: com.sample.client.*

When I build with maven, the build is successful , but the classes of scp-commons.jar are not packaged in my main.jar due to which the jar throws a class not found exception.

Given below is my pom.xml from main.jar project

        `<dependencies>
            <dependency>
                <groupId>_GroupID1_</groupId>
                <version>1</version>
                <artifactId>scp-commons</artifactId>
                <scope>system</scope>
                <systemPath>${user.lib.path}\src\main\webapp\WEB-INF\lib\scp-commons.jar</systemPath>
            </dependency>
        </dependencies>

        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>${compiler.version.source}</source>
                        <target>${compiler.version.target}</target>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-compile</id>
                            <phase>compile</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>toola-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                            <configuration>
                                <descriptors>
                                    <descriptor>assemblytoola.xml</descriptor>
                                </descriptors>
                                <archive>
                                    <manifest>
                                        <mainClass>com.sample.client.pat.toola.CpatToolA</mainClass>
                                    </manifest>
                                </archive>
                                <finalName>CPATToolA</finalName>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>`

Any help in this regard would be appreciated.

  • 1
    check out this [answer](https://stackoverflow.com/questions/54531565/how-to-add-local-jar-to-fat-jar-as-a-dependency-using-maven/54533572#54533572) use the [shade-plugin](https://maven.apache.org/plugins/maven-shade-plugin/) – Essex Boy Jan 30 '20 at 14:48
  • Don't use `systemPath`. Install the jar into your local repository and use it from there. – J Fabian Meier Jan 30 '20 at 17:04
  • 1
    Hi Jason, to prevent this kind of problems, think of a better way to set up your projects. As JF Meier above remarks, just install your library in your local repository, or if these two projects are related to each other, make them modules of a multi-module project. Eclipse (m2eclipse plugin) then correctly maintains the dependencies between them. – jazz64 Jan 30 '20 at 20:41
  • Installing the jar locally did the trick... thanx guys.. – Jason Xavier Jan 31 '20 at 06:03

0 Answers0