Skip to content

Commit

Permalink
Add asdf plugin application (#16)
Browse files Browse the repository at this point in the history
* Add asdf plugin application
* Bind Asdf tasks to PodInstall task

---------

Co-authored-by: Manfred Endres <manfred.endres@wooga.net>
Co-authored-by: Joaquim Alvino de Mesquita Neto <joaquim.neto@wooga.net>
  • Loading branch information
3 people committed Sep 26, 2023
1 parent 7b0b0e6 commit f52d933
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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['
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@

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
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
Expand All @@ -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.*
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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"
}
}
36 changes: 36 additions & 0 deletions src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -58,6 +62,8 @@ class IOSBuildPlugin implements Plugin<Project> {
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)

Expand Down Expand Up @@ -388,4 +394,34 @@ class IOSBuildPlugin implements Plugin<Project> {
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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

0 comments on commit f52d933

Please sign in to comment.