-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add task to set the project package resolution strategy
- Add generic task to modify the project manifest file - Add plugin task to ensure there's a package manifest
- Loading branch information
Showing
18 changed files
with
518 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ationTest/groovy/wooga/gradle/unity/tasks/SetResolutionStrategyTaskIntegrationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package wooga.gradle.unity.tasks | ||
|
||
import com.wooga.spock.extensions.unity.UnityPluginTestOptions | ||
import groovy.json.JsonOutput | ||
import groovy.json.JsonSlurper | ||
import spock.lang.Unroll | ||
import wooga.gradle.unity.UnityIntegrationSpec | ||
import wooga.gradle.unity.UnityPluginTest | ||
import wooga.gradle.unity.UnityTaskIntegrationSpec | ||
|
||
class SetResolutionStrategyTaskIntegrationSpec extends UnityIntegrationSpec { | ||
|
||
@Override | ||
String getSubjectUnderTestTypeName() { | ||
SetResolutionStrategy.class.name | ||
} | ||
|
||
@UnityPluginTestOptions(forceMockTaskRun = false) | ||
def "skips when the resolution strategy is not set"() { | ||
|
||
when: | ||
def result = runTasks(subjectUnderTestName) | ||
|
||
then: | ||
result.wasSkipped(subjectUnderTestName) | ||
} | ||
|
||
@UnityPluginTestOptions(forceMockTaskRun = false) | ||
@Unroll | ||
def "#verb the resolution strategy #strategy"() { | ||
|
||
given: "an unity project with the manifest file set" | ||
def manifestPath = "build/test_project/Packages/manifest.json" | ||
def manifestFile = new File(projectDir, manifestPath) | ||
manifestFile.parentFile.mkdirs() | ||
manifestFile.createNewFile() | ||
|
||
and: "an existing manifest file" | ||
def packages = ["com.unity.ugui": "1.0.0"] | ||
|
||
Map<String, Object> manifestContents = [ | ||
"dependencies": packages | ||
] | ||
if (originalStrategy != _) { | ||
manifestContents["resolutionStrategy"] = originalStrategy | ||
} | ||
manifestFile << JsonOutput.toJson(manifestContents) | ||
|
||
and: "task configuration" | ||
appendToSubjectTask(""" | ||
resolutionStrategy = ${wrapValueBasedOnType(strategy, String)} | ||
projectManifestFile = ${wrapValueBasedOnType(manifestPath, File)} | ||
""".stripIndent() | ||
) | ||
|
||
when: | ||
runTasksSuccessfully(subjectUnderTestName) | ||
|
||
then: "manifest file contains resolution strategy" | ||
def actual = new JsonSlurper().parse(manifestFile)["resolutionStrategy"] | ||
actual == strategy | ||
|
||
where: | ||
originalStrategy | strategy | ||
"katzen" | "highestMinor" | ||
_ | "highestMinor" | ||
_ | "lowest" | ||
"highest" | "highestPatch" | ||
|
||
verb = originalStrategy != _ ? "overrides" : "sets" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.