diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d5221b..3c5e7f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +3.1.0 / 2015-10-15 +================== + +* Update ivy status on publish + * `devSnapshot` and `snapshot` will leave status at integration + * `candidate` will set ivy status to candidate + * `final` will set ivy status to release +* Also depend on artifactory tasks if creating devSnapshot + 3.0.2 / 2015-09-18 ================== diff --git a/README.md b/README.md index ea93fdf..8580972 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This plugin provides opinions and tasks for the release process provided by [gra # Applying the plugin plugins { - id 'nebula.nebula-release' version '3.0.2' + id 'nebula.nebula-release' version '3.1.0' } -or- @@ -19,7 +19,7 @@ This plugin provides opinions and tasks for the release process provided by [gra buildscript { repositories { jcenter() } dependencies { - classpath 'com.netflix.nebula:nebula-release-plugin:3.0.2' + classpath 'com.netflix.nebula:nebula-release-plugin:3.1.0' } } apply plugin: 'nebula.nebula-release' diff --git a/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy new file mode 100644 index 0000000..211a5a4 --- /dev/null +++ b/src/integTest/groovy/nebula/plugin/release/ReleasePluginIvyStatusIntegrationSpec.groovy @@ -0,0 +1,101 @@ +/* + * Copyright 2015 Netflix, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package nebula.plugin.release +import nebula.test.functional.ExecutionResult +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.publish.ivy.plugins.IvyPublishPlugin + +class ReleasePluginIvyStatusIntegrationSpec extends GitVersioningIntegrationSpec { + + public static final String REPO_LOCATION = 'build/ivytest' + + @Override + def setupBuild() { + buildFile << """ + ext.dryRun = true + group = 'test' + ${applyPlugin(ReleasePlugin)} + ${applyPlugin(JavaPlugin)} + ${applyPlugin(IvyPublishPlugin)} + + publishing { + repositories { + ivy { + name 'ivytest' + url '$REPO_LOCATION' + } + } + publications { + ivy(IvyPublication) { + from components.java + } + } + } + + tasks.release.dependsOn 'publishIvyPublicationToIvytestRepository' + """.stripIndent() + + settingsFile << '''\ + rootProject.name='statuscheck' + '''.stripIndent() + + git.add(patterns: ['build.gradle', '.gitignore', 'settings.gradle'] as Set) + } + + def loadIvyFileViaVersionLookup(ExecutionResult result) { + loadIvyFile(inferredVersion(result.standardOutput, 'statuscheck').toString()) + } + + def loadIvyFile(String version) { + new XmlSlurper().parse(new File(projectDir, "${REPO_LOCATION}/test/statuscheck/${version}/ivy-${version}.xml")) + } + + def 'snapshot leaves integration status'() { + when: + def result = runTasksSuccessfully('snapshot') + + then: + def xml = loadIvyFileViaVersionLookup(result) + xml.info.@status == 'integration' + } + + def 'devSnapshot leaves integration status'() { + when: + def result = runTasksSuccessfully('devSnapshot') + + then: + def xml = loadIvyFileViaVersionLookup(result) + xml.info.@status == 'integration' + } + + def 'candidate sets candidate status'() { + when: + def result = runTasksSuccessfully('candidate') + + then: + def xml = loadIvyFileViaVersionLookup(result) + xml.info.@status == 'candidate' + } + + def 'final sets release status'() { + when: + def result = runTasksSuccessfully('final') + + then: + def xml = loadIvyFileViaVersionLookup(result) + xml.info.@status == 'release' + } +} diff --git a/src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy b/src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy index 4424513..6387730 100644 --- a/src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy +++ b/src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy @@ -14,11 +14,10 @@ * limitations under the License. */ package nebula.plugin.release - import com.jfrog.bintray.gradle.BintrayUploadTask import nebula.core.ProjectType -import org.ajoberstar.gradle.git.release.base.ReleasePluginExtension import org.ajoberstar.gradle.git.release.base.BaseReleasePlugin +import org.ajoberstar.gradle.git.release.base.ReleasePluginExtension import org.ajoberstar.grgit.Grgit import org.gradle.api.GradleException import org.gradle.api.Plugin @@ -28,6 +27,8 @@ import org.gradle.api.execution.TaskExecutionGraph import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.publish.ivy.IvyPublication +import org.gradle.api.publish.ivy.plugins.IvyPublishPlugin import org.jfrog.gradle.plugin.artifactory.task.BuildInfoPublicationsTask class ReleasePlugin implements Plugin { @@ -118,8 +119,11 @@ class ReleasePlugin implements Plugin { releaseCheck.isSnapshotRelease = hasSnapshot || hasDevSnapshot || (!hasCandidate && !hasFinal) if (hasFinal) { + setupStatus('release') applyReleaseStage('final') } else if (hasCandidate) { + project.allprojects.each { it.status = 'candidate' } + setupStatus('candidate') applyReleaseStage('rc') } else if (hasSnapshot) { applyReleaseStage('SNAPSHOT') @@ -149,6 +153,16 @@ class ReleasePlugin implements Plugin { (project.hasProperty('release.travisci') && project.property('release.travisci').toBoolean()) } + void setupStatus(String status) { + project.plugins.withType(IvyPublishPlugin) { + project.publishing { + publications.withType(IvyPublication) { + descriptor.status = status + } + } + } + } + void applyReleaseStage(String stage) { final String releaseStage = 'release.stage' project.allprojects.each { it.ext.set(releaseStage, stage) } @@ -181,7 +195,7 @@ class ReleasePlugin implements Plugin { project.gradle.taskGraph.whenReady { TaskExecutionGraph graph -> task.onlyIf { - graph.hasTask(':snapshot') + graph.hasTask(':snapshot') || graph.hasTask(':devSnapshot') } } }