0

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?

Ranjith Ramachandra
  • 10,399
  • 14
  • 59
  • 96
  • It is better to put in mvnrepository like an open source project so that it will be visible to everyone. Other option is to maintain Nexus in Amazon S3 and publish the jar file so that it can be used in other project. – Sambit Aug 26 '19 at 15:05
  • Have you seen [this question](https://stackoverflow.com/questions/29750417/how-to-include-remote-jar-dependency-in-maven) and its comments? Maybe it helps (TL;DR better put it in a repo) – Federico klez Culloca Aug 26 '19 at 15:08
  • @FedericoklezCulloca I did take a look at that link. The question is kind of the same but the answer does not help as it did not help the original author either – Ranjith Ramachandra Aug 26 '19 at 15:10
  • @Sambit can you share an example URL on how to do the nexus in s3? – Ranjith Ramachandra Aug 26 '19 at 15:10
  • Check this links, https://guides.sonatype.com/repo3/quick-start-guides/aws-for-repo/ , https://blog.sonatype.com/nexus-repository-3.12-support-for-s3-blob-stores – Sambit Aug 26 '19 at 15:12
  • I recently answered somewhat similar question https://stackoverflow.com/a/57478250/2168752 – Milen Dyankov Aug 26 '19 at 15:53

2 Answers2

1

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>
1
<dependency>
    <groupId>com.xxx.xxx</groupId>
    <artifactId>example-app</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/yourJar.jar</systemPath>
</dependency>
Qingfei Yuan
  • 1,196
  • 1
  • 8
  • 12