Created
January 6, 2014 23:34
-
-
Save lifuzu/8291999 to your computer and use it in GitHub Desktop.
Download packages from Nexus artifacts server
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
/* | |
* The platform OS definition. | |
*/ | |
def getPlatformOS() { | |
def os = System.properties['os.name'].toLowerCase() | |
// by default we set the platform as 'linux' | |
def platform = 'linux' | |
// on Mac OS, System.properties['os.name'] return 'Mac OS X' | |
if (os.contains('mac')) { | |
platform = 'darwin' | |
} else if (os.contains('windows')) { | |
platform = 'windows' | |
} | |
return platform | |
} | |
def platformOS = getPlatformOS() | |
/* | |
* The gradle wrapper generation. | |
*/ | |
task wrapper(type:Wrapper) { | |
gradleVersion = '1.8' | |
} | |
configurations { | |
environment | |
} | |
repositories { | |
mavenCentral() | |
maven { | |
url "http://repo.server.com/content/groups/public" | |
} | |
} | |
dependencies { | |
environment "com.google.android.ndk:android-ndk:r9b:${platformOS}@zip" | |
environment "com.google.android.sdk:android-sdk:22.3:${platformOS}@zip" | |
environment "com.google.android.sdk:platform-tools:19:${platformOS}@zip" | |
environment "com.google.android.sdk:build-tools:19.0.0:${platformOS}@zip" | |
environment "com.google.android.sdk:android-19:01@zip" | |
} | |
task prepare(type: Copy) { | |
description = "Prepare build environment for compiling ... " | |
configurations.environment.filter { it.toString().endsWith(".zip") }.each { file -> | |
String sub = file.toString().contains("com.google.android.ndk") ? "android.ndk" : "android.sdk" | |
inputs.file file | |
from(zipTree(file)) { | |
into sub | |
} | |
} | |
outputs.dir '.environments' | |
into '.environments' | |
doLast { | |
exec { | |
commandLine = ".environments/android.sdk/tools/android update project --target android-19 -p .".tokenize() | |
} | |
} | |
} | |
task fixZipUncompress(type: Exec) { | |
description = "Fix some of files the permission problem when re-unzip the dependency ... " | |
def folder = new File("${projectDir}/.environments") | |
if( !folder.exists() ) { | |
folder.mkdirs() | |
} | |
def archiveFolder = new File("${buildDir}/tmp/expandedArchives") | |
if ( !archiveFolder.exists() ) { | |
archiveFolder.mkdirs() | |
} | |
commandLine = "chmod -R +w ${folder} ${archiveFolder}".tokenize() | |
} | |
prepare.dependsOn fixZipUncompress | |
task clean << { | |
description = "Clean build environment ... " | |
exec { | |
commandLine = "rm -fr .environments".tokenize() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment