0

I want to compile some java files which have multiple dependent jars and make a jar file. I have kept all dependent jars under src/main/lib. after running mvn clean install, i get compilation failure of the classes. Dependent jars are not being copied to class path it seems. Anyone can tell whats going wrong her.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>test</groupId>
    <artifactId>test</artifactId>
    <version>1.0</version>
    <repositories>
        <repository>
            <id>external-jars</id>
            <name>external-jars</name>
            <url>file://${project.basedir}\src\main\lib\</url>
        </repository>
    </repositories>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>jars</groupId>
                <artifactId>jars</artifactId>
                <version>1.0</version>
                <scope>system</scope>
                <systemPath>${project.basedir}/src/main/lib/*</systemPath>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <build>
        <finalName>finaljar</finalName>
        <sourceDirectory></sourceDirectory>
    </build>    
</project>
GYaN
  • 2,327
  • 4
  • 19
  • 39
Niki
  • 1

1 Answers1

0

You construction

<dependency>
      <groupId>jars</groupId>
      <artifactId>jars</artifactId>
      <version>1.0</version>
      <scope>system</scope>
      <systemPath>${project.basedir}/src/main/lib/*</systemPath>
</dependency>

does not work. In Maven, each artifact is addressed through groupId, artifactId and version. You cannot add a directory, but only separate jars.

While it is possible to add jars through system paths, it is much better to use a repository. Look at the possibilities in

How to add local jar files to a Maven project?

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142