From fb318d389fbeb8060de4fbad1a2b9d54507db62c Mon Sep 17 00:00:00 2001 From: Manfred Endres <2523575+Larusso@users.noreply.github.com> Date: Tue, 19 May 2020 10:11:55 +0200 Subject: [PATCH] Improve ArchiveTask provide optional team id (#56) Description =========== During archive and the resulting code sign, it can happen that Xcode has issues with ambigious certificate names. It is possible to provide a `DEVELOPMENT_TEAM` flag during invocation and providing the teamId for code sign. This patch adds a new optional task input variable `teamId` to the `Archive` task and sets the `DEVELOPMENT_TEAM` option during execution if the property is set. The plugin will provide a default value from the plugin extension. Changes ======= * ![IMPROVE] ![IOS] `ArchiveTask` provide optional team id --- .../build/unity/ios/IOSBuildPlugin.groovy | 1 + .../unity/ios/tasks/XCodeArchiveTask.groovy | 37 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy b/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy index 9b79ecc5..41a6e6d2 100644 --- a/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy +++ b/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy @@ -69,6 +69,7 @@ class IOSBuildPlugin implements Plugin { conventionMapping.map("extension", { "xcarchive" }) conventionMapping.map("scheme", { extension.getScheme() }) conventionMapping.map("configuration", { extension.getConfiguration() }) + conventionMapping.map("teamId", { extension.getTeamId() }) } }) diff --git a/src/main/groovy/wooga/gradle/build/unity/ios/tasks/XCodeArchiveTask.groovy b/src/main/groovy/wooga/gradle/build/unity/ios/tasks/XCodeArchiveTask.groovy index 7aa7b8eb..db0e6378 100644 --- a/src/main/groovy/wooga/gradle/build/unity/ios/tasks/XCodeArchiveTask.groovy +++ b/src/main/groovy/wooga/gradle/build/unity/ios/tasks/XCodeArchiveTask.groovy @@ -23,6 +23,8 @@ import org.gradle.api.tasks.* import org.gradle.util.GUtil import wooga.gradle.build.unity.ios.XCAction +import java.util.concurrent.Callable + class XCodeArchiveTask extends ConventionTask { private Object projectPath @@ -152,6 +154,23 @@ class XCodeArchiveTask extends ConventionTask { this } + private Object teamId + + @Optional + @Input + String getTeamId() { + convertToString(teamId) + } + + void setTeamId(Object value) { + teamId = value + } + + ImportProvisioningProfile teamId(Object teamId) { + setTeamId(teamId) + this + } + @Internal("Represented as part of archivePath") String getArchiveName() { if (customName != null) { @@ -299,6 +318,10 @@ class XCodeArchiveTask extends ConventionTask { arguments << "OTHER_CODE_SIGN_FLAGS=--keychain ${getBuildKeychain()}" } + if (getTeamId()) { + arguments << "DEVELOPMENT_TEAM=${getTeamId()}" + } + arguments << "-archivePath" << getArchivePath().getPath() def derivedDataPath = new File(project.buildDir, "derivedData") @@ -311,4 +334,16 @@ class XCodeArchiveTask extends ConventionTask { args = arguments } } -} \ No newline at end of file + + private static String convertToString(Object value) { + if (!value) { + return null + } + + if (value instanceof Callable) { + value = ((Callable) value).call() + } + + value.toString() + } +}