Skip to content

Commit

Permalink
Release plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Ryan committed Aug 22, 2012
1 parent a85e196 commit 8f289b7
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 24 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Establish version and status
ext.releaseVersion = '1.1.3' // TEMPLATE: Set to latest release
ext.githubProjectName = rootProject.name // TEMPLATE: change to match github project, if it doesn't match project name
ext.githubProjectName = rootProject.name // Change if github project name is not the same as the root project's name

buildscript {
repositories { mavenCentral() }
Expand All @@ -11,11 +10,11 @@ allprojects {
repositories { mavenCentral() }
}

//apply from: file('gradle/release.gradle') // Not fully tested
apply from: file('gradle/convention.gradle')
apply from: file('gradle/maven.gradle')
apply from: file('gradle/check.gradle')
apply from: file('gradle/license.gradle')
apply from: file('gradle/release.gradle')

subprojects {
// Closure to configure all the POM with extra info, common to all projects
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=1.4-SNAPSHOT
7 changes: 7 additions & 0 deletions gradle/buildscript.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// Executed in context of buildscript
repositories {
ivy {
name = 'gradle_release'
artifactPattern 'http://launchpad.net/[organization]/trunk/[revision]/+download/[artifact]-[revision].jar'
}
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.0'
classpath 'com.mapvine:gradle-cobertura-plugin:0.1'
classpath 'gradle-release:gradle-release:1.0pre'
}
11 changes: 4 additions & 7 deletions gradle/convention.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@

ext.performingRelease = project.hasProperty('release') && Boolean.parseBoolean(project.release)
def versionPostfix = performingRelease?'':'-SNAPSHOT'
version = "${releaseVersion}${versionPostfix}"
status = performingRelease?'release':'snapshot'
// For Artifactory
rootProject.status = version.contains('-SNAPSHOT')?'snapshot':'release'

subprojects
{
subprojects { project ->
apply plugin: 'java' // Plugin as major conventions

version = rootProject.version

sourceCompatibility = 1.6

// GRADLE-2087 workaround, perform after java plugin
status = rootProject.status
status = version.contains('-SNAPSHOT')?'snapshot':'release'

task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
Expand Down
15 changes: 4 additions & 11 deletions gradle/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@ subprojects {
apply plugin: 'maven' // Java plugin has to have been already applied for the conf2scope mappings to work
apply plugin: 'signing'

if (gradle.startParameter.taskNames.contains("uploadMavenCentral")) {
signing {
required true
sign configurations.archives
}
} else {
task signArchives {
// do nothing
}
signing {
required { gradle.taskGraph.hasTask(uploadMavenCentral) }
sign configurations.archives
}

/**
* Publishing to Maven Central example provided from http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html
*/
task uploadMavenCentral(type:Upload) {
task uploadMavenCentral(type:Upload, dependsOn: signArchives) {
configuration = configurations.archives
dependsOn 'signArchives'
doFirst {
repositories.mavenDeployer {
beforeDeployment { org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment) }
Expand Down
64 changes: 61 additions & 3 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,64 @@
buildscript {
dependencies { classpath group: 'no.entitas.gradle', name: 'gradle-release-plugin', version: '1.11' }

apply plugin: 'release'

// Ignore release plugin's task because it calls out via GradleBuild. This is a good place to put an email to send out
task release(overwrite: true, dependsOn: commitNewVersion) << {
// This is a good place to put an email to send out
}
commitNewVersion.dependsOn updateVersion
updateVersion.dependsOn createReleaseTag
createReleaseTag.dependsOn preTagCommit
def buildTasks = tasks.matching { it.name =~ /:build/ }
preTagCommit.dependsOn buildTasks
preTagCommit.dependsOn checkSnapshotDependencies
//checkSnapshotDependencies.dependsOn confirmReleaseVersion // Introduced in 1.0, forces readLine
//confirmReleaseVersion.dependsOn unSnapshotVersion
checkSnapshotDependencies.dependsOn unSnapshotVersion // Remove once above is fixed
unSnapshotVersion.dependsOn checkUpdateNeeded
checkUpdateNeeded.dependsOn checkCommitNeeded
checkCommitNeeded.dependsOn initScmPlugin

// Call out to compile against internal repository
task uploadArtifactory(type: GradleBuild) {
startParameter = project.gradle.startParameter.newInstance()
startParameter.addInitScript( file('gradle/netflix-oss.gradle') )
startParameter.getExcludedTaskNames().add('check')
tasks = [ 'build', 'artifactoryPublish' ]
}

apply plugin: no.entitas.gradle.git.GitReleasePlugin // 'gitrelease'
task buildWithArtifactory(type: GradleBuild) {
startParameter = project.gradle.startParameter.newInstance()
startParameter.addInitScript( file('gradle/netflix-oss.gradle') )
startParameter.getExcludedTaskNames().add('check')
tasks = [ 'build' ]
}

// Ensure upload happens before taggging but after all pre-checks
uploadArtifactory.dependsOn checkSnapshotDependencies
createReleaseTag.dependsOn uploadArtifactory
gradle.taskGraph.whenReady { taskGraph ->
if ( taskGraph.hasTask(uploadArtifactory) && !taskGraph.hasTask(':release') ) {
throw new GradleException('"release" task has to be run before uploading to Artifactory')
}
}
subprojects.each { project ->
project.uploadMavenCentral.dependsOn rootProject.checkSnapshotDependencies
rootProject.createReleaseTag.dependsOn project.uploadMavenCentral

gradle.taskGraph.whenReady { taskGraph ->
if ( taskGraph.hasTask(project.uploadMavenCentral) && !taskGraph.hasTask(':release') ) {
throw new GradleException('"release" task has to be run before uploading to Maven Central')
}
}
}

// Prevent plugin from asking for a version number interactively
ext.'gradle.release.useAutomaticVersion' = "true"

release {
// http://tellurianring.com/wiki/gradle/release
failOnCommitNeeded=false
failOnPublishNeeded=false
failOnUnversionedFiles=false
failOnUpdateNeeded=false
}

0 comments on commit 8f289b7

Please sign in to comment.