diff --git a/build.gradle b/build.gradle index 9d7f4b3..e5e4c09 100644 --- a/build.gradle +++ b/build.gradle @@ -51,9 +51,12 @@ cveHandler { dependencies { api 'net.wooga.gradle:macos-security:[2,3[' api 'net.wooga.gradle:xcodebuild:[2,3[' + api 'net.wooga.gradle:fastlane:[2,3[' implementation "com.googlecode.plist:dd-plist:1.23" - integrationTestImplementation'com.wooga.spock.extensions:spock-macos-keychain-extension:[1,2[' implementation 'com.wooga.gradle:gradle-commons:[1,2[' + implementation 'net.wooga.gradle:asdf:[1,2[' + + integrationTestImplementation'com.wooga.spock.extensions:spock-macos-keychain-extension:[1,2[' testImplementation 'com.wooga.gradle:gradle-commons-test:[1,2[' } diff --git a/src/integrationTest/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginIntegrationSpec.groovy b/src/integrationTest/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginIntegrationSpec.groovy index 0fb2107..f7f29ed 100644 --- a/src/integrationTest/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginIntegrationSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginIntegrationSpec.groovy @@ -17,10 +17,11 @@ package wooga.gradle.build.unity.ios - +import com.wooga.gradle.PlatformUtils import com.wooga.gradle.test.ConventionSource import com.wooga.gradle.test.PropertyLocation import com.wooga.gradle.test.PropertyQueryTaskWriter +import com.wooga.gradle.test.queries.PropertyQuery import com.wooga.gradle.test.queries.TestValue import com.wooga.gradle.test.writers.PropertyGetterTaskWriter import com.wooga.gradle.test.writers.PropertySetterWriter @@ -28,6 +29,8 @@ import com.wooga.security.Domain import com.wooga.security.MacOsKeychainSearchList import nebula.test.functional.ExecutionResult import net.wooga.system.ProcessList +import org.gradle.process.ExecSpec +import spock.lang.IgnoreIf import spock.lang.Requires import spock.lang.Shared import spock.lang.Timeout @@ -39,6 +42,8 @@ import wooga.gradle.xcodebuild.config.ExportOptions import wooga.gradle.xcodebuild.tasks.ExportArchive import wooga.gradle.xcodebuild.tasks.XcodeArchive +import java.nio.file.Paths + import static com.wooga.gradle.PlatformUtils.escapedPath import static com.wooga.gradle.test.queries.TestValue.projectFile import static com.wooga.gradle.test.writers.PropertySetInvocation.* @@ -585,10 +590,10 @@ class IOSBuildPluginIntegrationSpec extends IOSBuildIntegrationSpec { set = new PropertySetterWriter(extensionName, property) - .serialize(wrapValueFallback) - .set(rawValue, type) - .to(location) - .use(invocation) + .serialize(wrapValueFallback) + .set(rawValue, type) + .to(location) + .use(invocation) get = new PropertyGetterTaskWriter(set) } @@ -753,4 +758,30 @@ class IOSBuildPluginIntegrationSpec extends IOSBuildIntegrationSpec { then: query.matches(result, "a prefixed initial value with a value appended") } + + /** + * With cocoapods now meant to be installed by default + */ + def "installs cocoapods with repo-art command"() { + when: + def result = runTasks(taskName) + + then: "pod should be installed in bin directory" + println result.standardError + stubs.each { + def binary = new File(projectDir, "${stubsDir}/${it}") + assert binary.exists() + assert binary.canExecute() + } + + and: "'pod' executable should have 'repo-art' subcommand" + def podsExec = Paths.get(projectDir.absolutePath, stubsDir, "pod").toFile() + def podResult = "$podsExec.absolutePath repo-art".execute() + podResult.waitFor() == 0 + + where: + stubs = ["pod"] + stubsDir = "bin" + taskName = "podInstall" + } } 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 f4e341f..d950b75 100644 --- a/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy +++ b/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy @@ -30,6 +30,10 @@ import org.gradle.api.plugins.BasePlugin import org.gradle.api.publish.plugins.PublishingPlugin import org.gradle.api.tasks.Sync import org.gradle.api.tasks.TaskProvider +import wooga.gradle.asdf.AsdfPlugin +import wooga.gradle.asdf.AsdfPluginExtension +import wooga.gradle.asdf.ruby.RubyPlugin +import wooga.gradle.asdf.ruby.RubyPluginExtension import wooga.gradle.build.unity.ios.internal.DefaultIOSBuildPluginExtension import wooga.gradle.build.unity.ios.tasks.ImportCodeSigningIdentities import wooga.gradle.build.unity.ios.tasks.InstallProvisionProfiles @@ -58,6 +62,8 @@ class IOSBuildPlugin implements Plugin { project.pluginManager.apply(FastlanePlugin.class) project.pluginManager.apply(PublishingPlugin.class) + applyAsdfPlugin(project) + def extension = project.getExtensions().create(IOSBuildPluginExtension, EXTENSION_NAME, DefaultIOSBuildPluginExtension.class) def fastlaneExtension = project.getExtensions().getByType(FastlanePluginExtension) @@ -388,4 +394,34 @@ class IOSBuildPlugin implements Plugin { archiveDSYM.configure({ it.mustRunAfter(xcodeExport) }) tasks.named(BasePlugin.ASSEMBLE_TASK_NAME).configure({ it.dependsOn(xcodeExport, archiveDSYM, collectOutputs) }) } + + /*** + * Applies the asdf plugin, which manages the installation and usage of the asdf tool which manages + * multiple language runtime versions on a per-project basis. + * (https://github.com/asdf-vm/asdf) + * @param project + */ + void applyAsdfPlugin(Project project) { + + project.pluginManager.apply(AsdfPlugin.class) + project.pluginManager.apply(RubyPlugin.class) + + def asdf = project.extensions.getByType(AsdfPluginExtension) + asdf.version.convention(IOSBuildPluginConventions.asdfVersion.getStringValueProvider(project)) + asdf.tool("ruby") + + def ruby = project.extensions.getByType(RubyPluginExtension) + ruby.gem("cocoapods") + ruby.gem("cocoapods-art") + ruby.gem("cocoapods-pod-linkage") + + def asdfGemInstallTask = project.tasks.named(RubyPlugin.RUBY_GEMS_TAK) { + dependsOn(AsdfPlugin.BIN_STUBS_TASK_NAME) + } + + project.tasks.withType(PodInstallTask).configureEach { + it.dependsOn(asdfGemInstallTask) + it.executableDirectory.set(ruby.stubsDir) + } + } } diff --git a/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginConventions.groovy b/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginConventions.groovy index e588016..ee40bc6 100644 --- a/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginConventions.groovy +++ b/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPluginConventions.groovy @@ -118,4 +118,8 @@ class IOSBuildPluginConventions { "IOS_BUILD_PROVISIONING_PROFILE_APP_ID", ["iosBuild.provisioningProfileAppId", "provisioningProfileAppId"], null) + static final PropertyLookup asdfVersion = new PropertyLookup("IOS_BUILD_ASDF_VERSION", + ["iosBuild.asdf.version"], + "0.13.1") } +