Giter Site home page Giter Site logo

gpr-for-gradle's Introduction

gpr-for-gradle (Gradle Github Packages Plugin)

Gradle Plugin Portal

GitHub Packages introduced features for hosting Maven packages for free, but these require credentials even for public ones.

This grade plugin allows you to add a maven repository from GitHub Packages in one line. It also comes with a default personal access token, allowing the use of public repositories without any extra setup (see Notes on automatic authentication).

Usage

Add the plugin

Using the plugins DSL:

plugins {
    id("io.github.0ffz.github-packages") version "1.x.x"
}
Using legacy plugin application:

buildscript {
  repositories {
    maven {
      url = uri("https://plugins.gradle.org/m2/")
    }
  }
  dependencies {
    classpath("gradle.plugin.io.github.0ffz:gpr-for-gradle:1.x.x")
  }
}

apply(plugin = "io.github.0ffz.github-packages")

You may find it on Gradle's plugin plugin portal

Groovy

Within Groovy, you may add a package repository as follows:

repositories {
    maven githubPackage.invoke("owner/repo")
   // Or for all packages under the owner/org
    maven githubPackage.invoke("owner")
}

There is currently no support for further customization in Groovy.

Kotlin

Add the GitHub repo to the repositories block:

repositories {
    githubPackage("owner/repo")
    // Or for all packages under the owner/org
    githubPackage("owner")
}

Modifying default username/key

Use the githubPackages blocks above repositories to edit the template applied to every package below. Example to change credentials of every repo:

githubPackages {
    credentials {
        username = "name"
        password = "token"
    }
}

repositories {
    githubPackage("owner/repo") //now with different credentials!
}

You may also modify each package declaration as you would a regular maven repository:

repositories {
    githubPackage("owner/repo"){
        name = "anotherName"
        credentials {
            username = "name"
            password = "token"
        }
    }
}

Notes on automatic authentication

It appears sharing a PAT is currently the encouraged solution, as seen by this post from a staff member on the GitHub community forms. In a worst case scenario, the plugin will send a detailed message explaining exactly how to set up a token.

Manual token setup

  1. Generate a token at https://github.com/settings/tokens/new?scopes=read:packages&description=GPR%20for%20Gradle
  2. Open your global gradle.properties file at ~/.gradle/gradle.properties
  3. Add username and token:
    gpr.user=<GITHUB NAME>
    gpr.key=<GENERATED TOKEN>
  4. You may need to restart your IDE

For more info see this GitHub docs page.

GITHUB_ACTOR and GITHUB_TOKEN will be used within GitHub workflows, unless the username and password are manually changed.

Plans

  • Make extension functions work nicely with Groovy (feel free to open a PR for it)
  • Archive this project if Github Packages improve support for maven

gpr-for-gradle's People

Contributors

0ffz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

ark-builders

gpr-for-gradle's Issues

Repository not added when invoked from build.gradle.kts

When using a kotlin build.gradle.kts script, the readme suggests I ought to be able to invoke repositories { githubPackage("name") } to add a repository, but this seems to not work -- the repository isn't included in the repositories list provided by gradle when it's reporting that downloading a dependency has failed.

Explicitly invoking the Action that githubPackage returns seems to function as a workaround.

Originally discovered by @Millad and reported here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.