Bintray configuration block now contains all fields required for the bare minimum POM.

This commit is contained in:
Clinton Alexander 2016-12-06 10:05:02 +00:00
parent 6ac7b9384d
commit 4b2d786724
5 changed files with 66 additions and 14 deletions
gradle-plugins

View File

@ -34,9 +34,21 @@ bintrayConfig {
repo = 'corda'
org = 'r3'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/corda/corda'
projectUrl = 'https://github.com/corda/corda'
gpgSign = true
gpgPassphrase = System.getenv('CORDA_BINTRAY_GPG_PASSPHRASE')
publications = ['cordformation', 'quasar-utils']
license {
name = 'Apache-2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0'
distribution = 'repo'
}
developer {
id = 'R3'
name = 'R3'
email = 'dev@corda.net'
}
}
// Aliasing the publishToMavenLocal for simplicity.

View File

@ -6,6 +6,7 @@ import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.MavenPom
import net.corda.plugins.bintray.*
/**
* A utility plugin that when applied will automatically create source and javadoc publishing tasks
@ -24,10 +25,9 @@ class PublishTasks implements Plugin<Project> {
createTasks()
createExtensions()
def bintrayConfig = project.rootProject.extensions.findByName('bintrayConfig')
def bintrayConfig = project.rootProject.extensions.findByType(BintrayConfigExtension.class)
if((bintrayConfig != null) && (bintrayConfig.publications)) {
def publications = bintrayConfig.publications.findAll { it == project.name }
println("HI")
if(publications.size > 0) {
project.logger.info("Configuring bintray for ${project.name}")
project.configure(project) {
@ -43,44 +43,44 @@ class PublishTasks implements Plugin<Project> {
artifact project.tasks.sourceJar
artifact project.tasks.javadocJar
extendPomForMavenCentral(pom)
extendPomForMavenCentral(pom, bintrayConfig)
}
}
}
}
// Maven central requires all of the below fields for this to be a valid POM
void extendPomForMavenCentral(MavenPom pom) {
void extendPomForMavenCentral(MavenPom pom, BintrayConfigExtension config) {
pom.withXml {
asNode().children().last() + {
resolveStrategy = Closure.DELEGATE_FIRST
name project.name
description project.description
url 'https://github.com/corda/corda'
url config.projectUrl
scm {
url 'https://github.com/corda/corda'
url config.vcsUrl
}
licenses {
license {
name 'Apache-2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0'
distribution 'repo'
name config.license.name
url config.license.url
distribution config.license.url
}
}
developers {
developer {
id 'R3'
name 'R3'
email 'dev@corda.net'
id config.developer.id
name config.developer.name
email config.developer.email
}
}
}
}
}
void configureBintray(def bintray, def bintrayConfig) {
void configureBintray(def bintray, BintrayConfigExtension bintrayConfig) {
bintray.user = bintrayConfig.user
bintray.key = bintrayConfig.key
bintray.publications = [ project.name ]

View File

@ -1,4 +1,6 @@
package net.corda.plugins
package net.corda.plugins.bintray
import org.gradle.util.ConfigureUtil
class BintrayConfigExtension {
/**
@ -29,6 +31,14 @@ class BintrayConfigExtension {
* The passphrase for the key used to sign releases.
*/
String gpgPassphrase
/**
* VCS URL
*/
String vcsUrl
/**
* Project URL
*/
String projectUrl
/**
* The publications that will be uploaded as a part of this configuration. These must match both the name on
* bintray and the gradle module name. ie; it must be "some-package" as a gradle sub-module (root project not
@ -41,4 +51,20 @@ class BintrayConfigExtension {
* Whether to test the publication without uploading to bintray.
*/
Boolean dryRun
/**
* The license this project will use (currently limited to one)
*/
License license = new License()
/**
* The developer of this project (currently limited to one)
*/
Developer developer = new Developer()
void license(Closure closure) {
ConfigureUtil.configure(closure, license)
}
void developer(Closure closure) {
ConfigureUtil.configure(closure, developer)
}
}

View File

@ -0,0 +1,7 @@
package net.corda.plugins.bintray
class Developer {
String id
String name
String email
}

View File

@ -0,0 +1,7 @@
package net.corda.plugins.bintray
class License {
String name
String url
String distribution
}