Home

Awesome

Gradle Github info plugin

License CI Appveyor build status codecov

About

Plugin generates common github links (like repository, issues, vcs etc) for project and configures common plugins. The main intention is to remove boilerplate and simplify project configuration.

Features:

You can use it with java-lib plugin to remove more configuration boilerplate for java or groovy library or gradle plugin.

Summary

Setup

Maven Central Gradle Plugin Portal

buildscript {
    repositories {
        gradlePluginPortal()
    }
    dependencies {
        classpath 'ru.vyarus:gradle-github-info-plugin:2.0.0'
    }
}
apply plugin: 'ru.vyarus.github-info'

OR

plugins {
    id 'ru.vyarus.github-info' version '2.0.0'
}

Compatibility

Plugin compiled for java 8, compatible with java 17

GradleVersion
72.0.0
5.11.5.0

Snapshots

<details> <summary>Snapshots may be used through JitPack</summary> </details>

Usage

Minimum required configuration:

github {
    user 'test'
    license 'MIT'    
}

User may be used to define either user or organization (links will be correct for both). github.repository will be set to project name by default (root project name in case of multi-module).

Other license properties may be also required (see below).

All other properties are generated by conventions. You can override any property.

If some required properties are not set validation error will be thrown to prevent incorrect usage.

Using in configurations

All properties may be used in other configurations

github {
    user 'test'
    license 'MIT'
}

somePlugin {
    websiteUrl = github.site
    vcsUrl = github.vcsUrl
    importantFileUrl = github.rawFileUrl('IFile.txt')
}

Available properties

PropertyDescriptionDefault value
userGithub user or organization name
repositoryGithub repository name$rootProject.name
branchBranch name for file linksHEAD (to support both legacy 'master' and new 'main')
licenseLicense short name (e.g. 'MIT')
licenseNameLicense full name (e.g. 'The MIT License')may be set by convention (see license section)
licenseUrlUrl to license filemay be set by convention (see license section)
repositoryUrlGithub repository urlhttps://github.com/$user/$repository
issuesUrl to github issueshttps://github.com/$user/$repository/issues
siteProject website$repositoryUrl
vcsUrlVersion control urlhttps://github.com/$user/${repository}
scmConnectionSCM connection urlscm:git:git://github.com/$user/${repository}
changelogFilePath to changelog file, relative to project rootCHANGELOG.md, CHANGELOG.txt or CHANGELOG if file found in project root

License

Plugin contains hardcoded info for most common licenses:

License IDLicense name
ApacheApache License 2.0
GPLv2GNU General Public License 2.0
GPLv3GNU General Public License 3.0
AGPLGNU Affero General Public License 3.0
LGPLv2.1The GNU Lesser General Public License 2.1
LGPLv3The GNU Lesser General Public License 3.0
MITThe MIT License
ArtisticArtistic License 2.0
EPLEclipse Public License 1.0
BSD 3-clauseThe BSD 3-Clause License
MPLMozilla Public License 2.0

If license property value is one of license id above then licenseName will be set. Otherwise, licenseName must be specified manually.

licenseUrl default:

Utility method

github.rawFileUrl(file, branch) method may be used in build script to generate direct (raw) urls to files on github repository.

For example,

github.rawFileUrl('folder/file.txt')

Will generate the following url:

https://raw.githubusercontent.com/$user/$repository/HEAD/folder/file.txt

Branch parameter is optional ('HEAD' by default in order to support both old 'master' and new 'main' default branch names)

Plugins defaults

Plugin recognize some common plugins and apply default values to them (but not overrides user configuration!)

maven-publish

If maven-publish plugin available, then for all defined publications pom will be extended with:

<url>${github.site}</url>
<scm>
    <url>${github.vcsUrl}</url>
    <connection>${github.scmConnection}</connection>
    <developerConnection>${github.scmConnection}</developerConnection>
</scm>
<licenses>
    <license>
        <name>${github.licenseName}</name>
        <url>%{github.licenseUrl}</url>
        <distribution>repo</distribution>
    </license>
</licenses>
<issueManagement>
    <system>GitHub</system>
    <url>${github.issues}</url>
</issueManagement>

plugin-publish

If publish-plugin plugin available, then following defaults will be applied for gradle 7.6 and above:

gradlePlugin {
    website = github.site
    vcsUrl = github.vcsUrl
}

For older gradle versions pluginBundle configured:

pluginBundle {
    website = github.site
    vcsUrl = github.vcsUrl
}

So you can avoid these properties in gradlePlugin configuration in your build file. If you manually specify any of these values it will not be overridden.

Might also like


gradle plugin generator