Add a new module for scripting compilation infrastructure...
add embeddable variant as well
This commit is contained in:
@@ -212,14 +212,16 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
// try to find and enable it implicitly
|
||||
if (!explicitOrLoadedScriptingPlugin) {
|
||||
val libPath = PathUtil.kotlinPathsForCompiler.libPath.takeIf { it.exists() && it.isDirectory } ?: File(".")
|
||||
with(PathUtil) {
|
||||
val jars = arrayOf(
|
||||
KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR, KOTLIN_SCRIPTING_IMPL_JAR,
|
||||
KOTLIN_SCRIPTING_COMMON_JAR, KOTLIN_SCRIPTING_JVM_JAR
|
||||
).mapNotNull { File(libPath, it).takeIf { it.exists() }?.canonicalPath }
|
||||
if (jars.size == 4) {
|
||||
pluginClasspaths = jars + pluginClasspaths
|
||||
}
|
||||
val (jars, missingJars) =
|
||||
PathUtil.KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS.mapNotNull { File(libPath, it) }.partition { it.exists() }
|
||||
if (missingJars.isEmpty()) {
|
||||
pluginClasspaths = jars.map { it.canonicalPath } + pluginClasspaths
|
||||
} else {
|
||||
val messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
messageCollector.report(
|
||||
LOGGING,
|
||||
"Scripting plugin will not be loaded: not all required jars are present in the classpath (missing files: $missingJars)"
|
||||
)
|
||||
}
|
||||
}
|
||||
if (arguments.scriptTemplates?.isNotEmpty() == true) {
|
||||
|
||||
@@ -67,10 +67,15 @@ object PathUtil {
|
||||
const val KOTLIN_SCRIPTING_JVM_JAR = "$KOTLIN_SCRIPTING_JVM_NAME.jar"
|
||||
const val KOTLIN_SCRIPTING_COMPILER_PLUGIN_NAME = "kotlin-scripting-compiler"
|
||||
const val KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR = "$KOTLIN_SCRIPTING_COMPILER_PLUGIN_NAME.jar"
|
||||
const val KOTLIN_SCRIPTING_IMPL_NAME = "kotlin-scripting-impl"
|
||||
const val KOTLIN_SCRIPTING_IMPL_JAR = "$KOTLIN_SCRIPTING_IMPL_NAME.jar"
|
||||
const val KOTLINX_COROUTINES_CORE_NAME = "kotlinx-coroutines-core"
|
||||
const val KOTLINX_COROUTINES_CORE_JAR = "$KOTLINX_COROUTINES_CORE_NAME.jar"
|
||||
const val KOTLIN_SCRIPTING_COMPILER_IMPL_NAME = "kotlin-scripting-compiler-impl"
|
||||
const val KOTLIN_SCRIPTING_COMPILER_IMPL_JAR = "$KOTLIN_SCRIPTING_COMPILER_IMPL_NAME.jar"
|
||||
|
||||
val KOTLIN_SCRIPTING_PLUGIN_CLASSPATH_JARS = arrayOf(
|
||||
KOTLIN_SCRIPTING_COMPILER_PLUGIN_JAR, KOTLIN_SCRIPTING_COMPILER_IMPL_JAR,
|
||||
KOTLIN_SCRIPTING_COMMON_JAR, KOTLIN_SCRIPTING_JVM_JAR
|
||||
)
|
||||
|
||||
const val KOTLIN_TEST_NAME = "kotlin-test"
|
||||
const val KOTLIN_TEST_JAR = "$KOTLIN_TEST_NAME.jar"
|
||||
|
||||
@@ -25,6 +25,8 @@ internal const val TROVE4J_JAR = "trove4j.jar"
|
||||
internal const val KOTLIN_SCRIPTING_COMPILER_JAR = "kotlin-scripting-compiler.jar"
|
||||
internal const val KOTLIN_SCRIPTING_COMPILER_EMBEDDABLE_JAR = "kotlin-scripting-compiler-embeddable.jar"
|
||||
internal const val KOTLIN_SCRIPTING_IMPL_JAR = "kotlin-scripting-impl.jar"
|
||||
internal const val KOTLIN_SCRIPTING_COMPILER_IMPL_JAR = "kotlin-scripting-compiler-impl.jar"
|
||||
internal const val KOTLIN_SCRIPTING_COMPILER_IMPL_EMBEDDABLE_JAR = "kotlin-scripting-compiler-impl-embeddable.jar"
|
||||
internal const val KOTLIN_SCRIPTING_COMMON_JAR = "kotlin-scripting-common.jar"
|
||||
internal const val KOTLIN_SCRIPTING_JVM_JAR = "kotlin-scripting-jvm.jar"
|
||||
|
||||
@@ -205,6 +207,8 @@ object KotlinJars {
|
||||
KOTLIN_SCRIPTING_COMPILER_JAR,
|
||||
KOTLIN_SCRIPTING_IMPL_JAR,
|
||||
KOTLIN_SCRIPTING_COMPILER_EMBEDDABLE_JAR,
|
||||
KOTLIN_SCRIPTING_COMPILER_IMPL_JAR,
|
||||
KOTLIN_SCRIPTING_COMPILER_IMPL_EMBEDDABLE_JAR,
|
||||
KOTLIN_SCRIPTING_COMMON_JAR,
|
||||
KOTLIN_SCRIPTING_JVM_JAR
|
||||
) else emptyList()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.jetbrains.kotlin.pill.PillExtension.Variant
|
||||
|
||||
plugins { java }
|
||||
|
||||
@@ -9,8 +8,8 @@ val packedJars by configurations.creating
|
||||
dependencies {
|
||||
packedJars(project(":kotlin-scripting-impl")) { isTransitive = false }
|
||||
packedJars(project(":kotlin-scripting-compiler")) { isTransitive = false }
|
||||
packedJars(project(":kotlin-scripting-common")) { isTransitive = false }
|
||||
packedJars(project(":kotlin-scripting-jvm")) { isTransitive = false }
|
||||
runtime(project(":kotlin-scripting-compiler-impl-embeddable"))
|
||||
runtime(kotlinStdlib())
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins { java }
|
||||
|
||||
description = "Kotlin Compiler Infrastructure for Scripting for embeddable compiler"
|
||||
|
||||
val packedJars by configurations.creating
|
||||
dependencies {
|
||||
packedJars(project(":kotlin-scripting-compiler-impl")) { isTransitive = false }
|
||||
runtime(project(":kotlin-scripting-common"))
|
||||
runtime(project(":kotlin-scripting-jvm"))
|
||||
runtime(kotlinStdlib())
|
||||
runtime(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
noDefaultJar()
|
||||
runtimeJar(rewriteDepsToShadedCompiler(
|
||||
task<ShadowJar>("shadowJar") {
|
||||
from(packedJars)
|
||||
}
|
||||
))
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
description = "Kotlin Compiler Infrastructure for Scripting"
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":compiler:frontend"))
|
||||
compileOnly(project(":compiler:frontend.java"))
|
||||
compileOnly(project(":compiler:psi"))
|
||||
compileOnly(project(":compiler:plugin-api"))
|
||||
compileOnly(project(":compiler:cli"))
|
||||
compile(project(":kotlin-scripting-common"))
|
||||
compile(project(":kotlin-scripting-jvm"))
|
||||
compile(kotlinStdlib())
|
||||
compileOnly(project(":kotlin-reflect-api"))
|
||||
compile(commonDep("org.jetbrains.kotlinx", "kotlinx-coroutines-core")) { isTransitive = false }
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
compileOnly(intellijDep()) { includeJars("asm-all", rootProject = rootProject) }
|
||||
|
||||
testCompile(project(":compiler:frontend"))
|
||||
testCompile(project(":compiler:plugin-api"))
|
||||
testCompile(project(":compiler:util"))
|
||||
testCompile(project(":compiler:cli"))
|
||||
testCompile(project(":compiler:cli-common"))
|
||||
testCompile(project(":compiler:frontend.java"))
|
||||
testCompile(projectTests(":compiler:tests-common"))
|
||||
testCompile(commonDep("junit:junit"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.3"
|
||||
apiVersion = "1.3"
|
||||
freeCompilerArgs += "-Xskip-metadata-version-check"
|
||||
}
|
||||
}
|
||||
|
||||
publish()
|
||||
|
||||
val jar = runtimeJar {}
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
dist()
|
||||
|
||||
ideaPlugin()
|
||||
|
||||
projectTest {
|
||||
workingDir = rootDir
|
||||
}
|
||||
+5
-1
@@ -175,8 +175,10 @@ include ":kotlin-build-common",
|
||||
":kotlin-scripting-intellij",
|
||||
":kotlin-scripting-impl",
|
||||
":kotlin-scripting-compiler",
|
||||
":kotlin-scripting-idea",
|
||||
":kotlin-scripting-compiler-embeddable",
|
||||
":kotlin-scripting-compiler-impl",
|
||||
":kotlin-scripting-compiler-impl-embeddable",
|
||||
":kotlin-scripting-idea",
|
||||
":kotlin-main-kts",
|
||||
":kotlin-main-kts-test",
|
||||
":examples:scripting-jvm-simple-script",
|
||||
@@ -340,6 +342,8 @@ project(':kotlin-scripting-intellij').projectDir = "$rootDir/libraries/scripting
|
||||
project(':kotlin-scripting-impl').projectDir = "$rootDir/plugins/scripting/scripting-impl" as File
|
||||
project(':kotlin-scripting-compiler').projectDir = "$rootDir/plugins/scripting/scripting-compiler" as File
|
||||
project(':kotlin-scripting-compiler-embeddable').projectDir = "$rootDir/plugins/scripting/scripting-compiler-embeddable" as File
|
||||
project(':kotlin-scripting-compiler-impl').projectDir = "$rootDir/plugins/scripting/scripting-compiler-impl" as File
|
||||
project(':kotlin-scripting-compiler-impl-embeddable').projectDir = "$rootDir/plugins/scripting/scripting-compiler-impl-embeddable" as File
|
||||
project(':kotlin-scripting-idea').projectDir = "$rootDir/plugins/scripting/scripting-idea" as File
|
||||
project(':kotlin-main-kts').projectDir = "$rootDir/libraries/tools/kotlin-main-kts" as File
|
||||
project(':kotlin-main-kts-test').projectDir = "$rootDir/libraries/tools/kotlin-main-kts-test" as File
|
||||
|
||||
Reference in New Issue
Block a user