Ranjith Ramachandra
Ranjith Ramachandra

Reputation: 10764

Is there a way to include a public jar URL as a maven dependency?

I have a jar file which I have publicly hosted on s3. I would like to include it in another Maven Java project.

Can I include it in the pom.xml as a dependency?

Upvotes: 1

Views: 2305

Answers (2)

user3237183
user3237183

Reputation:

If you file structure follows the maven folder structure then you just need to specify

    <repositories>
        <repository>
            <id>example-repo</id>
            <url>https://your_website/path</url>
        </repository>
    </repositories>

If you want to just link the jar then you need to use a download plugin https://github.com/maven-download-plugin/maven-download-plugin to download your jar to a lib folder

<plugin>
    <groupId>com.googlecode.maven-download-plugin</groupId>
    <artifactId>download-maven-plugin</artifactId>
    <version>1.4.2</version>
    <executions>
        <execution>
            <id>install-jbpm</id>
            <phase>compile</phase>
            <goals>
                <goal>wget</goal>
            </goals>
            <configuration>
                <url>http://path_to_your_jar</url>
                <outputDirectory>${project.build.directory}
            </configuration>
        </execution>
    </executions>
</plugin>

then reference it with

 <dependency>
    <groupId>com.sample</groupId>
    <artifactId>sample</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/yourJar.jar</systemPath>
</dependency>

Upvotes: 1

Qingfei Yuan
Qingfei Yuan

Reputation: 1212

<dependency>
    <groupId>com.xxx.xxx</groupId>
    <artifactId>example-app</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/yourJar.jar</systemPath>
</dependency>

Upvotes: 1

Related Questions