Skip to content

Instantly share code, notes, and snippets.

@kpiwko
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save kpiwko/7f9430f368b0a7c8128c to your computer and use it in GitHub Desktop.

Select an option

Save kpiwko/7f9430f368b0a7c8128c to your computer and use it in GitHub Desktop.
Gradle Spacelift env plugin
public class SpaceliftToolFromInstallationTest {
@Test
public void installAndroidSDKAndProvideTool() {
Project project = ProjectBuilder.builder().build()
project.apply plugin: 'aerogear-test-env'
project.setProperty("androidTargets", ["19"])
project.aerogearTestEnv {
workspace = new File(System.getProperty("user.dir"), "workspace")
installations {
androidSdk {
product = 'aerogear'
version = '1.0.0'
remoteUrl = [linux:"http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz", windows:"http://dl.google.com/android/android-sdk_r22.6.2-windows.zip", mac:"http://dl.google.com/android/android-sdk_r22.6.2-macosx.zip"]
fileName = [linux:"android-sdk_r22.6.2-linux.tgz", windows:"android-sdk_r22.6.2-windows.zip", mac:"android-sdk_r22.6.2-macosx.zip"]
home = [linux:"android-sdk-linux", windows:"android-sdk-windows", mac:"android-sdk-macosx"]
// tools provided by installation
tool {
name ="android"
command = [
linux: ["${home}/tools/android"],
windows: [
"cmd.exe",
"/C",
"${home}/tools/android.bat"
]
]
}
// actions performed after extraction
postActions {
// fix executable flags
project.ant.chmod(dir: "${home}/tools", perm:"a+x", includes:"*", excludes:"*.txt")
// update Android SDK, download / update each specified Android SDK version
project.androidTargets.each { v ->
Tasks.prepare(AndroidSdkUpdater).target(v).execute().await()
}
// opt out for stats
Tasks.prepare(AndroidSdkOptForStats).execute().await()
// update arquillian.xml files with Android homes
Tasks.chain([
androidHome: "${home}",
androidSdkHome: "${project.aerogearTestEnv.workspace}"
], ArquillianXmlUpdater).container('android').execute().await()
}
}
}
}
// initialize current project tools - this is effectively init-tools task
GradleSpacelift.currentProject(project)
project.aerogearTestEnv.installations.each { installation -> installation.install() }
// find android tool
def androidTool = GradleSpacelift.tools("android")
assertThat "Android tool is available after installation", androidTool, is(notNullValue())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment