From fe47e707320af73f8830a9f490b8d4e70491d6c8 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Fri, 30 Oct 2015 18:18:54 -0700 Subject: [PATCH] Simplify. --- .../beust/kobalt/plugin/java/JavaCompiler.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt index 57d50b5c..83e9d64e 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaCompiler.kt @@ -39,24 +39,27 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler) { val errorCode = process.waitFor() return if (errorCode == 0) TaskResult(true, "Compilation succeeded") - else TaskResult(false, "There were errors") + else TaskResult(false, "There were errors") } } /** - * Create an ICompilerAction based on the parameters and send it to JvmCompiler.doCompile(). + * Create an ICompilerAction based on the parameters and send it to JvmCompiler.doCompile() with + * the given executable. */ - fun compile(project: Project?, context: KobaltContext?, dependencies: List, - sourceFiles: List, outputDir: File, args: List) : TaskResult { + private fun run(project: Project?, context: KobaltContext?, dependencies: List, + sourceFiles: List, outputDir: File, args: List, executable: File) : TaskResult { val info = CompilerActionInfo(dependencies, sourceFiles, outputDir, args) - val jvm = JavaInfo.create(File(SystemProperties.javaBase)) - return jvmCompiler.doCompile(project, context, compilerAction(jvm.javacExecutable!!), info) + return jvmCompiler.doCompile(project, context, compilerAction(executable), info) } + fun compile(project: Project?, context: KobaltContext?, dependencies: List, + sourceFiles: List, outputDir: File, args: List) : TaskResult + = run(project, context, dependencies, sourceFiles, outputDir, args, + JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!) + fun javadoc(project: Project?, context: KobaltContext?, dependencies: List, - sourceFiles: List, outputDir: File, args: List) : TaskResult { - val info = CompilerActionInfo(dependencies, sourceFiles, outputDir, args) - val jvm = JavaInfo.create(File(SystemProperties.javaBase)) - return jvmCompiler.doCompile(project, context, compilerAction(jvm.javadocExecutable!!), info) - } + sourceFiles: List, outputDir: File, args: List) : TaskResult + = run(project, context, dependencies, sourceFiles, outputDir, args, + JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!) }