Skip to content

Commit

Permalink
Merge pull request #30 from rspieldenner/devsnapshot
Browse files Browse the repository at this point in the history
Set status in ivy publications
  • Loading branch information
rspieldenner committed Oct 23, 2015
2 parents 6e51f9e + 05b23a5 commit 69d8642
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 5 deletions.
9 changes: 9 additions & 0 deletions 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
==================

Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -11,15 +11,15 @@ 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-

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'
Expand Down
@@ -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'
}
}
20 changes: 17 additions & 3 deletions src/main/groovy/nebula/plugin/release/ReleasePlugin.groovy
Expand Up @@ -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
Expand All @@ -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<Project> {
Expand Down Expand Up @@ -118,8 +119,11 @@ class ReleasePlugin implements Plugin<Project> {
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')
Expand Down Expand Up @@ -149,6 +153,16 @@ class ReleasePlugin implements Plugin<Project> {
(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) }
Expand Down Expand Up @@ -181,7 +195,7 @@ class ReleasePlugin implements Plugin<Project> {

project.gradle.taskGraph.whenReady { TaskExecutionGraph graph ->
task.onlyIf {
graph.hasTask(':snapshot')
graph.hasTask(':snapshot') || graph.hasTask(':devSnapshot')
}
}
}
Expand Down

0 comments on commit 69d8642

Please sign in to comment.