JitPack.io Documentation

repository·main·Indexed 25 days ago

https://github.com/jitpack/jitpack.io

A package repository for JVM and Android projects that builds Git projects on demand from GitHub, BitBucket, GitLab, Gitee, and Azure. Documentation covers adding JitPack to Gradle projects, using snapshot and pull request versions, publishing Android libraries, accessing hosted Javadoc, and using the JitPack API for build management and project search.

Tokens
6.8K
Snippets
27
Records
54
Agent score
79%

What's inside JitPack.io

  1. Use JitCI for continuous integration

    main

    JitCI is an all-in-one solution to automate the publishing of high-quality libraries. It integrates with JitPack to provide:

    • Test execution
    • Code coverage reporting
    • Dependency auditing
    • License checks
    • Vulnerability reports
    • Automated publishing to JitPack

    You can enable it via project settings or by signing in at jitci.com.

  2. Publish Gradle projects to JitPack

    main

    To publish a Gradle project, ensure your repository contains a build.gradle file. JitPack requires either the maven or maven-publish plugin to be enabled.

    • If using the maven plugin, JitPack runs ./gradlew install.
    • If using the maven-publish plugin, JitPack runs ./gradlew build publishToMavenLocal.

    It is highly recommended to use the Gradle wrapper (gradlew) to ensure compatibility.

    apply plugin: 'maven'
        
    group = 'com.github.YourUsername'
  3. Publish Leiningen projects to JitPack

    main

    JitPack builds Leiningen projects by running lein do clean, install.

    To consume JitPack dependencies in Leiningen, add the JitPack repository and the dependency to your project.clj file.

    :repositories [["jitpack" "https://jitpack.io"]]
    :dependencies [[com.github.User/Repo "Tag"]]
  4. Add JitPack to a Gradle project

    main

    To use a GitHub project as a dependency via JitPack in Gradle, follow these two steps:

    1. Add the JitPack Maven repository: Add the JitPack URL to your repository list. It is recommended to add it at the end of your repositories list so Gradle finds other dependencies first.
    2. Add the dependency: Use the following format for the dependency coordinates:
      • Group: com.github.Username
      • Artifact: Repository Name
      • Version: A release tag, a commit hash, or branch-SNAPSHOT (e.g., master-SNAPSHOT).

    For security and performance, it is recommended to use repository content filtering to restrict JitPack to only your specific group.

    // In settings.gradle
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            mavenCentral()
            maven { url 'https://jitpack.io' }
        }
    }
    
    // In build.gradle
    dependencies {
        implementation 'com.github.User:Repo:Version'
    }
  5. Configure a Custom Domain for GroupIds

    main

    Instead of using com.github.yourcompany, you can use com.yourcompany by mapping your domain to your GitHub organization.

    1. Add a DNS TXT record that maps git.yourcompany.com to https://github.com/yourcompany.
    2. Verify the record using dig txt git.yourcompany.com.
    3. Look up https://jitpack.io/#com.yourcompany/yourrepo on JitPack. If DNS resolution works, you can select a version and get instructions.
    > dig txt git.jitpack.io
    ...
    ;; ANSWER SECTION:
    git.jitpack.io.        600    IN    TXT    "https://github.com/jitpack"
  6. Set up GitHub Webhooks for automatic builds

    main

    To build snapshots automatically on every commit, add a GitHub Webhook to your repository.

    • Webhook URL: https://jitpack.io/api/webhooks
    • Content type: application/json

    Note: The webhook triggers builds for branches you have previously requested from JitPack (e.g., master-SNAPSHOT).

  7. Publish a library on JitPack

    main

    To publish your library, you only need to create a GitHub Release. JitPack will automatically build the project if it contains a build file that can install the library into a local Maven repository.

    Tips for Publishers:

    • You can test builds before a formal release by using a specific commit hash as the version.
    • To make your library easier to use, include a sources jar in your build process.
    • Add the JitPack repository and dependency information to your project's README so users know how to consume it.
  8. Configure Gradle for Android library publishing

    main

    You must use the maven-publish plugin to publish your library.

    1. Add the plugin to your plugins block.
    2. Configure the publishing block to define your groupId, artifactId, and version.
    plugins {
        id 'maven-publish'
    }
    
    publishing {
        publications {
            release(MavenPublication) {
                groupId = 'io.jitpack'
                artifactId = 'library'
                version = '1.0'
    
                afterEvaluate {
                    from components.release
                }
            }
        }
    }
  9. Authenticate with the JitPack API

    main

    For private repositories, use Basic Authentication. Use your JitPack authentication token as the username and leave the password empty.

    You can find your token at https://jitpack.io/private.

    curl -uTOKEN: https://jitpack.io/api/builds/:groupId/:artifactId/:tag
  10. Configure a custom domain name for JitPack

    main

    You can use your own domain name as the groupId (e.g., com.yourcompany instead of com.github.yourcompany).

    Setup Steps:

    1. DNS Configuration: Add a DNS TXT record that maps git.yourcompany.com to your GitHub organization URL (e.g., https://github.com/yourcompany).
    2. Verification: Verify the record using dig txt git.yourcompany.com. It should return the GitHub URL.
    3. Lookup: Go to https://jitpack.io/#com.yourcompany/yourrepo and click Look up. If successful, you can select versions and get Maven/Gradle instructions.
    ~$ dig txt git.jitpack.io
    ...
    ;; ANSWER SECTION:
    git.jitpack.io.    600    IN    TXT    "https://github.com/jitpack"
  11. Use SSH Key Authentication

    main

    JitPack supports SSH key-based authentication or Deploy Keys.

    1. Generate keys on your JitPack user page.
    2. Add the public key to your Git repository.

    Note: To have admin permissions for the repository on JitPack, the deploy key must have push permissions.