use bootstrap.kotlin.default.version bootstrap for buildSrc
This commit is contained in:
@@ -9,6 +9,9 @@ import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import javax.xml.stream.XMLOutputFactory
|
||||
|
||||
import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore
|
||||
import org.jetbrains.kotlin.gradle.tasks.CleanDataTask
|
||||
|
||||
plugins {
|
||||
base
|
||||
}
|
||||
@@ -105,7 +108,7 @@ val nodeJSPlugin by configurations.creating
|
||||
val intellijRuntimeAnnotations = "intellij-runtime-annotations"
|
||||
|
||||
val dependenciesDir = (findProperty("kotlin.build.dependencies.dir") as String?)?.let(::File)
|
||||
?: rootProject.rootDir.parentFile.resolve("dependencies")
|
||||
?: rootProject.gradle.gradleUserHomeDir.resolve("kotlin-build-dependencies")
|
||||
|
||||
val customDepsRepoDir = dependenciesDir.resolve("repo")
|
||||
|
||||
@@ -142,14 +145,29 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
val makeIntellijCore = buildIvyRepositoryTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
||||
|
||||
val cleanupIntellijCore = tasks.register<CleanDataTask>("cleanupIntellijCore") {
|
||||
cleanableStoreProvider = provider { CleanableStore[repoDir.resolve("intellij-core").absolutePath] }
|
||||
}
|
||||
|
||||
val cleanupIntellijAnnotation = tasks.register<CleanDataTask>("cleanupIntellijAnnotation") {
|
||||
cleanableStoreProvider = provider { CleanableStore[repoDir.resolve(intellijRuntimeAnnotations).absolutePath] }
|
||||
}
|
||||
|
||||
val cleanupDependencies = tasks.register("cleanupDependencies") {
|
||||
dependsOn(cleanupIntellijCore)
|
||||
dependsOn(cleanupIntellijAnnotation)
|
||||
}
|
||||
|
||||
val makeIntellijCore = buildIvyRepositoryTaskAndRegisterCleanupTask(intellijCore, customDepsOrg, customDepsRepoDir)
|
||||
|
||||
val makeIntellijAnnotations by tasks.registering(Copy::class) {
|
||||
dependsOn(makeIntellijCore)
|
||||
|
||||
from(repoDir.resolve("intellij-core/$intellijVersion/artifacts/annotations.jar"))
|
||||
val intellijCoreRepo = CleanableStore[repoDir.resolve("intellij-core").absolutePath][intellijVersion].use()
|
||||
from(intellijCoreRepo.resolve("artifacts/annotations.jar"))
|
||||
|
||||
val targetDir = File(repoDir, "$intellijRuntimeAnnotations/$intellijVersion")
|
||||
val targetDir = CleanableStore[repoDir.resolve(intellijRuntimeAnnotations).absolutePath][intellijVersion].use()
|
||||
into(targetDir)
|
||||
|
||||
val ivyFile = File(targetDir, "$intellijRuntimeAnnotations.ivy.xml")
|
||||
@@ -181,20 +199,20 @@ val mergeSources by tasks.creating(Jar::class.java) {
|
||||
val sourcesFile = mergeSources.outputs.files.singleFile
|
||||
|
||||
val makeIde = if (androidStudioBuild != null) {
|
||||
buildIvyRepositoryTask(
|
||||
buildIvyRepositoryTaskAndRegisterCleanupTask(
|
||||
androidStudio,
|
||||
customDepsOrg,
|
||||
customDepsRepoDir,
|
||||
if (androidStudioOs == "mac")
|
||||
::skipContentsDirectory
|
||||
else
|
||||
::skipContentsDirectory
|
||||
else
|
||||
::skipToplevelDirectory
|
||||
)
|
||||
} else {
|
||||
val task = if (installIntellijUltimate) {
|
||||
buildIvyRepositoryTask(intellijUltimate, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
buildIvyRepositoryTaskAndRegisterCleanupTask(intellijUltimate, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
} else {
|
||||
buildIvyRepositoryTask(intellij, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
buildIvyRepositoryTaskAndRegisterCleanupTask(intellij, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
}
|
||||
|
||||
task.configure {
|
||||
@@ -204,8 +222,7 @@ val makeIde = if (androidStudioBuild != null) {
|
||||
task
|
||||
}
|
||||
|
||||
val buildJpsStandalone = buildIvyRepositoryTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
val buildNodeJsPlugin = buildIvyRepositoryTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
|
||||
val buildJpsStandalone = buildIvyRepositoryTaskAndRegisterCleanupTask(jpsStandalone, customDepsOrg, customDepsRepoDir, null, sourcesFile)
|
||||
|
||||
tasks.named("build") {
|
||||
dependsOn(
|
||||
@@ -215,11 +232,16 @@ tasks.named("build") {
|
||||
makeIntellijAnnotations
|
||||
)
|
||||
|
||||
if (installIntellijUltimate) {
|
||||
dependsOn(buildNodeJsPlugin)
|
||||
}
|
||||
}
|
||||
|
||||
if (installIntellijUltimate) {
|
||||
val buildNodeJsPlugin =
|
||||
buildIvyRepositoryTaskAndRegisterCleanupTask(nodeJSPlugin, customDepsOrg, customDepsRepoDir, ::skipToplevelDirectory, sourcesFile)
|
||||
tasks.named("build") { dependsOn(buildNodeJsPlugin) }
|
||||
}
|
||||
|
||||
tasks.named("build") { dependsOn(cleanupDependencies) }
|
||||
|
||||
// Task to delete legacy repo locations
|
||||
tasks.register<Delete>("cleanLegacy") {
|
||||
delete("$projectDir/android-dx")
|
||||
@@ -227,93 +249,114 @@ tasks.register<Delete>("cleanLegacy") {
|
||||
}
|
||||
|
||||
tasks.named<Delete>("clean") {
|
||||
//TODO specify repos to clean? Use CleanDataTask
|
||||
delete(customDepsRepoDir)
|
||||
}
|
||||
|
||||
fun buildIvyRepositoryTask(
|
||||
fun buildIvyRepositoryTaskAndRegisterCleanupTask(
|
||||
configuration: Configuration,
|
||||
organization: String,
|
||||
repoDirectory: File,
|
||||
pathRemap: ((String) -> String)? = null,
|
||||
sources: File? = null
|
||||
) = tasks.register("buildIvyRepositoryFor${configuration.name.capitalize()}") {
|
||||
): TaskProvider<Task> {
|
||||
fun ResolvedArtifact.storeDirectory(): CleanableStore =
|
||||
CleanableStore[repoDirectory.resolve("$organization/${moduleVersion.id.name}").absolutePath]
|
||||
|
||||
fun ResolvedArtifact.moduleDirectory(): File =
|
||||
File(repoDirectory, "$organization/${moduleVersion.id.name}/${moduleVersion.id.version}")
|
||||
storeDirectory()[moduleVersion.id.version].use()
|
||||
|
||||
dependsOn(configuration)
|
||||
inputs.files(configuration)
|
||||
val buildIvyRepositoryTask = tasks.register("buildIvyRepositoryFor${configuration.name.capitalize()}") {
|
||||
dependsOn(configuration)
|
||||
inputs.files(configuration)
|
||||
|
||||
if (verifyDependencyOutput) {
|
||||
outputs.dir(provider {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single().moduleDirectory()
|
||||
})
|
||||
} else {
|
||||
outputs.upToDateWhen {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single()
|
||||
.moduleDirectory()
|
||||
.exists()
|
||||
}
|
||||
}
|
||||
|
||||
doFirst {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single().run {
|
||||
val moduleDirectory = moduleDirectory()
|
||||
val artifactsDirectory = File(moduleDirectory(), "artifacts")
|
||||
|
||||
logger.info("Unpacking ${file.name} into ${artifactsDirectory.absolutePath}")
|
||||
copy {
|
||||
val fileTree = when (extension) {
|
||||
"tar.gz" -> tarTree(file)
|
||||
"zip" -> zipTree(file)
|
||||
else -> error("Unsupported artifact extension: $extension")
|
||||
if (verifyDependencyOutput) {
|
||||
outputs.dir(
|
||||
provider {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single().moduleDirectory()
|
||||
}
|
||||
|
||||
from(fileTree.matching {
|
||||
exclude("**/plugins/Kotlin/**")
|
||||
})
|
||||
|
||||
into(artifactsDirectory)
|
||||
|
||||
if (pathRemap != null) {
|
||||
eachFile {
|
||||
path = pathRemap(path)
|
||||
}
|
||||
}
|
||||
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
|
||||
writeIvyXml(
|
||||
organization,
|
||||
moduleVersion.id.name,
|
||||
moduleVersion.id.version,
|
||||
moduleVersion.id.name,
|
||||
File(artifactsDirectory, "lib"),
|
||||
File(artifactsDirectory, "lib"),
|
||||
File(moduleDirectory, "ivy"),
|
||||
*listOfNotNull(sources).toTypedArray()
|
||||
)
|
||||
} else {
|
||||
outputs.upToDateWhen {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single()
|
||||
.moduleDirectory()
|
||||
.exists()
|
||||
}
|
||||
}
|
||||
|
||||
val pluginsDirectory = File(artifactsDirectory, "plugins")
|
||||
if (pluginsDirectory.exists()) {
|
||||
file(File(artifactsDirectory, "plugins"))
|
||||
.listFiles { file: File -> file.isDirectory }
|
||||
.forEach {
|
||||
writeIvyXml(
|
||||
organization,
|
||||
it.name,
|
||||
moduleVersion.id.version,
|
||||
it.name,
|
||||
File(it, "lib"),
|
||||
File(it, "lib"),
|
||||
File(moduleDirectory, "ivy"),
|
||||
*listOfNotNull(sources).toTypedArray()
|
||||
)
|
||||
doFirst {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single().run {
|
||||
val moduleDirectory = moduleDirectory()
|
||||
val artifactsDirectory = File(moduleDirectory(), "artifacts")
|
||||
|
||||
logger.info("Unpacking ${file.name} into ${artifactsDirectory.absolutePath}")
|
||||
copy {
|
||||
val fileTree = when (extension) {
|
||||
"tar.gz" -> tarTree(file)
|
||||
"zip" -> zipTree(file)
|
||||
else -> error("Unsupported artifact extension: $extension")
|
||||
}
|
||||
|
||||
from(
|
||||
fileTree.matching {
|
||||
exclude("**/plugins/Kotlin/**")
|
||||
}
|
||||
)
|
||||
|
||||
into(artifactsDirectory)
|
||||
|
||||
if (pathRemap != null) {
|
||||
eachFile {
|
||||
path = pathRemap(path)
|
||||
}
|
||||
}
|
||||
|
||||
includeEmptyDirs = false
|
||||
}
|
||||
|
||||
writeIvyXml(
|
||||
organization,
|
||||
moduleVersion.id.name,
|
||||
moduleVersion.id.version,
|
||||
moduleVersion.id.name,
|
||||
File(artifactsDirectory, "lib"),
|
||||
File(artifactsDirectory, "lib"),
|
||||
File(moduleDirectory, "ivy"),
|
||||
*listOfNotNull(sources).toTypedArray()
|
||||
)
|
||||
|
||||
val pluginsDirectory = File(artifactsDirectory, "plugins")
|
||||
if (pluginsDirectory.exists()) {
|
||||
file(File(artifactsDirectory, "plugins"))
|
||||
.listFiles { file: File -> file.isDirectory }
|
||||
.forEach {
|
||||
writeIvyXml(
|
||||
organization,
|
||||
it.name,
|
||||
moduleVersion.id.version,
|
||||
it.name,
|
||||
File(it, "lib"),
|
||||
File(it, "lib"),
|
||||
File(moduleDirectory, "ivy"),
|
||||
*listOfNotNull(sources).toTypedArray()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val cleanupIvyRepositoryTask = tasks.register<CleanDataTask>("cleanupIvyRepositoryFor${configuration.name.capitalize()}") {
|
||||
cleanableStoreProvider = provider {
|
||||
configuration.resolvedConfiguration.resolvedArtifacts.single().storeDirectory()
|
||||
}
|
||||
}
|
||||
|
||||
cleanupDependencies {
|
||||
dependsOn(cleanupIvyRepositoryTask)
|
||||
}
|
||||
|
||||
return buildIvyRepositoryTask
|
||||
}
|
||||
|
||||
fun writeIvyXml(
|
||||
|
||||
Reference in New Issue
Block a user