简体   繁体   中英

I want to load all JARs from my libs project folder with Maven

I have a Java project using Maven. In my project I have a folder called libs that contains all the JARs that I can't load from internet/external repository.

My issue is how to specify to Maven to include those JARs during packaging, building etc.?

New to Maven, sorry if it is a stupid question.

EDIT : I have an automatic tool that will look up at my pom.xml on my Git to build & deploy my project on different environments. So adding it in local Maven repo, as suggested here will not help since it will work only on my PC. If I add a libs folder with my JARs it will work wherever I am.

Ask me in comments if it's not clear or if I'm mistaken.

Contrary to your EDIT adding to the local Maven repo will help and it can be automated as follows:

  • See jtahlborn's answer to Multiple install:install-file in a single pom.xml . (The current version of the maven-install-plugin is 2.5.2 . I'd use that rather than the default.)
  • The <configuration> s should look like:

     <configuration> <file>${project.basedir}/path/to/your/libs/lib-X.jar</file> <repositoryLayout>default</repositoryLayout> <!-- match the dependency declaration for this artifact --> <groupId>logan.wlv</groupId> <artifactId>lib-X</artifactId> <version>xyz</version> <packaging>jar</packaging> <!-- -------------------------------------------------- --> </configuration>
  • Put the install-plugin declaration into a build profile , eg lib .

  • Run mvn initialize -P lib once on every new PC (and once after the contents of libs , and hence the install-plugin declaration, changed) before invoking any phase that resolves dependencies first, eg compile .

or

  • Automate this even further with:

     <profile> <id>lib</id> <activation> <file> <missing>${settings.localRepository}/logan/wlv/lib-X/xyz/lib-Xx.yzjar</missing> </file> </activation> ... <profile>

    Such being able to run just mvn initialize without the explicit profile activation the very first time.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM