Skip to content

Commit

Permalink
use new plugin-publishing mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrullmann committed Nov 10, 2016
1 parent 1a28472 commit ec87d20
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 126 deletions.
134 changes: 8 additions & 126 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,137 +1,19 @@
plugins {
id 'java'
id 'groovy'
id 'maven'
id 'signing'
id 'com.jfrog.bintray' version '1.0'
id 'java-gradle-plugin'
id 'maven-publish'
id 'com.jfrog.bintray' version '1.7'
id 'com.gradle.plugin-publish' version '0.9.6'
}

if (!gradle.startParameter.taskNames.contains('release')) {
println "Not a release build, setting version to ${version}-SNAPSHOT"
version += '-SNAPSHOT'
}

repositories {
jcenter()
}


dependencies {
compile gradleApi()

testCompile ('org.spockframework:spock-core:0.7-groovy-2.0') {
exclude group: 'org.codehaus.groovy'
}
testCompile 'org.hamcrest:hamcrest-all:1.3'
}


def pomDefinition = pom {
project {
name project.friendly_name
packaging 'jar'
description project.description
url project.home_url

scm {
connection "scm:git:${project.scm_url}"
developerConnection "scm:git:${project.scm_url}"
url project.scm_url
}

licenses {
license {
name = project.license_name
url project.license_url
}
}

developers {
developer {
name 'Till Krullmann'
email '[email protected]'
}
}
}
}


task generatePom {
outputs.file "$buildDir/poms/pom.xml"
doLast {
pomDefinition.writeTo "$buildDir/poms/pom.xml"
}
}


jar {
into("META-INF/maven/$project.group/$project.name") {
from generatePom
}
}


task javadocJar(type: Jar) {
description = 'Assembles a jar archive containing the javadocs.'
classifier = 'javadoc'
from javadoc
}


task sourcesJar(type: Jar) {
description = 'Assembles a jar archive containing the sources.'
classifier = 'sources'
from sourceSets.main.allSource
}


artifacts {
archives javadocJar, sourcesJar
}


signing {
sign configurations.archives
}


install {
repositories.mavenInstaller {
beforeDeployment { deployment -> signing.signPom(deployment) }
pom = pomDefinition
testCompile('org.spockframework:spock-core:1.0-groovy-2.4') {
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
}
testCompile 'org.hamcrest:java-hamcrest:2.0.0.0'
}


bintray {
user = bintray_user
key = bintray_key
configurations = ['archives']

pkg {
repo = project.bintray_repo
name = project.name
desc = project.description
websiteUrl = project.home_url
licenses = ['MIT']
labels = ['gradle', 'plugin', 'test', 'testset']

vcsUrl = project.scm_url
issueTrackerUrl = project.issues_url
publicDownloadNumbers = true

version {
vcsTag = project.version
attributes = [
'gradle-plugin': "org.unbroken-dome.test-sets:${project.group}:${project.name}"
]
}
}
}


task release(dependsOn: ['bintrayUpload']) {
group = 'publishing'
} << {
println "Releasing $version"
}
apply from: "$rootDir/publishing.gradle"
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
group=org.unbroken-dome.gradle-plugins
version=1.3.0

plugin_id=org.unbroken-dome.test-sets
friendly_name=Gradle TestSets plugin
description=A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests). Each test set is a logical grouping of a source set, dependency configurations, and related tasks and artifacts.
home_url=https://github.com/unbroken-dome/gradle-testsets-plugin
Expand All @@ -17,4 +18,6 @@ ossrh_password=

bintray_user=
bintray_key=
bintray_labels=gradle,plugin,test,testset
bintray_repo=gradle-plugins
bintray_dryrun=false
101 changes: 101 additions & 0 deletions publishing.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
if (!gradle.startParameter.taskNames.contains('release')) {
println "Not a release build, setting version to ${project.version}-SNAPSHOT"
project.version += '-SNAPSHOT'
}


tasks.create('release') << {
println "Releasing $version"
}


project.plugins.withId('maven-publish') {

/* Add the generated pom.xml file into the JAR */
model {
tasks.jar {
into("META-INF/maven/${project.group}/${project.name}") {
from generatePomFileForMavenJavaPublication
rename 'pom-default.xml', 'pom.xml'
}
}
}

tasks.create('sourcesJar', Jar) {
description = 'Assembles a jar archive containing the sources.'
classifier = 'sources'
group = 'build'
from sourceSets.main.allSource
}

tasks.create('javadocJar', Jar) {
description = 'Assembles a jar archive containing the javadocs.'
classifier = 'javadoc'
group = 'build'
from tasks.javadoc
}

project.publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact tasks.sourcesJar
artifact tasks.javadocJar
}
}
}

plugins.withId('com.jfrog.bintray') {
bintray.publications = ['mavenJava']
}
}


project.plugins.withId('com.jfrog.bintray') {
bintray {
user = project.bintray_user
key = project.bintray_key

dryRun = Boolean.valueOf(project.bintray_dryrun as String)

pkg {
repo = project.bintray_repo
name = project.name
desc = project.description
websiteUrl = project.home_url
licenses = ['MIT']
labels = (project.bintray_labels as String).split ','

vcsUrl = project.scm_url
issueTrackerUrl = project.issues_url
publicDownloadNumbers = true
}

pkg.version {
name = project.version
released = new Date()
vcsTag = project.version
}
}

tasks['release'].dependsOn tasks.bintrayUpload
}


project.plugins.withId('com.gradle.plugin-publish') {
pluginBundle {
website = project.home_url
vcsUrl = project.scm_url
description = project.description
tags = (project.bintray_labels as String).split ','

plugins {
testSetsPlugin {
id = project.plugin_id
displayName = project.friendly_name
}
}
}

tasks['release'].dependsOn tasks.publishPlugins
}

0 comments on commit ec87d20

Please sign in to comment.