Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub dependency in Apache Maven project

Tags:

maven

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 ?

like image 524
stefan.nsk Avatar asked Nov 03 '22 02:11

stefan.nsk


1 Answers

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.

like image 158
carlspring Avatar answered Nov 25 '22 19:11

carlspring