Files
kotlin-fork/prepare/compiler-embeddable/build.gradle.kts
T
Yahor Berdnikau e25778a719 Fix ConcurrentModificationException
This exception is happening on build configuration trying to remove
default jar task artifacts from published one. I've set 'jar' task
to be always disabled instead and just add shadow jar to artifacts.
2022-05-24 07:58:36 +00:00

84 lines
2.8 KiB
Kotlin

import java.util.stream.Collectors
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext
import org.gradle.kotlin.dsl.support.serviceOf
import shadow.org.apache.tools.zip.ZipEntry
import shadow.org.apache.tools.zip.ZipOutputStream
description = "Kotlin Compiler (embeddable)"
plugins {
kotlin("jvm")
}
val testCompilationClasspath by configurations.creating
val testCompilerClasspath by configurations.creating {
isCanBeConsumed = false
extendsFrom(configurations["runtimeElements"])
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
}
}
dependencies {
runtimeOnly(kotlinStdlib())
runtimeOnly(project(":kotlin-script-runtime"))
runtimeOnly(project(":kotlin-reflect"))
runtimeOnly(project(":kotlin-daemon-embeddable"))
runtimeOnly(commonDependency("org.jetbrains.intellij.deps", "trove4j"))
Platform[203].orHigher {
runtimeOnly(commonDependency("net.java.dev.jna", "jna"))
}
testApi(commonDependency("junit:junit"))
testApi(project(":kotlin-test:kotlin-test-junit"))
testCompilationClasspath(kotlinStdlib())
}
sourceSets {
"main" {}
"test" { projectDefault() }
}
// dummy is used for rewriting dependencies to the shaded packages in the embeddable compiler
compilerDummyJar(compilerDummyForDependenciesRewriting("compilerDummy") {
archiveClassifier.set("dummy")
})
val runtimeJar = runtimeJar(embeddableCompiler()) {
exclude("com/sun/jna/**")
exclude("org/jetbrains/annotations/**")
mergeServiceFiles()
}
publish {
setArtifacts(listOf(runtimeJar))
}
sourcesJar {
val compilerTask = project(":kotlin-compiler").tasks.named<Jar>("sourcesJar")
dependsOn(compilerTask)
val archiveOperations = serviceOf<ArchiveOperations>()
from(compilerTask.map { it.archiveFile }.map { archiveOperations.zipTree(it) })
}
javadocJar {
val compilerTask = project(":kotlin-compiler").tasks.named<Jar>("javadocJar")
dependsOn(compilerTask)
val archiveOperations = serviceOf<ArchiveOperations>()
from(compilerTask.map { it.archiveFile }.map { archiveOperations.zipTree(it) })
}
projectTest {
dependsOn(runtimeJar)
val testCompilerClasspathProvider = project.provider { testCompilerClasspath.asPath }
val testCompilationClasspathProvider = project.provider { testCompilationClasspath.asPath }
val runtimeJarPathProvider = project.provider { runtimeJar.get().outputs.files.asPath }
doFirst {
systemProperty("compilerClasspath", "${runtimeJarPathProvider.get()}${File.pathSeparator}${testCompilerClasspathProvider.get()}")
systemProperty("compilationClasspath", testCompilationClasspathProvider.get())
}
}