-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
180 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
plugin/src/main/groovy/org/openbakery/carthage/CarthageUpdateTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.openbakery.carthage | ||
|
||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.internal.logging.text.StyledTextOutputFactory | ||
import org.openbakery.AbstractXcodeTask | ||
import org.openbakery.CommandRunner | ||
import org.openbakery.CommandRunnerException | ||
import org.openbakery.cocoapods.CocoapodsInstallTask | ||
import org.openbakery.output.ConsoleOutputAppender | ||
|
||
/** | ||
* Created by rene on 17.08.16. | ||
*/ | ||
class CarthageUpdateTask extends AbstractXcodeTask { | ||
|
||
|
||
public CarthageUpdateTask() { | ||
super() | ||
setDescription "Installs the carthage dependencies for the given project" | ||
} | ||
|
||
@TaskAction | ||
void update() { | ||
|
||
checkCarthageInstallation() | ||
|
||
def output = services.get(StyledTextOutputFactory).create(CarthageUpdateTask) | ||
commandRunner.run(["carthage", "update"], new ConsoleOutputAppender(output)) | ||
|
||
} | ||
|
||
void checkCarthageInstallation() { | ||
try { | ||
commandRunner.run("which", "carthage") | ||
} catch (CommandRunnerException) { | ||
throw new IllegalStateException("The carthage command was not found. Make sure that Carthage is installed") | ||
} | ||
} | ||
|
||
boolean hasCartfile() { | ||
File cartfile = new File(project.projectDir, "Cartfile") | ||
return cartfile.exists() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
plugin/src/test/groovy/org/openbakery/carthage/CarthageUpdateTaskSpecification.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.openbakery.carthage | ||
|
||
import org.apache.commons.io.FileUtils | ||
import org.gradle.api.Project | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import org.openbakery.CommandRunner | ||
import org.openbakery.CommandRunnerException | ||
import org.openbakery.output.ConsoleOutputAppender | ||
import spock.lang.Specification | ||
|
||
/** | ||
* Created by rene on 18.08.16. | ||
*/ | ||
class CarthageUpdateTaskSpecification extends Specification { | ||
|
||
|
||
Project project | ||
CarthageUpdateTask carthageUpdateTask; | ||
|
||
CommandRunner commandRunner = Mock(CommandRunner) | ||
|
||
def setup() { | ||
|
||
File projectDir = new File(System.getProperty("java.io.tmpdir"), "gradle-xcodebuild") | ||
|
||
project = ProjectBuilder.builder().withProjectDir(projectDir).build() | ||
project.buildDir = new File('build').absoluteFile | ||
project.apply plugin: org.openbakery.XcodePlugin | ||
|
||
carthageUpdateTask = project.getTasks().getByPath('carthageUpdate') | ||
|
||
carthageUpdateTask.commandRunner = commandRunner | ||
|
||
} | ||
|
||
|
||
def cleanup() { | ||
FileUtils.deleteDirectory(project.projectDir) | ||
} | ||
|
||
def "has carthageUpdate task"() { | ||
|
||
expect: | ||
carthageUpdateTask instanceof CarthageUpdateTask | ||
|
||
} | ||
|
||
def "verify that if carthage is not installed a excpetion is thrown"() { | ||
given: | ||
commandRunner.run("which", "carthage") >> { throw new CommandRunnerException("Command failed to run (exit code 1):") } | ||
|
||
when: | ||
carthageUpdateTask.update() | ||
|
||
then: | ||
def e = thrown(IllegalStateException) | ||
e.message.startsWith("The carthage command was not found. Make sure that Carthage is installed") | ||
} | ||
|
||
def "verify that carthage is installed"() { | ||
when: | ||
carthageUpdateTask.update() | ||
|
||
then: | ||
1 * commandRunner.run("which", "carthage") | ||
|
||
} | ||
|
||
def "run carthage update"() { | ||
when: | ||
carthageUpdateTask.update() | ||
|
||
|
||
then: | ||
1 * commandRunner.run(["carthage", "update"], _ ) >> { | ||
args -> args[1] instanceof ConsoleOutputAppender | ||
} | ||
|
||
} | ||
|
||
} |