Adding external jar in a maven project

12,450

I sometimes use file system based repos for this kind of thing.

<repositories>
   <repository>
    <id>local-files</id>
    <name>local-files</name>
    <url>file://c:\test\filerepo</url>
   </repository>
</repositories>

Then you can install files into the file repo...

mvn install:install-file -Dfile=onebusaway-gtfs-1.3.3 -DgroupId=org.onebusaway.gtfs -DartifactId=onebusaway-gtfs-1.3.3 -Dversion=1.0 -Dpackaging=jar -DlocalRepositoryPath=c:\test\filerepo

Just include the above <repoisitory> entry into any pom you want to have access to the file repo. For example:

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>some-artifact</artifactId>
  <packaging>jar</packaging>
  <version>1.0</version>
  <name>some-artifact</name>
  <url>http://maven.apache.org</url>
  <repositories>
       <repository>
        <id>local-files</id>
        <name>local-files</name>
        <url>file://c:\test\filerepo</url>
       </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>org.onebusaway.gtfs</groupId>
      <artifactId>org-onebusaway-gtfs-1.3.3</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>
</project>
Share:
12,450
WantIt
Author by

WantIt

so curious with number theory

Updated on June 04, 2022

Comments

  • WantIt
    WantIt almost 2 years

    I have a maven project (I use the jersey template, since I'll be creating an API) and would like to add an external jar file. I tried to follow this reference here

    enter image description here

    I'm using Eclipse Mars in Windows environment. I added the following depedency to my pom.xml file

    enter image description here

    Now, when I try to use the jar file in my application, why is that I can't access it? The classes in the jar file couldn't be resolved.

    enter image description here