Skip to content

Commit

Permalink
Fix missing rc task (#11)
Browse files Browse the repository at this point in the history
Description
===========

With the new `Jenkins` file update from #7 we have the option to build `candidate` builds.
The `rc` task requested by the `Jenkinsfile` was missing and this patch implements it.

resolves #8

Changes
=======

![FIX] missing `rc` task for CI system
  • Loading branch information
Larusso authored Sep 18, 2018
1 parent c97286d commit bb80299
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,18 @@ class PluginsPluginIntegrationSpec extends IntegrationSpec {
"publishGroovydocs" | _
"publish" | _
}

@Unroll
def "task :#taskAlias will execute :#taskToRun"() {
when:
def result = runTasks(taskAlias, "--dry-run")

then:
result.standardOutput.contains(":${taskToRun}")
!result.standardOutput.contains(":${taskAlias}")

where:
taskAlias | taskToRun
"rc" | "candidate"
}
}
23 changes: 23 additions & 0 deletions src/main/groovy/wooga/gradle/plugins/PluginsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PluginsPlugin implements Plugin<Project> {
private static final String INTEGRATION_TEST_SOURCE = "src/integrationTest/groovy"
static final String DOC_EXPORT_DIR = "docs/api"
static final String PUBLISH_GROOVY_DOCS_TASK_NAME = "publishGroovydocs"
static final String RC_TASK = "rc"


@Override
Expand All @@ -88,6 +89,8 @@ class PluginsPlugin implements Plugin<Project> {
apply(MavenPublishPlugin)
}

applyRCtoCandidateAlias(project)

Task integrationTestTask = setupIntegrationTestTask(project, project.tasks)
Task testTask = project.tasks.getByName(JavaPlugin.TEST_TASK_NAME)

Expand Down Expand Up @@ -301,4 +304,24 @@ class PluginsPlugin implements Plugin<Project> {

javaConvention.getSourceSets().getByName("integrationTest")
}

/**
* The {@code 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
* {@code rc} instead of {@code candidate}. All other resources are named with the
* pattern (final, rc and snapshot). I used a custom task with the name {@code rc} which depends on
* {@code candidate} but this will fall through the error check in {@code NebularRelease}. So instead we
* now change the cli tasklist on the fly. If we find the {@code rc} taskname in the cli tasklist we remove it
* and add {@code candidate} instead.
* @param project
* @return
*/
static void applyRCtoCandidateAlias(Project project) {
List<String> cliTasks = project.rootProject.gradle.startParameter.taskNames
if (cliTasks.contains(RC_TASK)) {
cliTasks.remove(RC_TASK)
cliTasks.add(ReleasePlugin.CANDIDATE_TASK_NAME)
project.rootProject.gradle.startParameter.setTaskNames(cliTasks)
}
}
}

0 comments on commit bb80299

Please sign in to comment.