Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix license directory Linux check #96

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,5 @@ dependencies {

implementation 'org.apache.maven:maven-artifact:3.8.1'
implementation "org.yaml:snakeyaml:1.28"
//implementation 'net.wooga:unity-version-manager-jni:1.+'
implementation 'net.wooga:unity-version-manager-jni:[1,2)'
//implementation 'net.wooga:unity-version-manager-jni:1.3.1'
}
24 changes: 8 additions & 16 deletions src/main/groovy/wooga/gradle/unity/UnityPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ class UnityPlugin implements Plugin<Project> {
}

activateTask.configure({ t ->
//if (extension.autoReturnLicense.get()) {
t.finalizedBy(returnLicenseTask)
//}
t.finalizedBy(returnLicenseTask)
})

// Assign authentication to ALL tasks of type Activate
Expand All @@ -306,21 +304,15 @@ class UnityPlugin implements Plugin<Project> {
// Assign license to ALL tasks of type ReturnLicense
project.tasks.withType(ReturnLicense).configureEach({ t ->
t.licenseDirectory.convention(extension.licenseDirectory)
t.onlyIf {extension.autoReturnLicense.get()}
t.onlyIf { extension.autoReturnLicense.get() }
})

//project.afterEvaluate {
project.tasks.withType(UnityTask).configureEach({ t ->
if (!Activate.isInstance(t) && !ReturnLicense.isInstance(t)) {
//if (extension.autoActivateUnity.get()) {
t.dependsOn(activateTask)
//}
project.tasks.withType(UnityTask).configureEach({ t ->
if (!Activate.isInstance(t) && !ReturnLicense.isInstance(t)) {
t.dependsOn(activateTask)
t.finalizedBy(returnLicenseTask)
}
})

//if (extension.autoReturnLicense.get()) {
t.finalizedBy(returnLicenseTask)
//}
}
})
//}
}
}
18 changes: 14 additions & 4 deletions src/main/groovy/wooga/gradle/unity/UnityPluginConventions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package wooga.gradle.unity

import wooga.gradle.unity.utils.PlatformUtils
import wooga.gradle.unity.utils.PlatformUtilsImpl
import wooga.gradle.unity.utils.PropertyLookup

Expand Down Expand Up @@ -53,7 +54,13 @@ class UnityPluginConventions implements PlatformUtilsImpl {
static File UNITY_LICENSE_DIRECTORY_MAC_OS = new File("/Library/Application Support/Unity/")

/**
* {@code File} to Unity license directory on windows.
* {@code File} to Unity license directory on Linux.
* @value "/Library/Application Support/Unity/"
*/
static File UNITY_LICENSE_DIRECTORY_LINUX = new File("${PlatformUtils.unixUserHomePath}/share/unity3d/Unity/")

/**
* {@code File} to Unity license directory on Windows.
* @value "C:\ProgramData\Unity"
*/
static File UNITY_LICENSE_DIRECTORY_WIN = new File("C:\\ProgramData\\Unity")
Expand All @@ -66,7 +73,7 @@ class UnityPluginConventions implements PlatformUtilsImpl {
/**
* 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 Down Expand Up @@ -112,12 +119,15 @@ class UnityPluginConventions implements PlatformUtilsImpl {
* The path to the Unity license directory
*/
static File getLicenseDirectory() {
File licensePath = null
File licensePath

if (isWindows()) {
licensePath = UnityPluginConventions.UNITY_LICENSE_DIRECTORY_WIN
} else if (osName().contains("mac os x")) {
} else if (isMac()) {
licensePath = UnityPluginConventions.UNITY_LICENSE_DIRECTORY_MAC_OS
} else {
licensePath = UnityPluginConventions.UNITY_LICENSE_DIRECTORY_LINUX

}

licensePath
Expand Down
8 changes: 8 additions & 0 deletions src/main/groovy/wooga/gradle/unity/utils/PlatformUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ trait PlatformUtilsImpl {
}
path
}

/**
* Returns the pat to the usr directory in UNIX
* @return
*/
static String getUnixUserHomePath() {
System.getProperty("user.home")
}
}

class PlatformUtils implements PlatformUtilsImpl {
Expand Down