I have a Maven project on github.com:
<project ...>
...
<groupId>com.example</groupId>
<artifactId>my-github-library</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
...
</project>
Now I want to add my-github-library as a dependency to another my-local-application project:
<project ...>
...
<groupId>com.example</groupId>
<artifactId>my-local-application</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
...
<dependencies>
...
<dependency>
<groupId>com.example</groupId>
<artifactId>my-github-library</artifactId>
<version>1.0.0</version>
</dependency>
...
</dependencies>
...
</project>
This of course doesn't work because GitHub is not a Maven repository.
How can I add an additional Maven repository to the project pom file ?
You can request open source hosting for your Github project's artifacts from the Sonatype OSS team. Then you will have to set up your project to be able to deploy to their repository (using <distributionManagement/>
in your pom.xml
and <servers/>
in your settings.xml
). Once you have deployed the artifact you're depending on, you can make your other project depend on it via a <dependency/>
and defining a <repository>
in your <repositories/>
section pointing to your repo at Sonatype.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With