Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use a GitHub project directly in Maven?

Tags:

java

github

maven

I am interested in using a project on GitHub as a dependency in my project. The GitHub project has a pom file. Can I modify my pom file to use this project? If so, how? If not, what is my best course of action?

like image 733
Bjorn Roche Avatar asked Jan 15 '12 15:01

Bjorn Roche


People also ask

How do I add a Git repository to Maven?

To bring a GitHub hosted Maven project into Eclipse, follow these steps: Copy the GitHub URL of the repository to the clipboard. Open Eclipse and choose Import –> Projects from Git (with smart import) Choose the Clone URI option in the Git import wizard and click Next.

How do I run a project directly from GitHub?

On GitHub.com, navigate to the main page of the repository. Above the list of files, click Code. Click Open with GitHub Desktop to clone and open the repository with GitHub Desktop. Follow the prompts in GitHub Desktop to complete the clone.

Does Maven use Git?

GIT holds the sourcecode of your application. MAVEN is used for dependency management. It holds the binary dependecies of your application. It also creates a abstraction of the used IDE.


2 Answers

Try jitpack, you just need to add the dependency, jitpack will build others for you.

From home page:

jitpack
Easy to use package repository for Gradle and Maven projects
JitPack builds GitHub projects on demand and provides ready-to-use packages

HOW

  1. Add repository first
<repository>     <id>jitpack.io</id>     <url>https://jitpack.io</url> </repository> 
  1. Add dependency
<dependency>     <groupId>com.github.User</groupId>     <artifactId>Repo name</artifactId>     <version>Release tag</version> </dependency> 

TIPS:

You can see its build log too https://jitpack.io/com/github/NanoHttpd/nanohttpd/Release-2.1.0/build.log

like image 118
wener Avatar answered Sep 20 '22 15:09

wener


Not in the way I think you mean, AFAIK.

You can use github as a Maven repository--this is not the same thing as directly referencing a project, and that it has a pom file means only that it's a Maven project.

If the project is not available in the central, or other, repository, your best bet may be to clone it, build it, and install it locally. You should confirm that it's truly not available elsewhere.

like image 32
Dave Newton Avatar answered Sep 21 '22 15:09

Dave Newton