diff --git a/README.md b/README.md index bb049ab..02f3738 100644 --- a/README.md +++ b/README.md @@ -31,31 +31,30 @@ Development Gradle and Java Compatibility ============================= -Built with Oracle JDK7 -Tested with Oracle JDK8 +Built with OpenJDK8 | Gradle Version | Works | | :-------------: | :----: | -| < 3.0 | ![no] | -| 3.0 | ![no] | -| 3.1 | ![no] | -| 3.2 | ![no] | -| 3.3 | ![no] | -| 3.4 | ![no] | -| 3.5 | ![no] | -| 3.5.1 | ![no] | -| 4.0 | ![no] | -| 4.1 | ![no] | -| 4.2 | ![no] | -| 4.3 | ![no] | -| 4.4 | ![no] | -| 4.5 | ![no] | -| 4.6 | ![no] | -| 4.6 | ![no] | -| 4.7 | ![yes] | -| 4.8 | ![yes] | -| 4.9 | ![yes] | -| 4.10 | ![yes] | +| < 5.1 | ![no] | +| 5.1 | ![yes] | +| 5.2 | ![yes] | +| 5.3 | ![yes] | +| 5.4 | ![yes] | +| 5.5 | ![yes] | +| 5.6 | ![yes] | +| 5.6 | ![yes] | +| 6.0 | ![yes] | +| 6.1 | ![yes] | +| 6.2 | ![yes] | +| 6.3 | ![yes] | +| 6.4 | ![yes] | +| 6.5 | ![yes] | +| 6.6 | ![yes] | +| 6.6 | ![yes] | +| 6.7 | ![yes] | +| 6.8 | ![yes] | +| 6.9 | ![yes] | +| 7.0 | ![yes] | LICENSE ======= diff --git a/build.gradle b/build.gradle index c6f484a..01a6f3e 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ */ plugins { - id 'net.wooga.plugins' version '1.4.0' + id 'net.wooga.plugins' version '2.1.1' } group 'net.wooga.gradle' @@ -41,15 +41,23 @@ github { } repositories { - jcenter() - maven { url "https://dl.bintray.com/wooga/maven" } + mavenCentral() maven { url 'https://repo.gradle.org/gradle/libs-releases' } } dependencies { - compile "net.wooga:unity-version-manager-jni:1.+" - compile "gradle.plugin.net.wooga.gradle:atlas-unity:1.+" - testCompile 'net.wooga.test:unity-project-generator-rule:0.2.0' - testCompile 'com.github.stefanbirkner:system-rules:1.18.0' - testCompile "com.wooga.spock.extensions:spock-unity-version-manager-extension:0.1.0" + implementation "net.wooga:unity-version-manager-jni:(1,2]" + implementation "gradle.plugin.net.wooga.gradle:atlas-unity:(2,3]" + testImplementation 'net.wooga.test:unity-project-generator-rule:0.3.0' + testImplementation "com.wooga.spock.extensions:spock-unity-version-manager-extension:0.2.0" +} + +configurations.all { + resolutionStrategy { + force 'org.codehaus.groovy:groovy-all:2.5.12' + force 'org.codehaus.groovy:groovy-macro:2.5.12' + force 'org.codehaus.groovy:groovy-nio:2.5.12' + force 'org.codehaus.groovy:groovy-sql:2.5.12' + force 'org.codehaus.groovy:groovy-xml:2.5.12' + } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 62665a3..c3d1dc0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -20,4 +20,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip diff --git a/gradle_check_versions.sh b/gradle_check_versions.sh index 6a80c86..b26de38 100755 --- a/gradle_check_versions.sh +++ b/gradle_check_versions.sh @@ -1,14 +1,40 @@ #!/usr/bin/env bash -versions=("4.0" "4.1" "4.2" "4.3" "4.4" "4.5" "4.6" "4.7" "4.8" "4.9" "4.10") +# +# Copyright 2018-2021 Wooga GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +versions=("5.1" "5.2" "5.3" "5.4" "5.5" "5.6" "6.0" "6.1" "6.2" "6.3" "6.4" "6.5" "6.6" "6.7" "6.8") + +rm -fr build/reports for i in "${versions[@]}" do echo "test gradle version $i" + GRADLE_VERSION=$i ./gradlew test &> /dev/null + status=$? + mkdir -p "build/reports/$i" + mv build/reports/test "build/reports/$i" + if [ $status -ne 0 ]; then + echo "test error $i" + fi + GRADLE_VERSION=$i ./gradlew integrationTest &> /dev/null status=$? mkdir -p "build/reports/$i" mv build/reports/integrationTest "build/reports/$i" if [ $status -ne 0 ]; then - echo "test error $i" + echo "integrationTest error $i" fi -done \ No newline at end of file +done diff --git a/src/integrationTest/groovy/wooga/gradle/unity/version/manager/IntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/unity/version/manager/IntegrationSpec.groovy index 4c390a9..99607b7 100644 --- a/src/integrationTest/groovy/wooga/gradle/unity/version/manager/IntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/unity/version/manager/IntegrationSpec.groovy @@ -35,11 +35,11 @@ class IntegrationSpec extends nebula.test.IntegrationSpec { ProvideSystemProperty properties = new ProvideSystemProperty("ignoreDeprecations", "true") @Shared - @UnityInstallation(version="2018.4.19f1", basePath = "build/unity", cleanup = true) + @UnityInstallation(version = "2018.4.2f1", basePath = "build/unity", cleanup = false) Installation preInstalledUnity2018_4_19f1 @Shared - @UnityInstallation(version="2018.4.18f1", basePath = "build/unity", cleanup = true) + @UnityInstallation(version = "2018.4.1f1", basePath = "build/unity", cleanup = false) Installation preInstalledUnity2018_4_18f1 def setup() { @@ -49,12 +49,12 @@ class IntegrationSpec extends nebula.test.IntegrationSpec { fork = true } - environmentVariables.clear( - UnityVersionManagerConsts.UNITY_VERSION_ENV_VAR, - UnityVersionManagerConsts.UNITY_INSTALL_BASE_DIR_PATH_ENV_VAR, - UnityVersionManagerConsts.AUTO_INSTALL_UNITY_EDITOR_PATH_ENV_VAR, - UnityVersionManagerConsts.AUTO_SWITCH_UNITY_EDITOR_PATH_ENV_VAR - ) + (UnityVersionManagerConventions.unityVersion.environmentKeys + + UnityVersionManagerConventions.unityInstallBaseDir.environmentKeys + + UnityVersionManagerConventions.autoInstallUnityEditor.environmentKeys + + UnityVersionManagerConventions.autoSwitchUnityEditor.environmentKeys).each { + environmentVariables.clear(it) + } } static String escapedPath(String path) { @@ -123,7 +123,7 @@ class IntegrationSpec extends nebula.test.IntegrationSpec { static String testPath(String path) { if (isWindows()) { if (path.startsWith("/")) { - path = "C:" + path + path = "C:" + path } path = path.replace('/', '\\') diff --git a/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtensionIntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtensionIntegrationSpec.groovy index cbfaeb0..4de5af1 100644 --- a/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtensionIntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtensionIntegrationSpec.groovy @@ -163,7 +163,7 @@ class UnityVersionManagerExtensionIntegrationSpec extends IntegrationSpec { unityVersion = "${defaultProjectVersion}" } - def componentsProvider = uvm.buildRequiredUnityComponentsProvider + def componentsProvider = uvm.buildRequiredUnityComponents task(customUnityIos, type: ${Unity.name}) { buildTarget = 'ios' @@ -177,7 +177,7 @@ class UnityVersionManagerExtensionIntegrationSpec extends IntegrationSpec { buildTarget = 'webGl' } - [customUnityIos, customUnityAndroid, customUnityWebGl].each {it.deleteAllActions()} + [customUnityIos, customUnityAndroid, customUnityWebGl].each {it.actions = []} task(printComponents) { println("print during task configuration: " + componentsProvider.get().sort()) diff --git a/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UvmCheckInstalltionIntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UvmCheckInstalltionIntegrationSpec.groovy index c797b24..052e84e 100644 --- a/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UvmCheckInstalltionIntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/unity/version/manager/UvmCheckInstalltionIntegrationSpec.groovy @@ -24,7 +24,7 @@ import org.junit.Rule import spock.lang.IgnoreIf import spock.lang.Unroll import wooga.gradle.unity.UnityPlugin -import wooga.gradle.unity.batchMode.BuildTarget +import wooga.gradle.unity.models.BuildTarget import wooga.gradle.unity.tasks.Unity class UvmCheckInstalltionIntegrationSpec extends IntegrationSpec { @@ -169,7 +169,7 @@ class UvmCheckInstalltionIntegrationSpec extends IntegrationSpec { expect: def result = runTasksWithFailure("customUnity") - result.standardOutput.contains("Unable to install requested unity version ${editorVersion}") + result.standardError.contains("Unable to install requested unity version ${editorVersion}") where: editorVersion = "2030.1.0f1" diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerConsts.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerConsts.groovy deleted file mode 100644 index 3b8f1db..0000000 --- a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerConsts.groovy +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2017 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package wooga.gradle.unity.version.manager - -class UnityVersionManagerConsts { - - /** - * Gradle property name to set the default value for {@code autoSwitchUnityEditor}. - * @value "uvm.autoSwitchUnityEditor" - * @see UnityVersionManagerExtension#getAutoSwitchUnityEditor() - */ - static String AUTO_SWITCH_UNITY_EDITOR_OPTION = "uvm.autoSwitchUnityEditor" - - /** - * Environment variable name to set the default value for {@code autoSwitchUnityEditor}. - * @value "UVM_AUTO_SWITCH_UNITY_EDITOR" - * @see UnityVersionManagerExtension#getAutoSwitchUnityEditor() - */ - static String AUTO_SWITCH_UNITY_EDITOR_PATH_ENV_VAR = "UVM_AUTO_SWITCH_UNITY_EDITOR" - - /** - * Gradle property name to set the default value for {@code autoInstallUnityEditor}. - * @value "uvm.autoInstallUnityEditor" - * @see UnityVersionManagerExtension#getAutoInstallUnityEditor() - */ - static String AUTO_INSTALL_UNITY_EDITOR_OPTION = "uvm.autoInstallUnityEditor" - - /** - * Environment variable name to set the default value for {@code autoInstallUnityEditor}. - * @value "UVM_AUTO_INSTALL_UNITY_EDITOR" - * @see UnityVersionManagerExtension#getAutoInstallUnityEditor() - */ - static String AUTO_INSTALL_UNITY_EDITOR_PATH_ENV_VAR = "UVM_AUTO_INSTALL_UNITY_EDITOR" - - /** - * Gradle property name to set the default value for {@code unityInstallBaseDir}. - * @value "uvm.unityInstallBaseDir" - * @see UnityVersionManagerExtension#getUnityInstallBaseDir() - */ - static String UNITY_INSTALL_BASE_DIR_OPTION = "uvm.unityInstallBaseDir" - - /** - * Environment variable name to set the default value for {@code unityInstallBaseDir}. - * @value "UVM_UNITY_INSTALL_BASE_DIR" - * @see UnityVersionManagerExtension#getUnityInstallBaseDir() - */ - static String UNITY_INSTALL_BASE_DIR_PATH_ENV_VAR = "UVM_UNITY_INSTALL_BASE_DIR" - - /** - * Gradle property name to set the default value for {@code unityVersion}. - * @value "uvm.unityVersion" - * @see UnityVersionManagerExtension#getUnityVersion() - */ - static String UNITY_VERSION_OPTION = "uvm.unityVersion" - - /** - * Environment variable name to set the default value for {@code unityVersion}. - * @value "UVM_UNITY_VERSION" - * @see UnityVersionManagerExtension#getUnityVersion() - */ - static String UNITY_VERSION_ENV_VAR = "UVM_UNITY_VERSION" -} diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerConventions.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerConventions.groovy new file mode 100644 index 0000000..010f10c --- /dev/null +++ b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerConventions.groovy @@ -0,0 +1,47 @@ +/* + * Copyright 2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package wooga.gradle.unity.version.manager + +import wooga.gradle.unity.utils.PropertyLookup + +class UnityVersionManagerConventions { + + /** + * Gradle property/env convention to set the default value for {@code autoSwitchUnityEditor}. + * @see UnityVersionManagerExtension#getAutoSwitchUnityEditor() + */ + static final PropertyLookup autoSwitchUnityEditor = new PropertyLookup("UVM_AUTO_SWITCH_UNITY_EDITOR", "uvm.autoSwitchUnityEditor", false) + + /** + * Gradle property/env convention set the default value for {@code autoInstallUnityEditor}. + * @see UnityVersionManagerExtension#getAutoInstallUnityEditor() + */ + static final PropertyLookup autoInstallUnityEditor = new PropertyLookup("UVM_AUTO_INSTALL_UNITY_EDITOR", "uvm.autoInstallUnityEditor", false) + + /** + * Gradle property/env convention to set the default value for {@code unityInstallBaseDir}. + * @see UnityVersionManagerExtension#getUnityInstallBaseDir() + */ + static final PropertyLookup unityInstallBaseDir = new PropertyLookup("UVM_UNITY_INSTALL_BASE_DIR", "uvm.unityInstallBaseDir", null) + + /** + * Gradle property/env convention to set the default value for {@code unityVersion}. + * @see UnityVersionManagerExtension#getUnityVersion() + */ + static final PropertyLookup unityVersion = new PropertyLookup("UVM_UNITY_VERSION", "uvm.unityVersion", null) +} diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtension.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtension.groovy index cf1c81c..86ae72c 100644 --- a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtension.groovy +++ b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerExtension.groovy @@ -21,6 +21,7 @@ import net.wooga.uvm.Component import org.gradle.api.file.DirectoryProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider +import org.gradle.api.provider.SetProperty interface UnityVersionManagerExtension { @@ -77,5 +78,5 @@ interface UnityVersionManagerExtension { * @param project the gradle project * @return A provider object which resolves the required build components needed for the current build. */ - Provider> getBuildRequiredUnityComponentsProvider() + SetProperty getBuildRequiredUnityComponents() } diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerPlugin.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerPlugin.groovy index 7e85a5b..700d9de 100644 --- a/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerPlugin.groovy +++ b/src/main/groovy/wooga/gradle/unity/version/manager/UnityVersionManagerPlugin.groovy @@ -22,12 +22,17 @@ import net.wooga.uvm.UnityVersionManager import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.Transformer +import org.gradle.api.file.RegularFileProperty import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging +import org.gradle.api.provider.Provider +import org.gradle.api.provider.SetProperty import wooga.gradle.unity.UnityPlugin +import wooga.gradle.unity.UnityPluginConventions import wooga.gradle.unity.UnityPluginExtension -import wooga.gradle.unity.batchMode.BuildTarget -import wooga.gradle.unity.tasks.internal.AbstractUnityProjectTask +import wooga.gradle.unity.UnityTask +import wooga.gradle.unity.models.BuildTarget import wooga.gradle.unity.version.manager.internal.DefaultUnityVersionManagerExtension import wooga.gradle.unity.version.manager.tasks.UvmCheckInstallation import wooga.gradle.unity.version.manager.tasks.UvmInstallUnity @@ -55,143 +60,135 @@ class UnityVersionManagerPlugin implements Plugin { return } - project.tasks.create(UVM_VERSION_TASK_NAME, UvmVersion) { + project.tasks.register(UVM_VERSION_TASK_NAME, UvmVersion, { group = GROUP description = "prints the version of the unity version manager" - uvmVersion.set(extension.uvmVersion) - } + uvmVersion.convention(extension.uvmVersion) + }) - project.tasks.create(LIST_INSTALLATIONS_TASK_NAME, UvmListInstallations) { + project.tasks.register(LIST_INSTALLATIONS_TASK_NAME, UvmListInstallations, { group = GROUP description = "lists all installed unity versions" - } + }) - project.tasks.create(INSTALL_UNITY_TASK_NAME, UvmInstallUnity) { + project.tasks.register(INSTALL_UNITY_TASK_NAME, UvmInstallUnity, { group = GROUP - } + }) - project.plugins.withType(UnityPlugin, new Action() { - @Override - void execute(UnityPlugin plugin) { - setupUnityHooks(project, extension) - } + def checkUnityInstallation = project.tasks.register(CHECK_UNITY_INSTALLATION_TASK_NAME, UvmCheckInstallation, { + buildRequiredUnityComponents.set(extension.buildRequiredUnityComponents) + unityVersion.convention(extension.unityVersion) + autoSwitchUnityEditor.convention(extension.autoSwitchUnityEditor) + autoInstallUnityEditor.convention(extension.autoInstallUnityEditor) + unityInstallBaseDir.convention(extension.unityInstallBaseDir) }) - project.tasks.withType(UvmInstallUnity, new Action() { - @Override - void execute(UvmInstallUnity task) { - task.unityVersion.set(extension.unityVersion) - task.description = "installs a unity editor version and optional components" - } + project.plugins.withType(UnityPlugin).configureEach({ + + UnityPluginExtension unity = project.extensions.getByType(UnityPluginExtension) + extension.unityProjectDir.convention(unity.projectDirectory) + checkUnityInstallation.configure({ + it.unityExtension.convention(unity) + }) + + project.tasks.withType(UnityTask).configureEach({ + project.tasks[UnityPlugin.Tasks.activateUnity.toString()].mustRunAfter checkUnityInstallation + dependsOn checkUnityInstallation + }) }) - project.tasks.withType(UvmCheckInstallation, new Action() { - @Override - void execute(UvmCheckInstallation checkInstallation) { - checkInstallation.unityVersion.set(extension.unityVersion) - checkInstallation.autoSwitchUnityEditor.set(extension.autoSwitchUnityEditor) - checkInstallation.autoInstallUnityEditor.set(extension.autoInstallUnityEditor) - checkInstallation.unityInstallBaseDir.set(extension.unityInstallBaseDir) - } + project.tasks.withType(UvmInstallUnity).configureEach({ + unityVersion.convention(extension.unityVersion) + description = "installs a unity editor version and optional components" }) } protected static UnityVersionManagerExtension create_and_configure_extension(Project project) { def extension = project.extensions.create(UnityVersionManagerExtension, EXTENSION_NAME, DefaultUnityVersionManagerExtension, project) - extension.unityProjectDir.set(project.layout.projectDirectory) - extension.unityVersion.set(project.provider({ - String version = (project.properties[UnityVersionManagerConsts.UNITY_VERSION_OPTION] - ?: System.getenv()[UnityVersionManagerConsts.UNITY_VERSION_ENV_VAR]) as String - - if(!version) { - version = UnityVersionManager.detectProjectVersion(extension.unityProjectDir.get().asFile) - } - - version - })) - - extension.unityInstallBaseDir.set(project.provider({ - String path = (project.properties[UnityVersionManagerConsts.UNITY_INSTALL_BASE_DIR_OPTION] - ?: System.getenv()[UnityVersionManagerConsts.UNITY_INSTALL_BASE_DIR_PATH_ENV_VAR]) as String - if (!path) { - path = new File(project.buildDir, "unity_installations").path - } - return project.layout.projectDirectory.dir(path) - })) - - extension.autoSwitchUnityEditor.set(project.provider({ - String rawValue = (project.properties[UnityVersionManagerConsts.AUTO_SWITCH_UNITY_EDITOR_OPTION] - ?: System.getenv()[UnityVersionManagerConsts.AUTO_SWITCH_UNITY_EDITOR_PATH_ENV_VAR]) as String - - if (rawValue) { - return (rawValue == "1" || rawValue.toLowerCase() == "yes" || rawValue.toLowerCase() == "y" || rawValue.toLowerCase() == "true") - } - - false - })) - - extension.autoInstallUnityEditor.set(project.provider({ - String rawValue = (project.properties[UnityVersionManagerConsts.AUTO_INSTALL_UNITY_EDITOR_OPTION] - ?: System.getenv()[UnityVersionManagerConsts.AUTO_INSTALL_UNITY_EDITOR_PATH_ENV_VAR]) as String - - if (rawValue) { - return (rawValue == "1" || rawValue.toLowerCase() == "yes" || rawValue.toLowerCase() == "y" || rawValue.toLowerCase() == "true") - } - - false - })) - - - + extension.unityProjectDir.convention(project.layout.projectDirectory) + extension.unityVersion.convention(UnityVersionManagerConventions.unityVersion.getStringValueProvider(project).orElse(project.provider({ + UnityVersionManager.detectProjectVersion(extension.unityProjectDir.get().asFile) + }))) + + extension.unityInstallBaseDir.convention(UnityVersionManagerConventions.unityInstallBaseDir.getDirectoryValueProvider(project).orElse(project.layout.buildDirectory.dir("unity_installations"))) + extension.autoSwitchUnityEditor.convention(UnityVersionManagerConventions.autoSwitchUnityEditor.getBooleanValueProvider(project)) + extension.autoInstallUnityEditor.convention(UnityVersionManagerConventions.autoInstallUnityEditor.getBooleanValueProvider(project)) + + extension.buildRequiredUnityComponents.set(project.provider({ + project.tasks.withType(UnityTask) + .findAll({ + try { + return project.gradle.taskGraph.hasTask(it) + } catch (IllegalStateException ignored) { + logger.warn("try to filter required build components to early. Filter not applied") + } + true + }) + .collect({ + BuildTargetToComponent.buildTargetToComponent(it.buildTarget) + }) + }).flatMap(new Transformer>, List>>() { + @Override + Provider> transform(List> providers) { + project.provider({ + providers.collect { + it.getOrElse(Component.unknown) + }.findAll {it != Component.unknown } + }) + } + })) extension } - static Component buildTargetToComponent(BuildTarget buildTarget) { - Component component - switch (buildTarget) { - case BuildTarget.ios: + static Component buildTargetToComponent(BuildTarget target) { + buildTargetToComponent(target.toString()) + } + + static Component buildTargetToComponent(String target) { + Component component = Component.unknown + switch (target.toLowerCase()) { + case "android": + component = Component.android + break + case "ios": component = Component.ios break - case BuildTarget.android: - component = Component.android + case "tvos": + component = Component.tvOs break - case BuildTarget.webgl: + case "webgl": component = Component.webGl break - case BuildTarget.linux: - case BuildTarget.linux64: + case "linux": + case "linux64": + case "linuxuniversal": component = Component.linux break - case BuildTarget.win32: - case BuildTarget.win64: - if(!System.getProperty("os.name").toLowerCase().startsWith("windows")) { + case "lumin": + component = Component.lumin + break + case 'osxuniversal': + component = Component.mac + break + case "win32": + case "win64": + if (!System.getProperty("os.name").toLowerCase().startsWith("windows")) { component = Component.windows } break - default: - component = null } component } - static void setupUnityHooks(Project project, UnityVersionManagerExtension extension) { - //set the unity project dir to the configured value in UnityPluginExtension - UnityPluginExtension unity = project.extensions.getByType(UnityPluginExtension) - extension.unityProjectDir.set(project.provider({ - def projectDir = project.layout.directoryProperty() - projectDir.set(project.file(unity.projectPath)) - projectDir.get() - })) - - project.tasks.withType(AbstractUnityProjectTask, new Action() { - @Override - void execute(AbstractUnityProjectTask unityTask) { - def checkInstallation = project.tasks.maybeCreate(CHECK_UNITY_INSTALLATION_TASK_NAME, UvmCheckInstallation) - checkInstallation.unityExtension.set(unity) - checkInstallation.buildRequiredUnityComponents.set(extension.buildRequiredUnityComponentsProvider) - project.tasks[UnityPlugin.ACTIVATE_TASK_NAME].mustRunAfter checkInstallation - unityTask.dependsOn checkInstallation - } - }) + private static class BuildTargetToComponent implements Transformer { + static Provider buildTargetToComponent(Provider buildTarget) { + buildTarget.map(new BuildTargetToComponent()) + } + + @Override + Component transform(String target) { + // Android, Linux, Linux64, LinuxUniversal, Lumin, OSXUniversal, PS4, Switch, WebGL, Win, Win64, WindowsStoreApps, XboxOne, iOS, tvOS + buildTargetToComponent(target) + } } } diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/internal/DefaultUnityVersionManagerExtension.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/internal/DefaultUnityVersionManagerExtension.groovy index f1051f9..aef91ff 100644 --- a/src/main/groovy/wooga/gradle/unity/version/manager/internal/DefaultUnityVersionManagerExtension.groovy +++ b/src/main/groovy/wooga/gradle/unity/version/manager/internal/DefaultUnityVersionManagerExtension.groovy @@ -21,49 +21,28 @@ import net.wooga.uvm.Component import net.wooga.uvm.UnityVersionManager import org.gradle.api.Project import org.gradle.api.file.DirectoryProperty -import org.gradle.api.logging.Logger -import org.gradle.api.logging.Logging import org.gradle.api.provider.Property import org.gradle.api.provider.Provider -import wooga.gradle.unity.tasks.internal.AbstractUnityProjectTask +import org.gradle.api.provider.SetProperty import wooga.gradle.unity.version.manager.UnityVersionManagerExtension -import wooga.gradle.unity.version.manager.UnityVersionManagerPlugin class DefaultUnityVersionManagerExtension implements UnityVersionManagerExtension { - static Logger logger = Logging.getLogger(DefaultUnityVersionManagerExtension) - final Provider uvmVersion final Property unityVersion final DirectoryProperty unityProjectDir final Property autoSwitchUnityEditor final Property autoInstallUnityEditor final DirectoryProperty unityInstallBaseDir - final Provider> buildRequiredUnityComponentsProvider + final SetProperty buildRequiredUnityComponents DefaultUnityVersionManagerExtension(Project project) { uvmVersion = project.provider({ UnityVersionManager.uvmVersion() }) - unityProjectDir = project.layout.directoryProperty() + unityProjectDir = project.objects.directoryProperty() unityVersion = project.objects.property(String) autoSwitchUnityEditor = project.objects.property(Boolean) autoInstallUnityEditor = project.objects.property(Boolean) - unityInstallBaseDir = project.layout.directoryProperty() - buildRequiredUnityComponentsProvider = project.provider { - def tasks = project.tasks.withType(AbstractUnityProjectTask) - - tasks.findAll { - try { - return project.gradle.taskGraph.hasTask(it) - } catch (IllegalStateException ignored) { - logger.warn("try to filter required build components to early. Filter not applied") - } - true - }.collect { - UnityVersionManagerPlugin.buildTargetToComponent(it.buildTarget) - }.findAll { - it != null - }.toSet() - } - + unityInstallBaseDir = project.objects.directoryProperty() + buildRequiredUnityComponents = project.objects.setProperty(Component) } } diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmCheckInstallation.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmCheckInstallation.groovy index 86b827d..56e3505 100644 --- a/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmCheckInstallation.groovy +++ b/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmCheckInstallation.groovy @@ -22,6 +22,7 @@ import net.wooga.uvm.Installation import net.wooga.uvm.UnityVersionManager import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFileProperty import org.gradle.api.provider.Property import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input @@ -50,6 +51,7 @@ class UvmCheckInstallation extends DefaultTask { final DirectoryProperty unityInstallBaseDir @Input + @Optional final SetProperty buildRequiredUnityComponents UvmCheckInstallation() { @@ -57,7 +59,7 @@ class UvmCheckInstallation extends DefaultTask { unityExtension = project.objects.property(UnityPluginExtension) autoSwitchUnityEditor = project.objects.property(Boolean) autoInstallUnityEditor = project.objects.property(Boolean) - unityInstallBaseDir = project.layout.directoryProperty() + unityInstallBaseDir = project.objects.directoryProperty() buildRequiredUnityComponents = project.objects.setProperty(Component) } @@ -114,7 +116,7 @@ class UvmCheckInstallation extends DefaultTask { if(unityExtension.present) { logger.info("update path to unity installtion ${installation.location}") def extension = unityExtension.get() - extension.unityPath = installation.executable + extension.unityPath.set(installation.executable) } } } diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmInstallUnity.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmInstallUnity.groovy index 4ad3cc4..9714c5b 100644 --- a/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmInstallUnity.groovy +++ b/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmInstallUnity.groovy @@ -70,7 +70,7 @@ class UvmInstallUnity extends DefaultTask { UvmInstallUnity() { unityVersion = project.objects.property(String) components = project.objects.setProperty(Component) - installDestination = project.layout.directoryProperty() + installDestination = project.objects.directoryProperty() outputs.upToDateWhen(new Spec() { @Override diff --git a/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmListInstallations.groovy b/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmListInstallations.groovy index c0376e2..dd3e384 100644 --- a/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmListInstallations.groovy +++ b/src/main/groovy/wooga/gradle/unity/version/manager/tasks/UvmListInstallations.groovy @@ -61,7 +61,7 @@ class UvmListInstallations extends DefaultTask { UvmListInstallations() { super() this.outputs.upToDateWhen({ false }) - this.outputFile = project.layout.fileProperty() + this.outputFile = project.objects.fileProperty() this.outputPrintStream = project.provider({ this.outputFile.map({ new GroovyPrintStream(it.asFile) as PrintStream