Skip to content

Commit

Permalink
Add a convention for the autoActivate property, deprecate the older n…
Browse files Browse the repository at this point in the history
…ame (#170)
  • Loading branch information
Azurelol committed Dec 15, 2022
1 parent 3596c0b commit 24f3832
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
build/
.idea/
out/
bin/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class UnityPluginIntegrationSpec extends UnityIntegrationSpec {
}

@UnityPluginTestOptions(unityPath = UnityPathResolution.None, addPluginTestDefaults = false,
disableAutoActivateAndLicense = false)
disableAutoActivateAndLicense = false)
@Unroll
def "extension property :#property returns '#testValue' if #reason"() {
given: "an applied plugin"
Expand Down Expand Up @@ -184,6 +184,9 @@ class UnityPluginIntegrationSpec extends UnityIntegrationSpec {

"defaultBuildTarget" | _ | _ | null | _ | PropertyLocation.none
"autoActivateUnity" | _ | _ | true | Boolean | PropertyLocation.none
"autoActivate" | _ | _ | true | Boolean | PropertyLocation.none
"autoActivate" | _ | false | false | Boolean | PropertyLocation.property
"autoActivate" | _ | false | false | Boolean | PropertyLocation.environment
"autoReturnLicense" | _ | _ | true | Boolean | PropertyLocation.none
"logCategory" | _ | _ | "unity" | "Property<String>" | PropertyLocation.none
"batchModeForEditModeTest" | _ | _ | true | Boolean | PropertyLocation.none
Expand Down Expand Up @@ -360,8 +363,8 @@ class UnityPluginIntegrationSpec extends UnityIntegrationSpec {

then:
shouldRun ?
result.wasExecuted("addUPMPackages") :
result.standardOutput.contains("Task :addUPMPackages SKIPPED")
result.wasExecuted("addUPMPackages") :
result.standardOutput.contains("Task :addUPMPackages SKIPPED")

where:
testCoverageEnabled | packagesToInstall | shouldRun
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/wooga/gradle/unity/UnityPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class UnityPlugin implements Plugin<Project> {
extension.reportsDir.convention(project.layout.buildDirectory.dir(project.provider({ reportingExtension.file("unity").path })))

extension.licenseDirectory.convention(project.layout.buildDirectory.dir(project.provider({ UnityPluginConventions.licenseDirectory.path })))
extension.autoActivateUnity.convention(true)
extension.autoReturnLicense.convention(extension.autoActivateUnity)
extension.autoActivate.convention(UnityPluginConventions.autoActivate.getBooleanValueProvider(project))
extension.autoReturnLicense.convention(extension.autoActivate)

extension.unityPath.convention(UnityPluginConventions.unityPath.getFileValueProvider(project))

Expand Down
13 changes: 9 additions & 4 deletions src/main/groovy/wooga/gradle/unity/UnityPluginConventions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class UnityPluginConventions {
/**
* The path to the Unity Editor executable
*/
static final PropertyLookup unityPath = new PropertyLookup(["UNITY_UNITY_PATH", "UNITY_PATH"], "unity.unityPath", { getPlatformUnityPath().absolutePath }) /**
static final PropertyLookup unityPath = new PropertyLookup(["UNITY_UNITY_PATH", "UNITY_PATH"], "unity.unityPath", { getPlatformUnityPath().absolutePath })

/**
* Used for authentication with Unity's servers
*/
Expand All @@ -86,9 +87,9 @@ class UnityPluginConventions {
* Used for authentication with Unity's servers
*/
static final PropertyLookup serial = new PropertyLookup("UNITY_AUTHENTICATION_SERIAL", "unity.authentication.serial", null)

/**
* Used in specifying the directory where unity logs are written to
*
* @environmentVariable "XCODEBUILD_LOGS_DIR"
* @propertyName "xcodebuild.logsDir"
* @defaultValue "logs"
Expand Down Expand Up @@ -121,7 +122,11 @@ class UnityPluginConventions {
/**
* Test filtering
*/
static final PropertyLookup testFilter = new PropertyLookup("UNITY_TEST_FILTER", "unity.testFilter", null)
static final PropertyLookup testFilter = new PropertyLookup("UNITY_TEST_FILTER", "unity.testFilter", null)
/**
* Automatic unity activation (get/return license)
*/
static final PropertyLookup autoActivate = new PropertyLookup("UNITY_AUTO_ACTIVATE", "unity.autoActivate", true)

/**
* The path to the Unity license directory
Expand Down Expand Up @@ -163,7 +168,7 @@ class UnityPluginConventions {

static UnityFileTree getUnityFileTree(File unityExec) {
return UnityFileTree.fromUnityExecutable(unityExec)
}
}

}

Expand Down
35 changes: 25 additions & 10 deletions src/main/groovy/wooga/gradle/unity/UnityPluginExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ trait UnityPluginExtension implements UnitySpec,
autoReturnLicense
}

final Provider<Boolean> shouldReturnLicense = providerFactory.provider({ getAutoActivateUnity().get() && getAutoReturnLicense().get() })
final Provider<Boolean> shouldReturnLicense = providerFactory.provider({ getAutoActivate().get() && getAutoReturnLicense().get() })

void setAutoReturnLicense(Provider<Boolean> value) {
autoReturnLicense.set(value)
Expand All @@ -144,24 +144,37 @@ trait UnityPluginExtension implements UnitySpec,
autoReturnLicense.set(value)
}

private final Property<Boolean> autoActivateUnity = objects.property(Boolean)

/**
* @return Whether a task to activate the Unity license should be executed before any task of type {@code UnityTask}
*/
@Deprecated
Property<Boolean> getAutoActivateUnity() {
autoActivateUnity
autoActivate
}

@Deprecated
void setAutoActivateUnity(Boolean value) {
autoActivateUnity.set(value)
setAutoActivate(value)
}

@Deprecated
void setAutoActivateUnity(Provider<Boolean> value) {
autoActivateUnity.set(value)
setAutoActivate(value)
}

private Property<String> defaultBuildTarget = objects.property(String)
/**
* @return Whether a task to activate the Unity license should be executed before any task of type {@code UnityTask}
*/
Property<Boolean> getAutoActivate() {
autoActivate
}

private final Property<Boolean> autoActivate = objects.property(Boolean)

void setAutoActivate(Provider<Boolean> value) {
autoActivate.set(value)
}

void setAutoActivate(Boolean value) {
autoActivate.set(value)
}

/**
* @return If assigned, what the build target will be assigned to by convention
Expand All @@ -170,6 +183,8 @@ trait UnityPluginExtension implements UnitySpec,
defaultBuildTarget
}

private Property<String> defaultBuildTarget = objects.property(String)

void setDefaultBuildTarget(Provider<String> value) {
defaultBuildTarget.set(value)
}
Expand Down

0 comments on commit 24f3832

Please sign in to comment.