Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Add pods and workspace support (#63)
Browse files Browse the repository at this point in the history
Description
===========

This patch adds a new task `podInstall` to the plugin which is a
dependend task for `xcodeArchive`. It only executes when a `Podfile` is
in the project directory. The `xcodeArchive` task has a new workspace
property which is set by default to the workspace generated by
podInstall. The workspace has a higher precedance than the project. If
the workspace does not exist the task falls back to the project.

The issue is the very nature how cocoapods handles workspaces. You can
configure pods to use a preexisting workspace or it generates a new
workspace based on the project it finds in the same directory.

The current patch only tries to solve a current workflow issue and needs
changes and tests!

Changes
=======

* ![ADD] `pods` and `workspace` support
  • Loading branch information
Larusso authored Aug 13, 2020
1 parent 2b6193e commit 477e6d0
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import wooga.gradle.build.unity.ios.tasks.ImportProvisioningProfile
import wooga.gradle.build.unity.ios.tasks.KeychainTask
import wooga.gradle.build.unity.ios.tasks.ListKeychainTask
import wooga.gradle.build.unity.ios.tasks.LockKeychainTask
import wooga.gradle.build.unity.ios.tasks.PodInstallTask
import wooga.gradle.build.unity.ios.tasks.PublishTestFlight
import wooga.gradle.build.unity.ios.tasks.XCodeArchiveTask
import wooga.gradle.build.unity.ios.tasks.XCodeExportTask
Expand Down Expand Up @@ -198,11 +199,16 @@ class IOSBuildPlugin implements Plugin<Project> {
it.profileName = "${maybeBaseName(baseName, 'signing')}.mobileprovision"
}

PodInstallTask podInstall = tasks.create(maybeBaseName(baseName, "podInstall"), PodInstallTask) {
it.projectPath = xcodeProject
}

def xcodeArchive = tasks.create(maybeBaseName(baseName, "xcodeArchive"), XCodeArchiveTask) {
it.dependsOn addKeychain, unlockKeychain
it.dependsOn addKeychain, unlockKeychain, podInstall

it.provisioningProfile = importProvisioningProfiles
it.projectPath = xcodeProject
it.workspacePath = podInstall.workspace
it.buildKeychain = buildKeychain
it.destinationDir = project.file("${project.buildDir}/archives")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package wooga.gradle.build.unity.ios.tasks

import org.gradle.api.DefaultTask
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.*

class PodInstallTask extends DefaultTask {
private Object projectPath

@Internal
File getProjectPath() {
project.files(projectPath).getSingleFile()
}

void setProjectPath(Object path) {
projectPath = path
}

XCodeArchiveTask projectPath(Object path) {
setProjectPath(path)
}

@InputFiles
@SkipWhenEmpty
protected FileCollection getInputFiles() {
def podFile = project.file("Podfile")
def inputFiles = [podFile]

if(podFile.exists()) {
inputFiles << project.file( "Podfile.lock")
}

project.files(inputFiles.findAll { it.exists() }.toArray())
}

@OutputDirectory
protected getPodsDir() {
project.file("Pods")
}

@OutputDirectory
File getWorkspace() {
project.file(getProjectPath().path.replaceAll('xcodeproj', 'xcworkspace'))
}

@TaskAction
protected void install() {
project.exec {
executable 'pod'
args 'install'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import java.util.concurrent.Callable
class XCodeArchiveTask extends ConventionTask {

private Object projectPath
private Object workspacePath
private Object buildKeychain
private Object provisioningProfile

Expand Down Expand Up @@ -80,7 +81,25 @@ class XCodeArchiveTask extends ConventionTask {
}

XCodeArchiveTask projectPath(Object path) {
setExportOptionsPlist(path)
setProjectPath(path)
}

@Optional
@InputDirectory
File getWorkspacePath() {
def workspace = project.file(workspacePath)
if(!workspace.exists()) {
return null
}
workspace
}

void setWorkspacePath(Object path) {
workspacePath = path
}

XCodeArchiveTask projectWorkspacePath(Object path) {
setWorkspacePath(path)
}

@Optional
Expand Down Expand Up @@ -302,7 +321,9 @@ class XCodeArchiveTask extends ConventionTask {
arguments << it.toString()
}

if (getProjectPath()) {
if(getWorkspacePath()) {
arguments << "-workspace" << getWorkspacePath().getPath()
} else if (getProjectPath()) {
arguments << "-project" << getProjectPath().getPath()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class AWSSecretsManagerResolver implements SecretResolver {
this(SecretsManagerClient.builder().region(region).build())
}

AWSSecretsManagerResolver() {
this(SecretsManagerClient.builder().build())
}

@Override
Secret<?> resolve(String secretId) {
GetSecretValueRequest request = GetSecretValueRequest.builder().secretId(secretId).build() as GetSecretValueRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class AWSSecretsManagerResolverSpec extends SecretsResolverSpec<AWSSecretsManage
SecretsManagerClient secretsManager

@Shared
Region region = Region.EU_WEST_1
Region region = Region.EU_CENTRAL_1

AWSSecretsManagerResolver resolver

Expand Down

0 comments on commit 477e6d0

Please sign in to comment.