Build scripts: separate setting up android sdk tasks

This commit is contained in:
Alexander Zolotov
2017-05-16 14:57:49 +03:00
parent 133787abae
commit 766b9bdeb9
+53 -51
View File
@@ -13,58 +13,60 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
task setupAndroidSdk {
if (!inJetBrainsNetwork) {
return
}
def zipFile = org.gradle.internal.os.OperatingSystem.current().familyName + ".zip"
def gradleFile = "gradle-3.3-bin.zip"
def repoFile = "offline_repo_repo.zip"
def archivePath = "$project.buildDir/android-sdk/" + zipFile
def gradlePath = "$project.buildDir/android-sdk/" + gradleFile
def repoPath = "$project.buildDir/android-sdk/" + repoFile
def outputDir ="$project.buildDir/android-sdk/prebuilts/studio/sdk"
def outputGradle ="$project.buildDir/android-sdk/tools/external/gradle"
def outputRepo ="$project.buildDir/android-sdk/prebuilts/tools/common/m2/repository"
outputs.dir(outputDir)
outputs.dir(outputGradle)
outputs.dir("$project.buildDir/android-sdk/prebuilts/tools/common");
outputs.file(archivePath)
outputs.file(gradlePath)
outputs.file(repoPath)
doFirst {
download {
src "http://repo.labs.intellij.net/thirdparty/android-sdk/" + zipFile
dest archivePath
onlyIfNewer true
}
download {
src "http://repo.labs.intellij.net/thirdparty/gradle/" + gradleFile
dest gradlePath
onlyIfNewer true
}
download {
src "http://repo.labs.intellij.net/thirdparty/android-sdk/" + repoFile
dest repoPath
onlyIfNewer true
}
buildscript {
repositories {
maven { url "http://repo.labs.intellij.net/plugins-gradle-org/" }
maven { url "https://plugins.gradle.org/m2/" }
}
doLast {
logger.info("Unpacking android sdk into " + archivePath)
copy {
from zipTree(file(archivePath))
into outputDir
}
copy {
from file(gradlePath)
into outputGradle
}
copy {
from zipTree(file(repoPath))
into outputRepo
}
file("$project.buildDir/android-sdk/prebuilts/tools/common/offline-m2").mkdirs()
dependencies {
classpath "de.undercouch:gradle-download-task:3.2.0"
}
}
apply plugin: "de.undercouch.download"
import de.undercouch.gradle.tasks.download.Download
def currentOs = org.gradle.internal.os.OperatingSystem.current()
task downloadGradleDistribution(type: Download) {
src "http://repo.labs.intellij.net/thirdparty/gradle/gradle-3.3-bin.zip"
dest "$buildDir/android-sdk/gradle-3.3-bin.zip"
onlyIfNewer true
onlyIf { inJetBrainsNetwork }
}
task setupGradleDistribution(dependsOn: downloadGradleDistribution, type: Copy) {
from zipTree(downloadGradleDistribution.outputs.files.singleFile)
into "$buildDir/android-sdk/tools/external/gradle"
}
task downloadOfflineRepo(type: Download) {
src "http://repo.labs.intellij.net/thirdparty/android-sdk/offline_repo_repo.zip"
dest "$buildDir/android-sdk/offline_repo_repo.zip"
onlyIfNewer true
onlyIf { inJetBrainsNetwork }
}
task setupOfflineRepo(dependsOn: downloadOfflineRepo, type: Copy) {
from zipTree(downloadGradleDistribution.outputs.files.singleFile)
into "$buildDir/android-sdk/prebuilts/tools/common/m2/repository"
}
task downloadAndroidSdk(type: Download) {
def osFamily = currentOs.familyName
src "http://repo.labs.intellij.net/thirdparty/android-sdk/${osFamily}.zip"
dest "$buildDir/android-sdk/${osFamily}.zip"
onlyIfNewer true
onlyIf { !currentOs.isMacOsX() && inJetBrainsNetwork }
}
task setupAndroidSdk(dependsOn: [downloadAndroidSdk, setupGradleDistribution, setupOfflineRepo], type: Copy) {
from zipTree(downloadAndroidSdk.outputs.files.singleFile)
into "$buildDir/android-sdk/prebuilts/studio/sdk"
onlyIf { !currentOs.isMacOsX() }
outputs.dir("$buildDir/android-sdk/prebuilts/tools/common")
doLast {
file("$buildDir/android-sdk/prebuilts/tools/common/offline-m2").mkdirs()
}
}