diff --git a/gradle-plugins/build.gradle b/gradle-plugins/build.gradle index a0b34e8bf1..2ea7adb464 100644 --- a/gradle-plugins/build.gradle +++ b/gradle-plugins/build.gradle @@ -21,7 +21,7 @@ apply plugin: 'net.corda.plugins.publish-utils' allprojects { version "$gradle_plugins_version" - group 'net.corda' + group 'net.corda.plugins' } subprojects { diff --git a/gradle-plugins/cordformation/build.gradle b/gradle-plugins/cordformation/build.gradle index 1a650e0bd0..26a7b9c198 100644 --- a/gradle-plugins/cordformation/build.gradle +++ b/gradle-plugins/cordformation/build.gradle @@ -1,6 +1,12 @@ apply plugin: 'groovy' -apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'maven-publish' +apply plugin: 'net.corda.plugins.publish-utils' + +description 'A small gradle plugin for adding some basic Quasar tasks and configurations to reduce build.gradle bloat.' + +repositories { + mavenCentral() +} dependencies { compile gradleApi() @@ -9,47 +15,3 @@ dependencies { compile "com.typesafe:config:1.3.0" } -repositories { - mavenCentral() -} - -publishing { - publications { - cordformation(MavenPublication) { - from components.java - groupId 'net.corda.plugins' - artifactId 'cordformation' - - artifact sourceJar - artifact javadocJar - - pom.withXml { - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - name 'cordformation' - description 'A small gradle plugin for adding some basic Quasar tasks and configurations to reduce build.gradle bloat.' - url 'https://github.com/corda/corda' - scm { - url 'https://github.com/corda/corda' - } - - licenses { - license { - name 'Apache-2.0' - url 'https://www.apache.org/licenses/LICENSE-2.0' - distribution 'repo' - } - } - - developers { - developer { - id 'R3' - name 'R3' - email 'dev@corda.net' - } - } - } - } - } - } -} diff --git a/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy b/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy index 97607ab21f..497dfb624f 100644 --- a/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy +++ b/gradle-plugins/publish-utils/src/main/groovy/net/corda/plugins/PublishTasks.groovy @@ -4,6 +4,8 @@ import org.gradle.api.* import org.gradle.api.tasks.bundling.Jar 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 /** * A utility plugin that when applied will automatically create source and javadoc publishing tasks @@ -14,7 +16,84 @@ import org.gradle.api.Project * in BintrayConfigExtension. */ class PublishTasks implements Plugin { + Project project + void apply(Project project) { + this.project = project + + createTasks() + createExtensions() + + def bintrayConfig = project.rootProject.extensions.findByName('bintrayConfig') + 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) { + apply plugin: 'com.jfrog.bintray' + } + def bintray = project.extensions.findByName("bintray") + configureBintray(bintray, bintrayConfig) + project.publishing.publications.create(project.name, MavenPublication) { + from project.components.java + groupId project.group + artifactId project.name + + artifact project.tasks.sourceJar + artifact project.tasks.javadocJar + + extendPomForMavenCentral(pom) + } + } + } + } + + // Maven central requires all of the below fields for this to be a valid POM + void extendPomForMavenCentral(MavenPom pom) { + pom.withXml { + asNode().children().last() + { + resolveStrategy = Closure.DELEGATE_FIRST + name project.name + description project.description + url 'https://github.com/corda/corda' + scm { + url 'https://github.com/corda/corda' + } + + licenses { + license { + name 'Apache-2.0' + url 'https://www.apache.org/licenses/LICENSE-2.0' + distribution 'repo' + } + } + + developers { + developer { + id 'R3' + name 'R3' + email 'dev@corda.net' + } + } + } + } + } + + void configureBintray(def bintray, def bintrayConfig) { + bintray.user = bintrayConfig.user + bintray.key = bintrayConfig.key + bintray.publications = [ project.name ] + bintray.dryRun = bintrayConfig.dryRun ?: false + bintray.pkg.repo = bintrayConfig.repo + bintray.pkg.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 + } + + void createTasks() { if(project.hasProperty('classes')) { project.task("sourceJar", type: Jar, dependsOn: project.classes) { classifier = 'sources' @@ -28,28 +107,11 @@ class PublishTasks implements Plugin { from project.javadoc.destinationDir } } + } - project.extensions.create("bintrayConfig", BintrayConfigExtension) - - def bintrayConfig = project.rootProject.extensions.findByName('bintrayConfig') - if((bintrayConfig != null) && (bintrayConfig.publications)) { - project.configure(project) { - apply plugin: 'com.jfrog.bintray' - } - def bintray = project.extensions.findByName("bintray") - println(bintrayConfig.publications.findAll { it == project.name }) - - project.logger.info("Configuring bintray for ${project.name}") - bintray.user = bintrayConfig.user - bintray.key = bintrayConfig.key - bintray.publications = bintrayConfig.publications.findAll { it == project.name } - bintray.dryRun = bintrayConfig.dryRun ?: false - bintray.pkg.repo = bintrayConfig.repo - bintray.pkg.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 + void createExtensions() { + if(project == project.rootProject) { + project.extensions.create("bintrayConfig", BintrayConfigExtension) } } } diff --git a/gradle-plugins/quasar-utils/build.gradle b/gradle-plugins/quasar-utils/build.gradle index d66ccc9034..ad4a10ecff 100644 --- a/gradle-plugins/quasar-utils/build.gradle +++ b/gradle-plugins/quasar-utils/build.gradle @@ -1,53 +1,14 @@ apply plugin: 'groovy' -apply plugin: 'net.corda.plugins.publish-utils' apply plugin: 'maven-publish' +apply plugin: 'net.corda.plugins.publish-utils' -dependencies { - compile gradleApi() - compile localGroovy() -} +description 'A small gradle plugin for adding some basic Quasar tasks and configurations to reduce build.gradle bloat.' repositories { mavenCentral() } -publishing { - publications { - "quasar-utils"(MavenPublication) { - from components.java - groupId 'net.corda.plugins' - artifactId 'quasar-utils' - - artifact sourceJar - artifact javadocJar - - pom.withXml { - asNode().children().last() + { - resolveStrategy = Closure.DELEGATE_FIRST - name 'quasar-utils' - description 'A small gradle plugin for adding some basic Quasar tasks and configurations to reduce build.gradle bloat.' - url 'https://github.com/corda/corda' - scm { - url 'https://github.com/corda/corda' - } - - licenses { - license { - name 'Apache-2.0' - url 'https://www.apache.org/licenses/LICENSE-2.0' - distribution 'repo' - } - } - - developers { - developer { - id 'R3' - name 'R3' - email 'dev@corda.net' - } - } - } - } - } - } -} +dependencies { + compile gradleApi() + compile localGroovy() +} \ No newline at end of file