Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure local jar in pom.xml

In my maven project I need to use some local jar libraries as a dependency.

I'm trying to use this method to configure them in pom.xml:

<repositories>
    <repository>
        <id>projectName.local</id>
        <url>file://${project.basedir}/libs</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.myproject</groupId>
        <artifactId>ProjectName</artifactId>
        <version>1.0</version>
    </dependency>

    <!-- other dependencies... -->
</dependencies>

I defined a local repository that points to a libs folder into the project root. Then I placed the jars in this folder:

/libs/org/myproject/ProjectName/1.0/ProjectName-1.0.jar

But, building the project I'm getting this warning:

The POM for org.myproject:ProjectName:jar:1.0 is missing, no dependency information available

And this build failure result:

Failed to execute goal on project my_project: Could not resolve dependencies for project *** : The following artifacts could not be resolved: org.myproject:ProjectName:jar:1.0: Failure to find org.myproject:ProjectName:jar:1.0 in file://C:\Users\David\Documents\NetBeansProjects\my_project/libs was cached in the local repository, resolution will not be reattempted until the update interval of projectName.local has elapsed or updates are forced -> [Help 1]

What am I missing?

like image 350
davioooh Avatar asked Oct 25 '25 21:10

davioooh


1 Answers

I think just copying the jar file will not solve your problem. You will need to install the dependency using Maven itself in that repository using a command like this one:

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file  -Dfile=path-to-your-artifact-jar \
                -DgroupId=your.groupId \
                -DartifactId=your-artifactId \
                -Dversion=version \
                -Dpackaging=jar \
                -DlocalRepositoryPath=path-to-specific-local-repo

path-to-specific-local-repo should be the path to your local repository (file://${project.basedir}/libs).

like image 51
gil.fernandes Avatar answered Oct 27 '25 11:10

gil.fernandes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!