Escape arguments when Gradle plugin launches out of process compilation
#KT-39755 Fixed
This commit is contained in:
+12
@@ -100,6 +100,18 @@ class KotlinGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinCompileInFolderWithSpaces() {
|
||||
val project = Project(projectName = "Project Path With Spaces")
|
||||
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertReportExists()
|
||||
assertTasksExecuted(":compileKotlin", ":compileTestKotlin")
|
||||
assertNotContains("Forcing System.gc")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLogLevelForceGC() {
|
||||
val debugProject = Project("simpleProject", minLogLevel = LogLevel.LIFECYCLE)
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.guava:guava:12.0'
|
||||
testCompile 'org.testng:testng:6.8'
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -Dkotlin.compiler.execution.strategy="out-of-process"
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package demo
|
||||
|
||||
class Dummy
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package demo
|
||||
|
||||
open class Greeter(val greeting: String)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package demo
|
||||
|
||||
import com.google.common.base.Joiner
|
||||
import java.util.ArrayList
|
||||
|
||||
class KotlinGreetingJoiner(val greeter: Greeter) {
|
||||
val names = ArrayList<String?>()
|
||||
|
||||
fun addName(name: String?): Unit {
|
||||
names.add(name)
|
||||
}
|
||||
|
||||
fun getJoinedGreeting(): String? {
|
||||
val joiner = Joiner.on(" and ").skipNulls();
|
||||
return "${greeter.greeting} ${joiner.join(names)}"
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package demo
|
||||
|
||||
fun dummyFun() {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package demo
|
||||
|
||||
import org.testng.Assert.assertEquals
|
||||
|
||||
class TestGreeter {
|
||||
fun test() {
|
||||
val greeter = Greeter("Hi!")
|
||||
assertEquals("Hi!", greeter.greeting)
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package demo
|
||||
|
||||
import org.testng.Assert.assertEquals
|
||||
import org.testng.annotations.Test as test
|
||||
|
||||
class TestKotlinGreetingJoiner() {
|
||||
@test
|
||||
fun test() {
|
||||
val example : KotlinGreetingJoiner = KotlinGreetingJoiner(Greeter("Hi"))
|
||||
example.addName("Harry")
|
||||
example.addName("Ron")
|
||||
example.addName("Hermione")
|
||||
|
||||
assertEquals(example.getJoinedGreeting(), "Hi Harry and Ron and Hermione")
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.compilerRunner
|
||||
|
||||
import groovy.json.StringEscapeUtils
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
@@ -124,9 +125,10 @@ internal fun runToolInSeparateProcess(
|
||||
}
|
||||
|
||||
private fun writeArgumentsToFile(directory: File, argsArray: Array<String>): File {
|
||||
val compilerOptions = File.createTempFile(LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "_", ".compiler.options", directory)
|
||||
val compilerOptions =
|
||||
File.createTempFile(LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "_", ".compiler.options", directory)
|
||||
compilerOptions.deleteOnExit()
|
||||
compilerOptions.writeText(argsArray.joinToString(" "))
|
||||
compilerOptions.writeText(argsArray.joinToString(" ") { "\"${StringEscapeUtils.escapeJava(it)}\"" })
|
||||
return compilerOptions
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user