Added more publish utilities for simplifying bintray configuration per project to reduced boilerplate.

This commit is contained in:
Clinton Alexander 2016-12-01 20:24:04 +00:00 committed by Clinton Alexander
parent c8e14b0ac6
commit 4eb7d3db11
7 changed files with 83 additions and 43 deletions

View File

@ -2,10 +2,11 @@
// or if you are developing these plugins. See the readme for more information.
buildscript {
ext.gradle_plugins_version = "0.6.1" // Our version: bump this on release.
ext.corda_published_version = "0.5" // Depend on our existing published publishing plugin.
ext.gradle_plugins_version = "0.6.2" // Our version: bump this on release.
ext.corda_published_version = "0.6.2" // Depend on our existing published publishing plugin.
repositories {
mavenLocal()
jcenter()
}
@ -16,6 +17,7 @@ buildscript {
}
apply plugin: 'maven-publish'
apply plugin: 'net.corda.plugins.publish-utils'
allprojects {
version "$gradle_plugins_version"
@ -26,6 +28,16 @@ subprojects {
task(install, dependsOn: 'publishToMavenLocal')
}
bintrayConfig {
user = System.getenv('CORDA_BINTRAY_USER')
key = System.getenv('CORDA_BINTRAY_KEY')
repo = 'corda'
org = 'r3'
licenses = ['Apache-2.0']
gpgSign = true
gpgPassphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE')
}
// Aliasing the publishToMavenLocal for simplicity.
task(install, dependsOn: 'publishToMavenLocal')

View File

@ -1,7 +1,6 @@
apply plugin: 'groovy'
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
dependencies {
compile gradleApi()
@ -14,24 +13,10 @@ repositories {
mavenCentral()
}
bintray {
user = System.getenv('CORDA_BINTRAY_USER')
key = System.getenv('CORDA_BINTRAY_KEY')
bintrayPublish {
name = 'cordformation'
publications = ['cordformation']
dryRun = false
pkg {
repo = 'corda'
name = 'cordformation'
userOrg = 'r3'
licenses = ['Apache-2.0']
version {
gpg {
sign = true
passphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE')
}
}
}
}
publishing {

View File

@ -0,0 +1,11 @@
package net.corda.plugins
class BintrayConfigExtension {
String user
String key
String repo
String org
String[] licenses
Boolean gpgSign
String gpgPassphrase
}

View File

@ -0,0 +1,7 @@
package net.corda.plugins
class BintrayPublishExtension {
String name
Boolean dryRun
String[] publications
}

View File

@ -7,17 +7,57 @@ import org.gradle.api.Project
/**
* A utility plugin that when applied will automatically create source and javadoc publishing tasks
* To apply this plugin you must also add 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' to your
* buildscript's classpath dependencies.
*/
class PublishTasks implements Plugin<Project> {
void apply(Project project) {
project.task("sourceJar", type: Jar, dependsOn: project.classes) {
classifier = 'sources'
from project.sourceSets.main.allSource
if(project.hasProperty('classes')) {
project.task("sourceJar", type: Jar, dependsOn: project.classes) {
classifier = 'sources'
from project.sourceSets.main.allSource
}
}
project.task("javadocJar", type: Jar, dependsOn: project.javadoc) {
classifier = 'javadoc'
from project.javadoc.destinationDir
if(project.hasProperty('javadoc')) {
project.task("javadocJar", type: Jar, dependsOn: project.javadoc) {
classifier = 'javadoc'
from project.javadoc.destinationDir
}
}
project.extensions.create("bintrayConfig", BintrayConfigExtension)
project.extensions.create("bintrayPublish", BintrayPublishExtension)
def bintrayValues = project.extensions.findByName("bintrayPublish")
def bintrayConfig = project.rootProject.extensions.findByName('bintrayConfig')
if((bintrayConfig != null) && (bintrayValues != null)) {
// TODO AM:
// Problem 1. Bootstrapping - do not want root to depend on this project
// Problem 2. This project's extension is not available here
// Problem 3. Bintray's extension is already configured after evaluation
// Possible solutions:
// name: project.name
// publications: project.name (make it a forced convention)
// dryRun: move to root.
// Problem 4: Root project therefore cannot be published
// Solution: Why use this plugin if you only have a root project?
project.configure(project) {
apply plugin: 'com.jfrog.bintray'
}
def bintray = project.extensions.findByName("bintray")
project.logger.info("Configuring bintray for ${project.name}")
bintray.user = bintrayConfig.user
bintray.key = bintrayConfig.key
bintray.publications = bintrayValues.publications
bintray.dryRun = bintrayValues.dryRun ?: false
bintray.pkg.repo = bintrayConfig.repo
bintray.pkg.name = bintrayValues.name ?: project.name
bintray.pkg.userOrg = bintrayConfig.org
bintray.pkg.licenses = bintrayConfig.licenses
bintray.pkg.version.gpg.sign = bintrayConfig.gpgSign ?: false
bintray.pkg.version.gpg.passphrase = bintrayConfig.gpgPassphrase
}
}
}

View File

@ -1,6 +1,5 @@
apply plugin: 'groovy'
apply plugin: 'net.corda.plugins.publish-utils'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'
dependencies {
@ -12,24 +11,10 @@ repositories {
mavenCentral()
}
bintray {
user = System.getenv('CORDA_BINTRAY_USER')
key = System.getenv('CORDA_BINTRAY_KEY')
bintrayPublish {
name = 'quasar-utils'
publications = ['quasarUtils']
dryRun = false
pkg {
repo = 'corda'
name = 'quasar-utils'
userOrg = 'r3'
licenses = ['Apache-2.0']
version {
gpg {
sign = true
passphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE')
}
}
}
}
publishing {

View File

@ -1,4 +1,4 @@
rootProject.name = 'corda-gradle-plugins'
include 'quasar-utils'
include 'publish-utils'
include 'quasar-utils'
include 'cordformation'