How to connect Java in dependencies from git repository?

Hello! I'm new in Java and I can not Google how to drain the dependence of github. In Java there maven, sbt, gradle, etc., but I have not seen examples where you can just provide a link to the git repo and deflate. In a PHP composer simply indicated the project name, version, and a link to the repository and you're done. But as in Java?
August 23rd 19 at 10:34
2 answers
August 23rd 19 at 10:36
Solution
1)Create a Maven project
2)Open the file pom.xml

By default, the contents of the file like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelversion>4.0.0</modelversion>

<groupid>ru.test</groupid>
<artifactid>test.a</artifactid>
<packaging>war</packaging>
<version>1</version>
<name>-project</name>

</project>


3) Add the repository
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>

4) Add the dependence
<dependency>
<groupid>com.github.User</groupid>
 <artifactid>Repo name</artifactid>
 the <version>tag the Release</version>
</dependency>


In the end, the full content of pom-Nika :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelversion>4.0.0</modelversion>

<groupid>ru.test</groupid>
<artifactid>test.a</artifactid>
<packaging>war</packaging>
<version>1</version>
<name>-project</name>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupid>com.github.User</groupid>
 <artifactid>Repo name</artifactid>
 the <version>tag the Release</version>
</dependency>
</dependencies>
</project>
Took the first available repository:
https://github.com/json-iterator/java

Your example pom added the following information:
<repositories>
<repository>
<id>test</id>
<url>https://github.com/json-iterator/java.git</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupid>com.github.json iterator</groupid>
<artifactid>java</artifactid>
<version>jsoniter-java-0.9.7</version>
</dependency>
</dependencies>


not working(
Error: "dependency com.github.json-iterator:java:jsoniter-java-0.9.7 not found" - Asa.Wi commented on August 23rd 19 at 10:39
: changed to another option - using JitPackŠ° - novella_Volkman commented on August 23rd 19 at 10:42
: Yes, I already tried this option with com.github.json iterator to work. Tried with another repa com.github.pubnub:java:4.3.1 not start, changed the version to 4.3.0 and everything is OK. I understand that in order to go from the Gita to pump up the dependency should use a turnip https://jitpack.iowhile addiction itself needs to meet certain requirements to jitpack missed it? - Asa.Wi commented on August 23rd 19 at 10:45
: I have successfully come out of addiction with a valid id and the url of the repository changed the response to JitPack - since it is universal should work with all projects , something that can not a particular version to get quite strange ,but with 4.4.0 ? - novella_Volkman commented on August 23rd 19 at 10:48
v4.4.0 - normal
There he offers 4.3.1 shareportal)
https://jitpack.io/#pubnub/java

In any case I learned what I wanted) thank you very much) the rest of the subtleties - Asa.Wi commented on August 23rd 19 at 10:51
August 23rd 19 at 10:38
It's much easier in gradle.
A possible example of how it is going to be? - Asa.Wi commented on August 23rd 19 at 10:41

Find more questions by tags ComposerGitHubJavaApache Maven