Create task to run kotlin scripts and use it to strip metadata.

This commit is contained in:
Ilya Gorbunov
2017-03-27 04:39:42 +03:00
parent 65a800840c
commit d1d62d557d
2 changed files with 51 additions and 25 deletions
+29 -1
View File
@@ -2,12 +2,13 @@
buildscript {
ext.kotlin_version = "1.1-SNAPSHOT"
ext.kotlin_language_version = "1.1"
ext.kotlin_gradle_plugin_version = "1.1.1"
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_gradle_plugin_version}"
}
}
@@ -29,6 +30,15 @@ subprojects {
mavenCentral()
}
configurations {
scriptCompile
scriptRuntime.extendsFrom(scriptCompile)
}
dependencies {
scriptCompile "org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlin_gradle_plugin_version}"
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile) {
compilerJarFile = bootstrapCompilerFile
}
@@ -125,3 +135,21 @@ def createPreprocessorTask(Project project, def name, def sourceDir, def targetD
args = [sourceDir, targetDir, profile]
}
}
static def createScriptTask(Project project, def name, Closure<JavaExec> configureClosure = null) {
JavaExec task = project.tasks.create(name, JavaExec)
return project.configure(task) {
classpath = project.configurations.scriptCompile
main = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
args = [
"-script",
"-version",
"-no-stdlib",
"-cp", project.configurations.scriptRuntime.asPath]
if (configureClosure != null) {
configureClosure.delegate = it
configureClosure.call()
}
}
}