Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
plugins {
id 'nebula.release' version '6.0.0'
}

//

allprojects {
apply plugin: 'java-gradle-plugin'
apply plugin: 'groovy'

def versionNumber = "0.16.0.a603076-SNAPSHOT"

if (project.hasProperty("versionNumber")) {
versionNumber = project.versionNumber
}
if (project.hasProperty("versionSuffix")) {
versionNumber += project.versionSuffix
}
if (project.hasProperty("buildNumber")) {
versionNumber += "." + project.buildNumber
}


group = 'org.openbakery'
version = versionNumber
version = project.version.toString() + "-SNAPSHOT"

sourceCompatibility = "1.6"
targetCompatibility = "1.6"
Expand Down
4 changes: 3 additions & 1 deletion example/OSX/ExampleOSX/ExampleOSX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
TargetAttributes = {
A7F1890E1A6FE161002D206F = {
CreatedOnToolsVersion = 6.1.1;
DevelopmentTeam = Z7L2YCUH45;
DevelopmentTeam = 2YFT3F89TY;
};
A7F189211A6FE161002D206F = {
CreatedOnToolsVersion = 6.1.1;
Expand Down Expand Up @@ -404,6 +404,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 2YFT3F89TY;
INFOPLIST_FILE = ExampleOSX/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -417,6 +418,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = 2YFT3F89TY;
INFOPLIST_FILE = ExampleOSX/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
6 changes: 1 addition & 5 deletions libxcode/src/main/groovy/org/openbakery/CommandRunner.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.openbakery.output.OutputAppender
import org.slf4j.Logger
import org.slf4j.LoggerFactory

class CommandRunner {
class CommandRunner implements Serializable{

private static Logger logger = LoggerFactory.getLogger(CommandRunner.class)

Expand All @@ -34,10 +34,6 @@ class CommandRunner {

Thread readerThread

public CommandRunner() {

}

void setOutputFile(File outputFile) {
if (outputFile.exists()) {

Expand Down
2 changes: 1 addition & 1 deletion libxcode/src/main/groovy/org/openbakery/xcode/Xcode.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Xcode {
if (file.exists()) {
result.put(ENV_DEVELOPER_DIR, file.absolutePath)
}
println file.absolutePath

return result
}

Expand Down
28 changes: 18 additions & 10 deletions libxcode/src/main/groovy/org/openbakery/xcode/Xcodebuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,34 @@ class Xcodebuild {
static void packageIpa(CommandRunner commandRunner,
File archivePath,
File exportPath,
File exportOptionsPlist) {
File exportOptionsPlist,
@Nullable File xcodeApp) {

assert archivePath != null && archivePath.exists()
assert exportPath != null && exportPath.exists()
assert exportOptionsPlist != null && exportOptionsPlist.exists()

commandRunner.run(EXECUTABLE,
ACTION_EXPORT_ARCHIVE,
ARGUMENT_ARCHIVE_PATH, archivePath.absolutePath,
ARGUMENT_EXPORT_PATH, exportPath.absolutePath,
ARGUMENT_EXPORT_OPTIONS_PLIST, exportOptionsPlist.absolutePath)
// Env value
HashMap<String, String> envMap = new HashMap<>()
if (xcodeApp != null) {
envMap.put(Xcode.ENV_DEVELOPER_DIR, xcodeApp.absolutePath)
}

List<String> args = [EXECUTABLE,
ACTION_EXPORT_ARCHIVE,
ARGUMENT_ARCHIVE_PATH, archivePath.absolutePath,
ARGUMENT_EXPORT_PATH, exportPath.absolutePath,
ARGUMENT_EXPORT_OPTIONS_PLIST, exportOptionsPlist.absolutePath]

commandRunner.run(args, envMap)
}

static void archive(CommandRunner commandRunner,
String scheme,
File outputPath,
File xcConfig,
String configuration,
@Nullable File xcodeApp) {
assert scheme != null
assert xcConfig.exists() && !xcConfig.isDirectory()

HashMap<String, String> envMap = new HashMap<>()

Expand All @@ -80,8 +88,8 @@ class Xcodebuild {
List<String> args = [EXECUTABLE,
ACTION_ARCHIVE,
ARGUMENT_SCHEME, scheme,
ARGUMENT_ARCHIVE_PATH, outputPath.absolutePath,
ARGUMENT_XCCONFIG, xcConfig.absolutePath]
"-configuration", configuration,
ARGUMENT_ARCHIVE_PATH, outputPath.absolutePath]

commandRunner.run(args, envMap)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class KeychainCreateTaskFunctionalTest extends Specification {
buildFile << """
xcodebuild {
signing {
certificate = project.provisioningFile1("$certificate")
certificateURI = "$certificate.absolutePath"
}
}
"""
Expand All @@ -84,6 +84,7 @@ class KeychainCreateTaskFunctionalTest extends Specification {
BuildResult result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments(KeychainCreateTask.TASK_NAME)
.withDebug(true)
.withPluginClasspath(pluginClasspath)
.build()

Expand All @@ -96,7 +97,7 @@ class KeychainCreateTaskFunctionalTest extends Specification {
buildFile << """
xcodebuild {
signing {
certificate = project.provisioningFile1("$certificate")
certificateURI = "${certificate.toURI().toString()}"
certificatePassword = "p4ssword"
}
}
Expand All @@ -107,6 +108,7 @@ class KeychainCreateTaskFunctionalTest extends Specification {
.withProjectDir(testProjectDir.root)
.withArguments(KeychainCreateTask.TASK_NAME)
.withPluginClasspath(pluginClasspath)
.withDebug(true)
.build()

then:
Expand All @@ -118,7 +120,7 @@ class KeychainCreateTaskFunctionalTest extends Specification {
buildFile << """
xcodebuild {
signing {
certificate = project.provisioningFile1("$certificate")
certificateURI = "${certificate.toURI().toString()}"
certificatePassword = "p4ssword"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package org.openbakery.carthage

import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.TaskOutcome
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Specification

class CarthageBootStrapTaskFunctionalTest extends Specification {
@Rule
final TemporaryFolder testProjectDir = new TemporaryFolder()

List<File> pluginClasspath
File buildFile
GradleRunner gradleRunner
File carthageFolder

void setup() {
buildFile = testProjectDir.newFile('build.gradle')

buildFile << """
plugins {
id 'org.openbakery.xcode-plugin'
}
"""

def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt")
if (pluginClasspathResource == null) {
throw new IllegalStateException("Did not find plugin classpath resource, run `testClasses` build task.")
}

pluginClasspath = pluginClasspathResource.readLines().collect { new File(it) }

gradleRunner = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withArguments(CarthageBootStrapTask.NAME)
.withPluginClasspath(pluginClasspath)

carthageFolder = new File(testProjectDir.root, "Carthage")
}

def "The task list should contain the task"() {
when:
BuildResult result = gradleRunner.build()

then:
result.output.contains(CarthageBootStrapTask.NAME)
}

def "The task should be skipped if no cartfile is present"() {
when:
BuildResult result = gradleRunner.build()

then:
result.task(":" + CarthageBootStrapTask.NAME)
.outcome == TaskOutcome.SKIPPED
}

def "The task should be executed with success if a `cartfile.resolved` file is present"() {
setup:
testProjectDir.newFile(CarthageBootStrapTask.CARTHAGE_RESOLVED_FILE)

when:
BuildResult result = gradleRunner.build()

then:
result.task(":" + CarthageBootStrapTask.NAME)
.outcome == TaskOutcome.SUCCESS
}

def "The task should resolve the defined carthage dependencies"() {
setup:
File carthageFile = testProjectDir.newFile("Cartfile")
carthageFile << """
github "ashleymills/Reachability.swift"
"""

File carthageResolvedFile = testProjectDir.newFile(CarthageBootStrapTask.CARTHAGE_RESOLVED_FILE)
carthageResolvedFile << """
github "ashleymills/Reachability.swift" "v4.1.0"
"""

when:
BuildResult result = gradleRunner
.build()

then:
result.task(":" + CarthageBootStrapTask.NAME)
.outcome == TaskOutcome.SUCCESS

and: "The resolved framework should be existing only for iOS (default target)"
carthageFolder.exists()
new File(carthageFolder, "Build/iOS/Reachability.framework").exists()
!new File(carthageFolder, "Build/tvOS/Reachability.framework").exists()

when: "Force reset and build with cache enabled"
assert carthageFolder.deleteDir()
result = gradleRunner.withArguments('--build-cache', CarthageBootStrapTask.NAME)
.build()

then: "Should resolve the carthage dependencies from cache"
result.task(":" + CarthageBootStrapTask.NAME)
.outcome == TaskOutcome.FROM_CACHE

new File(carthageFolder, "Build/iOS/Reachability.framework").exists()
!new File(carthageFolder, "Build/tvOS/Reachability.framework").exists()
}

def "The task should resolve the defined carthage dependencies depending of the configured target"() {
setup:
File carthageFile = testProjectDir.newFile("Cartfile")
carthageFile << """
github "ashleymills/Reachability.swift"
"""

File carthageResolvedFile = testProjectDir.newFile(CarthageBootStrapTask.CARTHAGE_RESOLVED_FILE)
carthageResolvedFile << """
github "ashleymills/Reachability.swift" "v4.1.0"
"""

buildFile << """
xcodebuild {
type = "tvOS"
}
"""

when:
BuildResult result = gradleRunner.build()

then:
result.task(":" + CarthageBootStrapTask.NAME)
.outcome == TaskOutcome.SUCCESS

and: "The resolved framework should be existing only for iOS (default target)"
carthageFolder.exists()
!new File(carthageFolder, "Build/iOS/Reachability.framework").exists()
new File(carthageFolder, "Build/tvOS/Reachability.framework").exists()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class ProvisioningInstallTaskFunctionalTest extends Specification {
provisioningFile1 = findResource("test1.mobileprovision")
assert provisioningFile1.exists()

def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt")
def pluginClasspathResource = getClass().classLoader
.findResource("plugin-classpath.txt")

if (pluginClasspathResource == null) {
throw new IllegalStateException("Did not find plugin classpath resource, run `testClasses` build task.")
}
Expand Down Expand Up @@ -70,7 +72,7 @@ class ProvisioningInstallTaskFunctionalTest extends Specification {
buildFile << """
xcodebuild {
signing {
mobileProvisionURI = []
mobileProvisionList = []
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ abstract class AbstractXcodeBuildTask extends AbstractXcodeTask {
}

String getBundleIdentifier() {
File infoPlist = new File(project.projectDir, getXcodeExtension().infoPlist)
File infoPlist = new File(project.rootProject.rootDir, getXcodeExtension().infoPlist)
return plistHelper.getValueFromPlist(infoPlist, "CFBundleIdentifier")
}

Expand All @@ -119,8 +119,6 @@ abstract class AbstractXcodeBuildTask extends AbstractXcodeTask {
List<File> provisioningList = getProvisioningUriList()
.collect { it -> new File(new URI(it)) }

println "provisioningList : " + provisioningList

return Optional.ofNullable(ProvisioningProfileReader.getProvisionFileForIdentifier(bundleIdentifier,
provisioningList,
commandRunner,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class InfoPlistModifyTask extends AbstractDistributeTask {
throw new IllegalArgumentException("No Info.plist was found! Check you xcode project settings if the specified target has a Info.plist set.")
}

infoPlist = new File(project.projectDir, project.xcodebuild.infoPlist)
infoPlist = new File(project.rootProject.projectDir, project.xcodebuild.infoPlist)


logger.debug("Try to updating {}", infoPlist)
Expand Down Expand Up @@ -148,7 +148,7 @@ class InfoPlistModifyTask extends AbstractDistributeTask {
setValueForPlist(KeyBundleIdentifier, extension.bundleIdentifier)
} else {
xcodeExtension.getBuildTargetConfiguration(xcodeExtension.scheme.getOrNull(),
xcodeExtension.configuration)
xcodeExtension.configuration.get())
.map { it -> it.bundleIdentifier }
.ifPresent { it -> setValueForPlist(KeyBundleIdentifier, it) }
}
Expand Down
Loading