1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Get rid of stdlib warning.

This commit is contained in:
Cedric Beust 2016-02-18 02:31:53 +04:00
parent e24476feba
commit 38d2308410

View file

@ -52,12 +52,18 @@ class KotlinCompiler @Inject constructor(
if (! outputDir.endsWith(".jar")) { if (! outputDir.endsWith(".jar")) {
File(outputDir).mkdirs() File(outputDir).mkdirs()
} }
val allArgs : Array<String> = arrayOf( val allArgs = arrayListOf(
"-d", outputDir, "-d", outputDir,
"-classpath", cp.joinToString(File.pathSeparator), "-classpath", cp.joinToString(File.pathSeparator),
*(info.compilerArgs.toTypedArray()), *(info.compilerArgs.toTypedArray()),
*(info.sourceFiles.toTypedArray()) *(info.sourceFiles.toTypedArray())
) )
// Get rid of annoying and useless warning
if (! info.compilerArgs.contains("-no-stdlib")) {
allArgs.add("-no-stdlib")
}
val success = invokeCompiler(projectName ?: "kobalt-" + Random().nextInt(), cp, allArgs) val success = invokeCompiler(projectName ?: "kobalt-" + Random().nextInt(), cp, allArgs)
return TaskResult(success) return TaskResult(success)
} }
@ -72,7 +78,7 @@ class KotlinCompiler @Inject constructor(
* There are plenty of ways in which this method can break but this will be immediately * There are plenty of ways in which this method can break but this will be immediately
* apparent if it happens. * apparent if it happens.
*/ */
private fun invokeCompiler(projectName: String, cp: List<File>, args: Array<String>): Boolean { private fun invokeCompiler(projectName: String, cp: List<File>, args: List<String>): Boolean {
val allArgs = listOf("-module-name", "project-" + projectName) + args val allArgs = listOf("-module-name", "project-" + projectName) + args
log(2, "Calling kotlinc " + allArgs.joinToString(" ")) log(2, "Calling kotlinc " + allArgs.joinToString(" "))
val result : Boolean = val result : Boolean =
@ -81,7 +87,7 @@ class KotlinCompiler @Inject constructor(
val compiler = classLoader.loadClass("org.jetbrains.kotlin.cli.common.CLICompiler") val compiler = classLoader.loadClass("org.jetbrains.kotlin.cli.common.CLICompiler")
val compilerMain = compiler.declaredMethods.filter { val compilerMain = compiler.declaredMethods.filter {
it.name == "doMainNoExit" && it.parameterTypes.size == 2 it.name == "doMainNoExit" && it.parameterTypes.size == 2
}.get(0) }[0]
val kCompiler = classLoader.loadClass("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler") val kCompiler = classLoader.loadClass("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
val compilerInstance = kCompiler.newInstance() val compilerInstance = kCompiler.newInstance()
val exitCode = compilerMain.invoke(null, compilerInstance, allArgs.toTypedArray()) val exitCode = compilerMain.invoke(null, compilerInstance, allArgs.toTypedArray())