Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Fix error messages for rc builds (#25)
Browse files Browse the repository at this point in the history
Description
===========

The `NebularRelease` plugin will provide slightly better error messages when using the official
cli tasks (final, candidate, snapshot, ...). Because of internal naming reasons it makes sense for us to use
`rc` instead of `candidate`. All other resources are named with the
pattern (final, rc and snapshot). I used a custom task with the name `rc` which depends on
`candidate` but this will fall through the error check in `NebularRelease`. So instead we
now change the cli tasklist on the fly. If we find the `rc` taskname in the cli tasklist we remove it
and add `candidate` instead.

Changes
=======

![ADD] alias from task `rc` to `candidate`
![REMOVE] custom task `rc`
![IMPROVE] error messages for `rc` builds
  • Loading branch information
Larusso authored Dec 12, 2017
1 parent 06028ba commit ef97550
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ import wooga.gradle.unity.UnityPlugin
class ReleasePluginIntegrationSpec extends IntegrationSpec {

Grgit git
File gitIgnore

def setup() {
gitIgnore = createFile('.gitignore')
gitIgnore << """
.gradle/
.gradle*/
*.gradle
""".stripIndent()

git = Grgit.init(dir: projectDir)
git.add(patterns: ['.gitignore'])
git.commit(message: 'initial commit')
git.tag.add(name: "v0.0.1")
}
Expand Down Expand Up @@ -323,4 +332,24 @@ class ReleasePluginIntegrationSpec extends IntegrationSpec {
filesToDelete.every { !it.exists() }
filesToKeep.every { it.exists() }
}

@Unroll
def "uses task: #taskA as alias to #taskB"() {
given: "a buildfile with release plugin applied"
buildFile << """
${applyPlugin(ReleasePlugin)}
""".stripIndent()

when:
def result = runTasks(taskA, "--dry-run")

then:
result.standardOutput.contains(":${taskB}")
!result.standardOutput.contains(":${taskA}")


where:
taskA | taskB
ReleasePlugin.RC_TASK | nebula.plugin.release.ReleasePlugin.CANDIDATE_TASK_NAME
}
}
24 changes: 23 additions & 1 deletion src/main/groovy/wooga/gradle/release/ReleasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ class ReleasePlugin implements Plugin<Project> {
exclude("**/*.so.meta")
}


applyRCtoCandidateAlias(project)

applyNebularRelease(project)
applyVisteg(project)
applyWoogaPlugins(project)
Expand Down Expand Up @@ -123,7 +126,6 @@ class ReleasePlugin implements Plugin<Project> {
def publishTask = tasks.getByName(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME)
GithubPublish githubPublishTask = (GithubPublish) tasks.getByName(GithubPublishPlugin.PUBLISH_TASK_NAME)
def candiateTask = tasks.getByName(nebula.plugin.release.ReleasePlugin.CANDIDATE_TASK_NAME)
def rcTask = tasks.create(name: RC_TASK, group: nebula.plugin.release.ReleasePlugin.GROUP, dependsOn: candiateTask)
if (!tasks.hasProperty(TEST_TASK)) {
def test = tasks.create(name: TEST_TASK, dependsOn: setup)
checkTask.dependsOn test
Expand Down Expand Up @@ -156,6 +158,26 @@ class ReleasePlugin implements Plugin<Project> {
configurePaketConfigurationArtifacts(project)
}

/**
* The <code>NebularRelease</code> plugin will provide slightly better error messages when using the official
* cli tasks (final, candidate, snapshot, ...). Because of internal naming reasons it makes sense for us to use
* <code>rc</code> instead of <code>candidate</code>. All other resources are named with the
* pattern (final, rc and snapshot). I used a custom task with the name <code>rc</code> which depends on
* <code>candidate</code> but this will fall through the error check in <code>NebularRelease</code>. So instead we
* now change the cli tasklist on the fly. If we find the <code>rc</code> taskname in the cli tasklist we remove it
* and add <code>candidate</code> instead.
* @param project
* @return
*/
private applyRCtoCandidateAlias(Project project) {
List<String> cliTasks = project.rootProject.gradle.startParameter.taskNames
if (cliTasks.contains(RC_TASK)) {
cliTasks.remove(RC_TASK)
cliTasks.add(nebula.plugin.release.ReleasePlugin.CANDIDATE_TASK_NAME)
project.rootProject.gradle.startParameter.setTaskNames(cliTasks)
}
}

void createReleaseNoteTasks(Grgit git) {
GithubPublish githubPublishTask = (GithubPublish) tasks.getByName(GithubPublishPlugin.PUBLISH_TASK_NAME)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class ReleasePluginSpec extends ProjectSpec {
taskName << [
ReleasePlugin.UNTIY_PACK_TASK,
ReleasePlugin.SETUP_TASK,
ReleasePlugin.RC_TASK,
ReleasePlugin.TEST_TASK
]
}
Expand Down

0 comments on commit ef97550

Please sign in to comment.