182: Build: Support idea SNAPSHOT version
This commit is contained in:
committed by
Nikolay Krasko
parent
8af4ae0409
commit
1c9a2c5d30
@@ -0,0 +1,276 @@
|
|||||||
|
|
||||||
|
@file:Suppress("PropertyName")
|
||||||
|
|
||||||
|
import org.gradle.api.publish.ivy.internal.artifact.DefaultIvyArtifact
|
||||||
|
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 com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val intellijUltimateEnabled: Boolean by rootProject.extra
|
||||||
|
val intellijRepo: String by rootProject.extra
|
||||||
|
val intellijReleaseType: String by rootProject.extra
|
||||||
|
val intellijVersion = rootProject.extra["versions.intellijSdk"] as String
|
||||||
|
val androidStudioRelease = rootProject.findProperty("versions.androidStudioRelease") as String?
|
||||||
|
val androidStudioBuild = rootProject.findProperty("versions.androidStudioBuild") as String?
|
||||||
|
val intellijSeparateSdks: Boolean by rootProject.extra
|
||||||
|
val installIntellijCommunity = !intellijUltimateEnabled || intellijSeparateSdks
|
||||||
|
val installIntellijUltimate = intellijUltimateEnabled
|
||||||
|
|
||||||
|
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
|
||||||
|
if (intellijVersionDelimiterIndex == -1) {
|
||||||
|
error("Invalid IDEA version $intellijVersion")
|
||||||
|
}
|
||||||
|
|
||||||
|
val platformBaseVersion = intellijVersion.substring(0, intellijVersionDelimiterIndex)
|
||||||
|
|
||||||
|
logger.info("intellijUltimateEnabled: $intellijUltimateEnabled")
|
||||||
|
|
||||||
|
logger.info("intellijVersion: $intellijVersion")
|
||||||
|
logger.info("androidStudioRelease: $androidStudioRelease")
|
||||||
|
logger.info("androidStudioBuild: $androidStudioBuild")
|
||||||
|
|
||||||
|
logger.info("intellijSeparateSdks: $intellijSeparateSdks")
|
||||||
|
logger.info("installIntellijCommunity: $installIntellijCommunity")
|
||||||
|
logger.info("installIntellijUltimate: $installIntellijUltimate")
|
||||||
|
|
||||||
|
val studioOs by lazy {
|
||||||
|
when {
|
||||||
|
OperatingSystem.current().isWindows -> "windows"
|
||||||
|
OperatingSystem.current().isMacOsX -> "mac"
|
||||||
|
OperatingSystem.current().isLinux -> "linux"
|
||||||
|
else -> {
|
||||||
|
logger.error("Unknown operating system for android tools: ${OperatingSystem.current().name}")
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
if (androidStudioRelease != null) {
|
||||||
|
ivy {
|
||||||
|
artifactPattern("https://dl.google.com/dl/android/studio/ide-zips/$androidStudioRelease/[artifact]-[revision]-$studioOs.zip")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maven { setUrl("$intellijRepo/$intellijReleaseType") }
|
||||||
|
maven { setUrl("https://plugins.jetbrains.com/maven") }
|
||||||
|
ivy {
|
||||||
|
artifactPattern("https://raw.github.com/JetBrains/intellij-community/[revision]/lib/src/[artifact].zip")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val intellij by configurations.creating
|
||||||
|
val intellijUltimate by configurations.creating
|
||||||
|
val sources by configurations.creating
|
||||||
|
val `asm-shaded-sources` by configurations.creating
|
||||||
|
val `jps-standalone` by configurations.creating
|
||||||
|
val `jps-build-test` by configurations.creating
|
||||||
|
val `intellij-core` by configurations.creating
|
||||||
|
val `plugins-NodeJS` by configurations.creating
|
||||||
|
|
||||||
|
val customDepsRepoDir = File(buildDir, "repo")
|
||||||
|
val customDepsOrg: String by rootProject.extra
|
||||||
|
val customDepsRevision = intellijVersion
|
||||||
|
val customDepsRepoModulesDir = File(customDepsRepoDir, "$customDepsOrg/$customDepsRevision")
|
||||||
|
val repoDir = customDepsRepoModulesDir
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
if (androidStudioRelease != null) {
|
||||||
|
intellij("google:android-studio-ide:$androidStudioBuild")
|
||||||
|
} else {
|
||||||
|
if (installIntellijCommunity) {
|
||||||
|
intellij("com.jetbrains.intellij.idea:ideaIC:$intellijVersion")
|
||||||
|
}
|
||||||
|
if (installIntellijUltimate) {
|
||||||
|
intellijUltimate("com.jetbrains.intellij.idea:ideaIU:$intellijVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sources("com.jetbrains.intellij.idea:ideaIC:$intellijVersion:sources@jar")
|
||||||
|
`asm-shaded-sources`("asmsources:asm-src:$platformBaseVersion@zip")
|
||||||
|
`jps-standalone`("com.jetbrains.intellij.idea:jps-standalone:$intellijVersion")
|
||||||
|
`jps-build-test`("com.jetbrains.intellij.idea:jps-build-test:$intellijVersion")
|
||||||
|
`intellij-core`("com.jetbrains.intellij.idea:intellij-core:$intellijVersion")
|
||||||
|
if (intellijUltimateEnabled) {
|
||||||
|
`plugins-NodeJS`("com.jetbrains.plugins:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}@zip")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Task.configureExtractFromConfigurationTask(sourceConfig: Configuration,
|
||||||
|
pathRemap: (String) -> String = { it },
|
||||||
|
extractor: (Configuration) -> Any) {
|
||||||
|
dependsOn(sourceConfig)
|
||||||
|
inputs.files(sourceConfig)
|
||||||
|
val targetDir = File(repoDir, sourceConfig.name)
|
||||||
|
outputs.dirs(targetDir)
|
||||||
|
doFirst {
|
||||||
|
project.copy {
|
||||||
|
from(extractor(sourceConfig))
|
||||||
|
into(targetDir)
|
||||||
|
eachFile {
|
||||||
|
path = pathRemap(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun removePathPrefix(path: String): String {
|
||||||
|
if (androidStudioRelease == null) return path
|
||||||
|
val slashes = if (studioOs == "mac") 2 else 1
|
||||||
|
var result = path
|
||||||
|
repeat(slashes) {
|
||||||
|
result = result.substringAfter('/')
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
val unzipIntellijSdk by tasks.creating {
|
||||||
|
configureExtractFromConfigurationTask(intellij, pathRemap = { removePathPrefix(it) }) {
|
||||||
|
zipTree(it.singleFile).matching {
|
||||||
|
exclude("**/plugins/Kotlin/**")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val unzipIntellijUltimateSdk by tasks.creating {
|
||||||
|
configureExtractFromConfigurationTask(intellijUltimate) {
|
||||||
|
zipTree(it.singleFile).matching {
|
||||||
|
exclude("plugins/Kotlin/**")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val unzipIntellijCore by tasks.creating { configureExtractFromConfigurationTask(`intellij-core`) { zipTree(it.singleFile) } }
|
||||||
|
|
||||||
|
val unzipJpsStandalone by tasks.creating { configureExtractFromConfigurationTask(`jps-standalone`) { zipTree(it.singleFile) } }
|
||||||
|
|
||||||
|
val copyAsmShadedSources by tasks.creating(Copy::class.java) {
|
||||||
|
from(`asm-shaded-sources`)
|
||||||
|
rename(".zip", ".jar")
|
||||||
|
destinationDir = File(repoDir, `asm-shaded-sources`.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
val copyIntellijSdkSources by tasks.creating(ShadowJar::class.java) {
|
||||||
|
from(copyAsmShadedSources)
|
||||||
|
from(sources)
|
||||||
|
baseName = "ideaIC"
|
||||||
|
version = intellijVersion
|
||||||
|
classifier = "sources"
|
||||||
|
destinationDir = File(repoDir, sources.name)
|
||||||
|
}
|
||||||
|
|
||||||
|
val copyJpsBuildTest by tasks.creating { configureExtractFromConfigurationTask(`jps-build-test`) { it.singleFile } }
|
||||||
|
|
||||||
|
val unzipNodeJSPlugin by tasks.creating { configureExtractFromConfigurationTask(`plugins-NodeJS`) { zipTree(it.singleFile) } }
|
||||||
|
|
||||||
|
fun writeIvyXml(moduleName: String, fileName: String, jarFiles: FileCollection, baseDir: File, sourcesJar: File?) {
|
||||||
|
with(IvyDescriptorFileGenerator(DefaultIvyPublicationIdentity(customDepsOrg, moduleName, intellijVersion))) {
|
||||||
|
addConfiguration(DefaultIvyConfiguration("default"))
|
||||||
|
addConfiguration(DefaultIvyConfiguration("sources"))
|
||||||
|
jarFiles.asFileTree.files.forEach {
|
||||||
|
if (it.isFile && it.extension == "jar") {
|
||||||
|
val relativeName = it.toRelativeString(baseDir).removeSuffix(".jar")
|
||||||
|
addArtifact(DefaultIvyArtifact(it, relativeName, "jar", "jar", null).also { it.conf = "default" })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sourcesJar != null) {
|
||||||
|
val sourcesArtifactName = sourcesJar.name.removeSuffix(".jar").substringBefore("-")
|
||||||
|
addArtifact(DefaultIvyArtifact(sourcesJar, sourcesArtifactName, "jar", "sources", "sources").also { it.conf = "sources" })
|
||||||
|
}
|
||||||
|
writeTo(File(customDepsRepoModulesDir, "$fileName.ivy.xml"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val prepareIvyXmls by tasks.creating {
|
||||||
|
dependsOn(unzipIntellijCore, unzipJpsStandalone, copyIntellijSdkSources, copyJpsBuildTest, copyAsmShadedSources)
|
||||||
|
|
||||||
|
val intellijSdkDir = File(repoDir, intellij.name)
|
||||||
|
val intellijUltimateSdkDir = File(repoDir, intellijUltimate.name)
|
||||||
|
|
||||||
|
if (installIntellijCommunity) {
|
||||||
|
dependsOn(unzipIntellijSdk)
|
||||||
|
inputs.dir(intellijSdkDir)
|
||||||
|
outputs.file(File(repoDir, "${intellij.name}.ivy.xml"))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (installIntellijUltimate) {
|
||||||
|
dependsOn(unzipIntellijUltimateSdk)
|
||||||
|
inputs.dir(intellijUltimateSdkDir)
|
||||||
|
outputs.file(File(repoDir, "${intellijUltimate.name}.ivy.xml"))
|
||||||
|
}
|
||||||
|
|
||||||
|
val flatDeps = listOf(`intellij-core`, `jps-standalone`, `jps-build-test`, `asm-shaded-sources`)
|
||||||
|
flatDeps.forEach {
|
||||||
|
inputs.dir(File(repoDir, it.name))
|
||||||
|
outputs.file(File(repoDir, "${it.name}.ivy.xml"))
|
||||||
|
}
|
||||||
|
inputs.dir(File(repoDir, sources.name))
|
||||||
|
|
||||||
|
if (intellijUltimateEnabled) {
|
||||||
|
dependsOn(unzipNodeJSPlugin)
|
||||||
|
inputs.dir(File(repoDir, `plugins-NodeJS`.name))
|
||||||
|
outputs.file(File(repoDir, "${`plugins-NodeJS`.name}.ivy.xml"))
|
||||||
|
}
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
val sourcesFile = if (sources.isEmpty) null else File(repoDir, "${sources.name}/${sources.singleFile.name}")
|
||||||
|
|
||||||
|
if (installIntellijCommunity) {
|
||||||
|
val libDir = File(intellijSdkDir, "lib")
|
||||||
|
writeIvyXml(intellij.name,
|
||||||
|
intellij.name,
|
||||||
|
fileTree(libDir).filter {
|
||||||
|
it.parentFile == libDir && !it.name.startsWith("kotlin-")
|
||||||
|
},
|
||||||
|
libDir,
|
||||||
|
sourcesFile)
|
||||||
|
|
||||||
|
File(intellijSdkDir, "plugins").listFiles { it: File -> it.isDirectory }.forEach {
|
||||||
|
writeIvyXml(it.name, "intellij.plugin.${it.name}", files("$it/lib/"), File(it, "lib"), sourcesFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (installIntellijUltimate) {
|
||||||
|
val libDir = File(intellijUltimateSdkDir, "lib")
|
||||||
|
writeIvyXml(intellij.name, // important! the module name should be "intellij"
|
||||||
|
intellijUltimate.name,
|
||||||
|
fileTree(libDir).filter {
|
||||||
|
it.parentFile == libDir && !it.name.startsWith("kotlin-")
|
||||||
|
},
|
||||||
|
libDir,
|
||||||
|
sourcesFile)
|
||||||
|
|
||||||
|
File(intellijUltimateSdkDir, "plugins").listFiles { it: File -> it.isDirectory }.forEach {
|
||||||
|
writeIvyXml(it.name, "intellijUltimate.plugin.${it.name}", files("$it/lib/"), File(it, "lib"), sourcesFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flatDeps.forEach {
|
||||||
|
writeIvyXml(it.name, it.name, files("$repoDir/${it.name}"), File(repoDir, it.name), sourcesFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intellijUltimateEnabled) {
|
||||||
|
val nodeJsBaseDir = "${`plugins-NodeJS`.name}/NodeJS/lib"
|
||||||
|
writeIvyXml("NodeJS", `plugins-NodeJS`.name, files("$repoDir/$nodeJsBaseDir"), File(repoDir, nodeJsBaseDir), sourcesFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val build by tasks.creating {
|
||||||
|
dependsOn(prepareIvyXmls)
|
||||||
|
}
|
||||||
|
|
||||||
|
val clean by tasks.creating(Delete::class) {
|
||||||
|
delete(customDepsRepoModulesDir)
|
||||||
|
delete(buildDir)
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
extra["versions.intellijSdk"] = "181.4203.6"
|
||||||
|
extra["versions.androidBuildTools"] = "r23.0.1"
|
||||||
|
extra["versions.idea.NodeJS"] = "181.3494.12"
|
||||||
|
//extra["versions.androidStudioRelease"] = "3.1.0.5"
|
||||||
|
//extra["versions.androidStudioBuild"] = "173.4506631"
|
||||||
|
|
||||||
|
val gradleJars = listOf(
|
||||||
|
"gradle-api",
|
||||||
|
"gradle-tooling-api",
|
||||||
|
"gradle-base-services",
|
||||||
|
"gradle-wrapper",
|
||||||
|
"gradle-core",
|
||||||
|
"gradle-base-services-groovy"
|
||||||
|
)
|
||||||
|
|
||||||
|
val androidStudioVersion = if (extra.has("versions.androidStudioRelease"))
|
||||||
|
extra["versions.androidStudioRelease"]?.toString()?.replace(".", "")?.substring(0, 2)
|
||||||
|
else
|
||||||
|
null
|
||||||
|
|
||||||
|
val intellijVersion = rootProject.extra["versions.intellijSdk"] as String
|
||||||
|
val intellijVersionDelimiterIndex = intellijVersion.indexOfAny(charArrayOf('.', '-'))
|
||||||
|
if (intellijVersionDelimiterIndex == -1) {
|
||||||
|
error("Invalid IDEA version $intellijVersion")
|
||||||
|
}
|
||||||
|
|
||||||
|
val platformBaseVersion = intellijVersion.substring(0, intellijVersionDelimiterIndex)
|
||||||
|
val platform = androidStudioVersion?.let { "AS$it" } ?: platformBaseVersion
|
||||||
|
|
||||||
|
when (platform) {
|
||||||
|
"181" -> {
|
||||||
|
extra["versions.jar.guava"] = "21.0"
|
||||||
|
extra["versions.jar.groovy-all"] = "2.4.12"
|
||||||
|
extra["versions.jar.lombok-ast"] = "0.2.3"
|
||||||
|
extra["versions.jar.swingx-core"] = "1.6.2-2"
|
||||||
|
extra["versions.jar.kxml2"] = "2.3.0"
|
||||||
|
extra["versions.jar.streamex"] = "0.6.5"
|
||||||
|
extra["versions.jar.gson"] = "2.8.2"
|
||||||
|
extra["versions.jar.oro"] = "2.0.8"
|
||||||
|
for (jar in gradleJars) {
|
||||||
|
extra["versions.jar.$jar"] = "4.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"173" -> {
|
||||||
|
extra["versions.jar.guava"] = "21.0"
|
||||||
|
extra["versions.jar.groovy-all"] = "2.4.12"
|
||||||
|
extra["versions.jar.lombok-ast"] = "0.2.3"
|
||||||
|
extra["versions.jar.swingx-core"] = "1.6.2"
|
||||||
|
extra["versions.jar.kxml2"] = "2.3.0"
|
||||||
|
extra["versions.jar.streamex"] = "0.6.5"
|
||||||
|
extra["versions.jar.gson"] = "2.8.2"
|
||||||
|
for (jar in gradleJars) {
|
||||||
|
extra["versions.jar.$jar"] = "4.0"
|
||||||
|
}
|
||||||
|
extra["ignore.jar.lombok-ast-0.2.3"] = true
|
||||||
|
}
|
||||||
|
"172" -> {
|
||||||
|
extra["versions.jar.guava"] = "21.0"
|
||||||
|
extra["versions.jar.groovy-all"] = "2.4.6"
|
||||||
|
extra["versions.jar.lombok-ast"] = "0.2.3"
|
||||||
|
extra["versions.jar.swingx-core"] = "1.6.2"
|
||||||
|
extra["versions.jar.kxml2"] = "2.3.0"
|
||||||
|
extra["versions.jar.streamex"] = "0.6.2"
|
||||||
|
extra["versions.jar.gson"] = "2.5"
|
||||||
|
for (jar in gradleJars) {
|
||||||
|
extra["versions.jar.$jar"] = "3.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"171" -> {
|
||||||
|
extra["versions.jar.guava"] = "19.0"
|
||||||
|
extra["versions.jar.groovy-all"] = "2.4.6"
|
||||||
|
extra["versions.jar.lombok-ast"] = "0.2.3"
|
||||||
|
extra["versions.jar.swingx-core"] = "1.6.2"
|
||||||
|
extra["versions.jar.kxml2"] = "2.3.0"
|
||||||
|
extra["versions.jar.streamex"] = "0.6.2"
|
||||||
|
extra["versions.jar.gson"] = "2.5"
|
||||||
|
for (jar in gradleJars) {
|
||||||
|
extra["versions.jar.$jar"] = "3.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"AS30" -> {
|
||||||
|
extra["versions.jar.guava"] = "19.0"
|
||||||
|
extra["versions.jar.groovy-all"] = "2.4.6"
|
||||||
|
extra["versions.jar.lombok-ast"] = "0.2.3"
|
||||||
|
extra["versions.jar.swingx-core"] = "1.6.2"
|
||||||
|
extra["versions.jar.kxml2"] = "2.3.0"
|
||||||
|
extra["versions.jar.streamex"] = "0.6.2"
|
||||||
|
extra["versions.jar.gson"] = "2.5"
|
||||||
|
for (jar in gradleJars) {
|
||||||
|
extra["versions.jar.$jar"] = "3.5"
|
||||||
|
}
|
||||||
|
|
||||||
|
extra["ignore.jar.common"] = true
|
||||||
|
}
|
||||||
|
"AS31" -> {
|
||||||
|
extra["versions.jar.guava"] = "21.0"
|
||||||
|
extra["versions.jar.groovy-all"] = "2.4.12"
|
||||||
|
extra["versions.jar.swingx-core"] = "1.6.2"
|
||||||
|
extra["versions.jar.kxml2"] = "2.3.0"
|
||||||
|
extra["versions.jar.streamex"] = "0.6.5"
|
||||||
|
extra["versions.jar.gson"] = "2.8.2"
|
||||||
|
for (jar in gradleJars) {
|
||||||
|
extra["versions.jar.$jar"] = "4.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
extra["ignore.jar.common"] = true
|
||||||
|
extra["ignore.jar.lombok-ast"] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extra.has("versions.androidStudioRelease")) {
|
||||||
|
extra["ignore.jar.android-base-common"] = true
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user