diff --git a/src/integrationTest/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTaskSpec.groovy b/src/integrationTest/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTaskSpec.groovy index 7584622..c2dfdee 100644 --- a/src/integrationTest/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTaskSpec.groovy +++ b/src/integrationTest/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTaskSpec.groovy @@ -113,22 +113,73 @@ class PodInstallTaskSpec extends CocoaPodSpec { query.matches(result, expectedValue) where: - property | method | rawValue | returnValue | type - "projectDirectory" | toProviderSet(property) | "/path/to/project" | _ | "File" - "projectDirectory" | toProviderSet(property) | "/path/to/project" | _ | "Provider" - "projectDirectory" | toSetter(property) | "/path/to/project" | _ | "File" - "projectDirectory" | toSetter(property) | "/path/to/project" | _ | "Provider" - - "xcodeProjectFileName" | toProviderSet(property) | "test.xcodeproj" | _ | "String" - "xcodeProjectFileName" | toProviderSet(property) | "test.xcodeproj" | _ | "Provider" - "xcodeProjectFileName" | toSetter(property) | "test.xcodeproj" | _ | "String" - "xcodeProjectFileName" | toSetter(property) | "test.xcodeproj" | _ | "Provider" - - "xcodeWorkspaceFileName" | toProviderSet(property) | "test.xcworkspace" | _ | "String" - "xcodeWorkspaceFileName" | toProviderSet(property) | "test.xcworkspace" | _ | "Provider" - "xcodeWorkspaceFileName" | toSetter(property) | "test.xcworkspace" | _ | "String" - "xcodeWorkspaceFileName" | toSetter(property) | "test.xcworkspace" | _ | "Provider" + property | method | rawValue | returnValue | type + "projectDirectory" | toProviderSet(property) | "/path/to/project" | _ | "File" + "projectDirectory" | toProviderSet(property) | "/path/to/project" | _ | "Provider" + "projectDirectory" | toSetter(property) | "/path/to/project" | _ | "File" + "projectDirectory" | toSetter(property) | "/path/to/project" | _ | "Provider" + + "xcodeProjectFileName" | toProviderSet(property) | "test.xcodeproj" | _ | "String" + "xcodeProjectFileName" | toProviderSet(property) | "test.xcodeproj" | _ | "Provider" + "xcodeProjectFileName" | toSetter(property) | "test.xcodeproj" | _ | "String" + "xcodeProjectFileName" | toSetter(property) | "test.xcodeproj" | _ | "Provider" + + "xcodeWorkspaceFileName" | toProviderSet(property) | "test.xcworkspace" | _ | "String" + "xcodeWorkspaceFileName" | toProviderSet(property) | "test.xcworkspace" | _ | "Provider" + "xcodeWorkspaceFileName" | toSetter(property) | "test.xcworkspace" | _ | "String" + "xcodeWorkspaceFileName" | toSetter(property) | "test.xcworkspace" | _ | "Provider" + + "artRepositories" | toProviderSet(property) | ["https://foo.bar"] | _ | "List" + "artRepositories" | toProviderSet(property) | ["https://foo.bar"] | _ | "Provider>" + "artRepositories" | toSetter(property) | ["https://foo.bar"] | _ | "List" + "artRepositories" | toSetter(property) | ["https://foo.bar"] | _ | "Provider>" value = wrapValueBasedOnType(rawValue, type, wrapValueFallback) expectedValue = returnValue == _ ? rawValue : returnValue } + + def "adds repo-art repositories when configured"() { + given: "a sample Pod file" + def podFile = createFile("Podfile") + + and: "a list of artifactory repositories configured" + appendToSubjectTask(""" + setArtRepositories(${wrapValueBasedOnType(repositories.values().toList(), "List")}) + """.stripIndent()) + + when: + def result = runTasks(taskName) + + then: + result.success + repositories.each {repoName, repoUrl -> + assert outputContains(result, "repo-art add ${repoName} ${repoUrl} --silent") + assert outputContains(result, "repo-art update ${repoName}") + } + + where: + repositories = [ + "repo1-443-foo-bar": "https://repo1/foo/bar", + "repo2-443-" : "https://repo2/", + "repo3" : "https://repo3" + ] + taskName = subjectUnderTestName + } + + def "does not call repo-art commands when artRepositories properties is empty"() { + given: "a sample Pod file" + def podFile = createFile("Podfile") + + and: "empty artRepositories" + appendToSubjectTask(""" + setArtRepositories([]) + """.stripIndent()) + + when: + def result = runTasks(subjectUnderTestName) + + then: + result.success + !outputContains(result, "repo-art add") + !outputContains(result, "repo-art update") + } } 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 95889f3..6703599 100644 --- a/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy +++ b/src/main/groovy/wooga/gradle/build/unity/ios/IOSBuildPlugin.groovy @@ -23,7 +23,10 @@ import org.gradle.api.Action import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task +import org.gradle.api.file.Directory +import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.DuplicatesStrategy +import org.gradle.api.internal.provider.Providers import org.gradle.api.logging.Logger import org.gradle.api.logging.Logging import org.gradle.api.plugins.BasePlugin diff --git a/src/main/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTask.groovy b/src/main/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTask.groovy index 76b9e95..8cdbac7 100644 --- a/src/main/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTask.groovy +++ b/src/main/groovy/wooga/gradle/build/unity/ios/tasks/PodInstallTask.groovy @@ -8,6 +8,8 @@ import org.gradle.api.DefaultTask import org.gradle.api.file.Directory import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.FileCollection +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.MapProperty import org.gradle.api.provider.Property import org.gradle.api.provider.Provider import org.gradle.api.tasks.* @@ -28,6 +30,17 @@ class PodInstallTask extends DefaultTask implements ExecSpec, LogFileSpec, Proce projectDirectory.set(value) } + private final ListProperty artRepositories = project.objects.listProperty(String) + + @Input + ListProperty getArtRepositories() { + artRepositories + } + + void setArtRepositories(Provider> value) { + artRepositories.set(value) + } + @InputFiles @SkipWhenEmpty protected FileCollection getInputFiles() { @@ -93,6 +106,22 @@ class PodInstallTask extends DefaultTask implements ExecSpec, LogFileSpec, Proce @TaskAction protected void install() { + artRepositories.get().each { repoUrl -> + def repoName = repoUrl.replaceAll("https?://","").replaceFirst("/","-443-").replaceAll("[/]","-") + ProcessExecutor.from(this) + + .withArguments(['repo-art', 'add', repoName, repoUrl, "--silent"]) + .withOutputLogFile(this, this) + .execute() + .assertNormalExitValue() + + ProcessExecutor.from(this) + .withArguments(['repo-art', 'update', repoName]) + .withOutputLogFile(this, this) + .execute() + .assertNormalExitValue() + } + ProcessExecutor.from(this) .withArguments(['repo', 'update']) .withOutputLogFile(this, this)