Object Oriented Github API
Set of classes in `com.jcabi.github` package is an object oriented Java adapter of Github API:
import com.jcabi.github.RtGithub; import com.jcabi.github.Issue; import com.jcabi.github.Github; import com.jcabi.github.Repo; public class Main { public static void main(String[] args) { Github github = new RtGithub(".. your OAuth token .."); Repo repo = github.repos().get(new Coordinates.Simple("jcabi", "jcabi-github")); Issue issue = repo.issues().create("How are you?", "Please tell me..."); issue.comments().post("My first comment!"); } }
Read JavaDoc for more information and examples.
There are a few other Java adapters of Github API, but our implementation has its advantages, including:
- All classes are private and implement public interfaces
- Out-of-the-box in-memory mock of Github server
- All classes are truly immutable and thread-safe
- Every Github object gives GET/PATCH access to its raw JSON
- HTTP request is accessible for modifications
- Entire Github API is available, at least through a configurable HTTP request
Java 7 or higher is required. The only dependency you need is (you can also download jcabi-github-1.8.0.jar
and add it to the classpath):
<dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-github</artifactId> <version>1.8.0</version> </dependency>
If you're not a Maven user, you can use a JAR with all dependencies inside (over 4Mb): jcabi-github-1.8.0-jar-with-dependencies.jar
. You can also include it to your Maven `pom.xml`:
<dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-github</artifactId> <version>1.8.0</version> <classifier>jar-with-dependencies</classifier> </dependency>
Cutting Edge Version
If you want to use current version of the product, you can do it with this configuration in your pom.xml
:
<repositories> <repository> <id>oss.sonatype.org</id> <url>https://oss.sonatype.org/content/repositories/snapshots/</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.jcabi</groupId> <artifactId>jcabi-github</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies>