Build: Extract android-dx to separate project with publishing

This commit is contained in:
Vyacheslav Gerasimov
2019-05-23 22:02:48 +03:00
parent d0db006614
commit 10779ea397
2 changed files with 111 additions and 0 deletions

111
dependencies/android-dx/build.gradle.kts vendored Normal file
View File

@@ -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<MavenPublication>("maven") {
artifact(dxArtifact)
artifact(prepareDxSourcesJar)
}
}
repositories {
maven {
url = uri("${rootProject.buildDir}/internal/repo")
}
}
}

View File