Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

stachu540/github-gradle-plugin

Repository files navigation

Travis Releases

Getting Started

Requirements

Gradle 4+ with Kotlin DSL

Guide

Step 1: Create your Personal Access Token using this site

It requires 2 scopes read:packages and write:packages. When your repository is private repo scope is required too. For more about configuring for Maven use this link

Step 2: Apply the plugin to your Gradle build script

Groovy build.gradle
plugins {
    id "com.github.registry" version "0.1.0"
}
Kotlin build.gradle.kts
plugins {
    id("com.github.registry") version "0.1.0"
}

Step 3: Add the github configuration closure to your build file

github {
    token = '<your personal access token here>' // is required to uploading your artifacts
    publications = ['MyPublication'] 
    repositoryOwner = '<repository owner>' // required if your repository owner is a different as your personal access token
}
publishing {
    publications {
        MyPublication(MavenPublication) {
            artifactId = archivesBaseName
            from(components.java)
            artifact(sourcesJar)
            artifact(javadocJar)
            artifact(kdocJar)
        }
    }
} 
Kotlin build.gradle.kts
github {
    token = "<your personal access token here>" // is required to uploading your artifacts
    publications = arrayOf("MyPublication")
    repositoryOwner = "<repository owner>" // required if your repository owner is a different as your personal access token
}

publishing {
    publications {
        register("MyPublication", MavenPublication::class) {
            artifactId = base.archivesBaseName
            artifact(tasks.named<Jar>("sourcesJar").get())
            artifact(tasks.named<Jar>("javadocJar").get())
            artifact(tasks.named<Jar>("kdocJar").get())
            from(components["java"])
        }
    }
}