From 10779ea397168ec6bbff9585ebad78e2af4071dc Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Thu, 23 May 2019 22:02:48 +0300 Subject: [PATCH] Build: Extract android-dx to separate project with publishing --- dependencies/android-dx/build.gradle.kts | 111 +++++++++++++++++++++++ dependencies/android-dx/settings.gradle | 0 2 files changed, 111 insertions(+) create mode 100644 dependencies/android-dx/build.gradle.kts create mode 100644 dependencies/android-dx/settings.gradle diff --git a/dependencies/android-dx/build.gradle.kts b/dependencies/android-dx/build.gradle.kts new file mode 100644 index 00000000000..69cbfaa4e7b --- /dev/null +++ b/dependencies/android-dx/build.gradle.kts @@ -0,0 +1,111 @@ +import java.net.URI + +plugins { + base + `maven-publish` +} + +apply(from = "../../gradle/versions.gradle.kts") + +val androidBuildToolsVersion = extra["versions.androidBuildTools"] as String +val androidDxSourcesVersion = extra["versions.androidDxSources"] as String + +group = "org.jetbrains.kotlin" +version = androidBuildToolsVersion + +repositories { + ivy { + url = URI("https://dl.google.com/android/repository") + + patternLayout { + artifact("[artifact]_[revision](-[classifier]).[ext]") + } + + metadataSources { + artifact() + } + } + + + ivy { + url = URI("https://android.googlesource.com/platform/dalvik/+archive/android-$androidDxSourcesVersion") + + patternLayout { + artifact("[artifact].[ext]") + } + + metadataSources { + artifact() + } + } +} + +val androidBuildTools by configurations.creating +val androidDxSources by configurations.creating + +val androidDxRevision = androidBuildToolsVersion + +dependencies { + androidBuildTools("google:build-tools:$androidBuildToolsVersion:linux@zip") + androidDxSources("google:dx:0@tar.gz") +} + +val unzipDxJar by tasks.creating { + val outputDir = File(buildDir, name) + val outputFile = File(outputDir, "dx.jar") + + dependsOn(androidBuildTools) + inputs.files(androidBuildTools) + outputs.files(outputFile) + + doFirst { + project.copy { + from(zipTree(androidBuildTools.singleFile).files) + include("**/dx.jar") + into(outputDir) + } + } +} + +val untarDxSources by tasks.creating { + val dxSourcesTargetDir = File(buildDir, name) + dependsOn(androidDxSources) + inputs.files(androidDxSources) + outputs.dir(dxSourcesTargetDir) + doFirst { + project.copy { + from(tarTree(androidDxSources.singleFile)) + include("src/**") + includeEmptyDirs = false + into(dxSourcesTargetDir) + } + } +} + +val prepareDxSourcesJar by tasks.creating(Jar::class) { + dependsOn(untarDxSources) + from(untarDxSources) + + archiveClassifier.set("sources") +} + +val dxArtifact = artifacts.add("default", unzipDxJar.outputs.files.singleFile) { + builtBy(unzipDxJar) +} + +artifacts.add("default", prepareDxSourcesJar) + +publishing { + publications { + create("maven") { + artifact(dxArtifact) + artifact(prepareDxSourcesJar) + } + } + + repositories { + maven { + url = uri("${rootProject.buildDir}/internal/repo") + } + } +} \ No newline at end of file diff --git a/dependencies/android-dx/settings.gradle b/dependencies/android-dx/settings.gradle new file mode 100644 index 00000000000..e69de29bb2d