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

Commit

Permalink
Root-Level Project Support + WDK-Release tasks collision fix [ATLAS-1…
Browse files Browse the repository at this point in the history
…451] (#144)

Make sure release plugin can be added after wdk-release plugin by not creating the same tasks

Use allprojects instead of subprojects for configuring unity package, since we want to support also the root-level folder structure
  • Loading branch information
pletoss authored Sep 21, 2023
1 parent 7593b9e commit c8926e4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package wooga.gradle.release

import com.wooga.gradle.test.executable.FakeExecutables
import org.ajoberstar.grgit.Grgit
import org.gradle.api.Task
import spock.lang.Ignore
import spock.lang.Unroll
import wooga.gradle.paket.get.PaketGetPlugin
Expand Down Expand Up @@ -141,6 +142,31 @@ class ReleasePluginIntegrationSpec extends com.wooga.gradle.test.IntegrationSpec
testType = range.size() > 1 ? "multiple" : "single"
}

@Unroll("verify main project unity tasks gets configured to run paketUnityInstall")
def "verify configureUnityPackageIfPresent of main project"() {
given: "a buildfile with net.wooga.wdk-unity and release plugin applied"
buildFile << """
apply plugin: 'net.wooga.wdk-unity'
${applyPlugin(ReleasePlugin)}
import wooga.gradle.unity.UnityTask
project.tasks.register('myunitytask', UnityTask) {
}
task("printdeps") {
doLast {
println "paketUnityInstall:[\${project.tasks.findByName('myunitytask').dependsOn.collect{it.name}.contains('paketUnityInstall')}]"
}
}
""".stripIndent()

when:
def result = runTasksSuccessfully("printdeps")

then:
result.standardOutput.contains("paketUnityInstall:[true]")
}

@Ignore
@Unroll("verify plugin activation with gradle #gradleVersionToTest")
def "activates with multiple gradle versions"() {
Expand Down
10 changes: 5 additions & 5 deletions src/main/groovy/wooga/gradle/release/ReleasePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ class ReleasePlugin implements Plugin<Project> {
// which was deprecated in favor of our own solution. These tasks have no action, they instead
// work by mapping the 'release.stage' property.
// For example, invoking the `final` task will have the `release.stage` property set to `final`
Task preflightTask = project.tasks.create(PREFLIGHT_TASK_NAME)
Task finalTask = project.tasks.create(FINAL_TASK_NAME)
Task rcTask = project.tasks.create(RC_TASK_NAME)
Task snapshotTask = project.tasks.create(SNAPSHOT_TASK_NAME)
Task preflightTask = project.tasks.maybeCreate(PREFLIGHT_TASK_NAME)
Task finalTask = project.tasks.maybeCreate(FINAL_TASK_NAME)
Task rcTask = project.tasks.maybeCreate(RC_TASK_NAME)
Task snapshotTask = project.tasks.maybeCreate(SNAPSHOT_TASK_NAME)

[snapshotTask, preflightTask, rcTask, finalTask].each {
it.dependsOn publishTask
Expand Down Expand Up @@ -339,7 +339,7 @@ class ReleasePlugin implements Plugin<Project> {
DependencyHandler dependencies = project.dependencies
def rootPaketUnityInstall = project.rootProject.tasks[PaketUnityPlugin.INSTALL_TASK_NAME]
def rootPaketUnwrapUPM = project.rootProject.tasks[PaketUnityPlugin.UNWRAP_UPM_TASK_NAME]
project.subprojects { Project sub ->
project.allprojects { Project sub ->
sub.pluginManager.withPlugin("net.wooga.unity", new Action<AppliedPlugin>() {
@Override
void execute(AppliedPlugin unityPlugin) {
Expand Down
21 changes: 21 additions & 0 deletions src/test/groovy/wooga/gradle/release/ReleasePluginSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.internal.tasks.TaskExecutionOutcome
import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.publish.plugins.PublishingPlugin
import org.gradle.api.specs.Spec
import org.gradle.cache.internal.VersionStrategy
import spock.lang.Ignore
Expand Down Expand Up @@ -92,6 +93,26 @@ class ReleasePluginSpec extends ProjectSpec {
"paket-unity" | PaketUnityPlugin
}

def 'Supports adding wdk-unity-release first'() {
given:
assert !project.plugins.hasPlugin(PLUGIN_NAME)
and:
project.tasks.register(ReleasePlugin.SNAPSHOT_TASK_NAME) {}
project.tasks.register(ReleasePlugin.RC_TASK_NAME) {}
project.tasks.register(ReleasePlugin.PREFLIGHT_TASK_NAME) {}
project.tasks.register(ReleasePlugin.FINAL_TASK_NAME) {}

when:
project.plugins.apply(PLUGIN_NAME)

then:
project.plugins.hasPlugin(PLUGIN_NAME)
project.tasks.findByName(ReleasePlugin.SNAPSHOT_TASK_NAME).dependsOn.collect{it.name}.contains(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME)
project.tasks.findByName(ReleasePlugin.RC_TASK_NAME).dependsOn.collect{it.name}.contains(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME)
project.tasks.findByName(ReleasePlugin.PREFLIGHT_TASK_NAME).dependsOn.collect{it.name}.contains(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME)
project.tasks.findByName(ReleasePlugin.FINAL_TASK_NAME).dependsOn.collect{it.name}.contains(PublishingPlugin.PUBLISH_LIFECYCLE_TASK_NAME)
}

def findStrategyByName(List<VersionStrategy> strategies, name) {
strategies.find { it.name == name }
}
Expand Down

0 comments on commit c8926e4

Please sign in to comment.