Build: Merge prepare-deps/android-dx to intellij-sdk
This commit is contained in:
@@ -109,4 +109,4 @@ samWithReceiver {
|
||||
fun Project.`samWithReceiver`(configure: org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverExtension.() -> Unit): Unit =
|
||||
extensions.configure("samWithReceiver", configure)
|
||||
|
||||
tasks["build"].dependsOn(":prepare-deps:android-dx:build", ":prepare-deps:intellij-sdk:build")
|
||||
tasks["build"].dependsOn(":prepare-deps:intellij-sdk:build")
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
|
||||
import org.gradle.api.publish.ivy.internal.artifact.FileBasedIvyArtifact
|
||||
import org.gradle.api.publish.ivy.internal.publication.DefaultIvyConfiguration
|
||||
import org.gradle.api.publish.ivy.internal.publication.DefaultIvyPublicationIdentity
|
||||
import org.gradle.api.publish.ivy.internal.publisher.IvyDescriptorFileGenerator
|
||||
import java.io.File
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
val toolsOs by lazy {
|
||||
when {
|
||||
OperatingSystem.current().isWindows -> "windows"
|
||||
OperatingSystem.current().isMacOsX -> "macosx"
|
||||
OperatingSystem.current().isLinux -> "linux"
|
||||
else -> {
|
||||
logger.error("Unknown operating system for android tools: ${OperatingSystem.current().name}")
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val buildToolsVersion = rootProject.extra["versions.androidBuildTools"] as String
|
||||
val dxSourcesVersion = rootProject.extra["versions.androidDxSources"] as String
|
||||
|
||||
repositories {
|
||||
ivy {
|
||||
artifactPattern("https://dl.google.com/android/repository/[artifact]_[revision](-[classifier]).[ext]")
|
||||
artifactPattern("https://android.googlesource.com/platform/dalvik/+archive/android-$dxSourcesVersion/[artifact].[ext]")
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val customDepsRepoDir = File(rootProject.rootDir, "../dependencies/repo")
|
||||
val customDepsOrg: String by rootProject.extra
|
||||
val dxModuleName = "android-dx"
|
||||
val dxRevision = buildToolsVersion
|
||||
val dxRepoModuleDir = File(customDepsRepoDir, "$customDepsOrg/$dxModuleName/$dxRevision")
|
||||
|
||||
val buildToolsZip by configurations.creating
|
||||
val dxSourcesTar by configurations.creating
|
||||
|
||||
dependencies {
|
||||
buildToolsZip("google:build-tools:$buildToolsVersion:$toolsOs@zip")
|
||||
dxSourcesTar("google:dx:0@tar.gz")
|
||||
}
|
||||
|
||||
val unzipDxJar by tasks.creating {
|
||||
dependsOn(buildToolsZip)
|
||||
inputs.files(buildToolsZip)
|
||||
outputs.files(File(dxRepoModuleDir, "dx.jar"))
|
||||
doFirst {
|
||||
project.copy {
|
||||
from(zipTree(buildToolsZip.singleFile).files)
|
||||
include("**/dx.jar")
|
||||
into(dxRepoModuleDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val dxSourcesTargetDir = File(buildDir, "dx_src")
|
||||
|
||||
val untarDxSources by tasks.creating {
|
||||
dependsOn(dxSourcesTar)
|
||||
inputs.files(dxSourcesTar)
|
||||
outputs.dir(dxSourcesTargetDir)
|
||||
doFirst {
|
||||
project.copy {
|
||||
from(tarTree(dxSourcesTar.singleFile))
|
||||
include("src/**")
|
||||
includeEmptyDirs = false
|
||||
into(dxSourcesTargetDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val prepareDxSourcesJar by tasks.creating(Jar::class) {
|
||||
dependsOn(untarDxSources)
|
||||
from("$dxSourcesTargetDir/src")
|
||||
destinationDir = dxRepoModuleDir
|
||||
baseName = "dx"
|
||||
classifier = "sources"
|
||||
}
|
||||
|
||||
val prepareIvyXml by tasks.creating {
|
||||
dependsOn(unzipDxJar, prepareDxSourcesJar)
|
||||
inputs.files(unzipDxJar, prepareDxSourcesJar)
|
||||
val ivyFile = File(dxRepoModuleDir, "$dxModuleName.ivy.xml")
|
||||
outputs.file(ivyFile)
|
||||
doLast {
|
||||
with(IvyDescriptorFileGenerator(DefaultIvyPublicationIdentity(customDepsOrg, dxModuleName, dxRevision))) {
|
||||
addConfiguration(DefaultIvyConfiguration("default"))
|
||||
addConfiguration(DefaultIvyConfiguration("sources"))
|
||||
addArtifact(
|
||||
FileBasedIvyArtifact(
|
||||
File(dxRepoModuleDir, "dx.jar"),
|
||||
DefaultIvyPublicationIdentity(customDepsOrg, "dx", dxRevision)
|
||||
).also {
|
||||
it.conf = "default"
|
||||
})
|
||||
|
||||
addArtifact(
|
||||
FileBasedIvyArtifact(
|
||||
File(dxRepoModuleDir, "dx-sources.jar"),
|
||||
DefaultIvyPublicationIdentity(customDepsOrg, "dx", dxRevision)
|
||||
).also {
|
||||
it.conf = "sources"
|
||||
it.classifier = "sources"
|
||||
})
|
||||
|
||||
writeTo(ivyFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val build by tasks.creating {
|
||||
dependsOn(unzipDxJar, prepareDxSourcesJar, prepareIvyXml)
|
||||
}
|
||||
|
||||
val clean by tasks.creating(Delete::class) {
|
||||
delete(dxRepoModuleDir)
|
||||
delete(buildDir)
|
||||
}
|
||||
@@ -18,6 +18,9 @@ val intellijSeparateSdks: Boolean by rootProject.extra
|
||||
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
|
||||
val installIntellijUltimate = intellijUltimateEnabled
|
||||
|
||||
val androidBuildToolsVersion = rootProject.extra["versions.androidBuildTools"] as String
|
||||
val androidDxSourcesVersion = rootProject.extra["versions.androidDxSources"] as String
|
||||
|
||||
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
|
||||
if (intellijVersionDelimiterIndex == -1) {
|
||||
error("Invalid IDEA version $intellijVersion")
|
||||
@@ -35,7 +38,7 @@ logger.info("intellijSeparateSdks: $intellijSeparateSdks")
|
||||
logger.info("installIntellijCommunity: $installIntellijCommunity")
|
||||
logger.info("installIntellijUltimate: $installIntellijUltimate")
|
||||
|
||||
val studioOs by lazy {
|
||||
val androidStudioOs by lazy {
|
||||
when {
|
||||
OperatingSystem.current().isWindows -> "windows"
|
||||
OperatingSystem.current().isMacOsX -> "mac"
|
||||
@@ -47,20 +50,41 @@ val studioOs by lazy {
|
||||
}
|
||||
}
|
||||
|
||||
val androidToolsOs by lazy {
|
||||
when {
|
||||
OperatingSystem.current().isWindows -> "windows"
|
||||
OperatingSystem.current().isMacOsX -> "macosx"
|
||||
OperatingSystem.current().isLinux -> "linux"
|
||||
else -> {
|
||||
logger.error("Unknown operating system for android tools: ${OperatingSystem.current().name}")
|
||||
""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
if (androidStudioRelease != null) {
|
||||
ivy {
|
||||
if (cacheRedirectorEnabled) {
|
||||
artifactPattern("https://cache-redirector.jetbrains.com/dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$studioOs.zip")
|
||||
artifactPattern("https://cache-redirector.jetbrains.com/dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$androidStudioOs.zip")
|
||||
}
|
||||
|
||||
artifactPattern("https://dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$studioOs.zip")
|
||||
artifactPattern("https://dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$androidStudioOs.zip")
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ivy {
|
||||
artifactPattern("https://dl.google.com/android/repository/[artifact]_[revision](-[classifier]).[ext]")
|
||||
artifactPattern("https://android.googlesource.com/platform/dalvik/+archive/android-$androidDxSourcesVersion/[artifact].[ext]")
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/$intellijReleaseType")
|
||||
maven("https://cache-redirector.jetbrains.com/plugins.jetbrains.com/maven")
|
||||
@@ -80,6 +104,8 @@ val jpsStandalone by configurations.creating
|
||||
val jpsBuildTest by configurations.creating
|
||||
val intellijCore by configurations.creating
|
||||
val nodeJS by configurations.creating
|
||||
val androidBuildTools by configurations.creating
|
||||
val androidDxSources by configurations.creating
|
||||
|
||||
/**
|
||||
* Special repository for annotations.jar required for idea runtime only.
|
||||
@@ -93,6 +119,10 @@ val customDepsOrg: String by rootProject.extra
|
||||
val customDepsRevision = intellijVersion
|
||||
val repoDir = File(customDepsRepoDir, customDepsOrg)
|
||||
|
||||
val androidDxModuleName = "android-dx"
|
||||
val androidDxRevision = androidBuildToolsVersion
|
||||
val androidDxRepoModuleDir = File(repoDir, "$androidDxModuleName/$androidDxRevision")
|
||||
|
||||
dependencies {
|
||||
if (androidStudioRelease != null) {
|
||||
androidStudio("google:android-studio-ide:$androidStudioBuild")
|
||||
@@ -116,6 +146,66 @@ dependencies {
|
||||
if (intellijUltimateEnabled) {
|
||||
nodeJS("com.jetbrains.plugins:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}@zip")
|
||||
}
|
||||
|
||||
androidBuildTools("google:build-tools:$androidBuildToolsVersion:$androidToolsOs@zip")
|
||||
androidDxSources("google:dx:0@tar.gz")
|
||||
}
|
||||
|
||||
val dxSourcesTargetDir = File(buildDir, "dx_src")
|
||||
|
||||
val untarDxSources by tasks.creating {
|
||||
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("$dxSourcesTargetDir/src")
|
||||
destinationDir = File(repoDir, sources.name)
|
||||
baseName = androidDxModuleName
|
||||
classifier = "sources"
|
||||
version = androidBuildToolsVersion
|
||||
}
|
||||
|
||||
val unzipDxJar by tasks.creating {
|
||||
dependsOn(androidBuildTools)
|
||||
inputs.files(androidBuildTools)
|
||||
outputs.files(File(androidDxRepoModuleDir, "dx.jar"))
|
||||
doFirst {
|
||||
project.copy {
|
||||
from(zipTree(androidBuildTools.singleFile).files)
|
||||
include("**/dx.jar")
|
||||
into(androidDxRepoModuleDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val buildIvyRepoForAndroidDx by tasks.creating {
|
||||
dependsOn(unzipDxJar, prepareDxSourcesJar)
|
||||
inputs.files(unzipDxJar, prepareDxSourcesJar)
|
||||
outputs.file(File(androidDxRepoModuleDir, "$androidDxModuleName.ivy.xml"))
|
||||
|
||||
doLast {
|
||||
writeIvyXml(
|
||||
customDepsOrg,
|
||||
androidDxModuleName,
|
||||
androidBuildToolsVersion,
|
||||
androidDxModuleName,
|
||||
androidDxRepoModuleDir,
|
||||
androidDxRepoModuleDir,
|
||||
androidDxRepoModuleDir,
|
||||
prepareDxSourcesJar.outputs.files.singleFile
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
||||
@@ -161,7 +251,7 @@ val makeIde = if (androidStudioBuild != null) {
|
||||
androidStudio,
|
||||
customDepsOrg,
|
||||
customDepsRepoDir,
|
||||
if (studioOs == "mac")
|
||||
if (androidStudioOs == "mac")
|
||||
::skipContentsDirectory
|
||||
else
|
||||
::skipToplevelDirectory
|
||||
@@ -186,7 +276,8 @@ val build by tasks.creating {
|
||||
makeIde,
|
||||
buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile),
|
||||
buildIvyRepositoryTask(jpsBuildTest, customDepsOrg, customDepsRepoDir, null, sourcesFile),
|
||||
makeIntellijAnnotations
|
||||
makeIntellijAnnotations,
|
||||
buildIvyRepoForAndroidDx
|
||||
)
|
||||
|
||||
if (installIntellijUltimate) {
|
||||
|
||||
@@ -11,5 +11,4 @@ pluginManagement {
|
||||
}
|
||||
}
|
||||
|
||||
include "prepare-deps:android-dx",
|
||||
"prepare-deps:intellij-sdk"
|
||||
include "prepare-deps:intellij-sdk"
|
||||
|
||||
@@ -10,6 +10,7 @@ fun RepositoryHandler.androidDxJarRepo(project: Project): IvyArtifactRepository
|
||||
val baseDir = File("${project.rootDir}/dependencies/repo")
|
||||
ivyPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/[module].ivy.xml")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/[artifact](-[classifier]).jar")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/sources/[artifact]-[revision](-[classifier]).[ext]")
|
||||
}
|
||||
|
||||
fun Project.androidDxJar() = "kotlin.build:android-dx:${rootProject.extra["versions.androidBuildTools"]}"
|
||||
|
||||
@@ -50,6 +50,7 @@ fun RepositoryHandler.intellijSdkRepo(project: Project): IvyArtifactRepository =
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/artifacts/lib/[artifact](-[classifier]).[ext]")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/[module]/[revision]/artifacts/[artifact](-[classifier]).[ext]")
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/${project.ideModuleName()}/[revision]/artifacts/plugins/[module]/lib/[artifact](-[classifier]).[ext]") // bundled plugins
|
||||
artifactPattern("${baseDir.canonicalPath}/[organisation]/sources/[artifact]-[revision](-[classifier]).[ext]")
|
||||
|
||||
metadataSources {
|
||||
ivyDescriptor()
|
||||
|
||||
Reference in New Issue
Block a user