mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Pass the current directory to Java compilation.
This commit is contained in:
parent
2dc1a0e5ea
commit
9134c41cc5
3 changed files with 12 additions and 8 deletions
|
@ -62,7 +62,7 @@ class JvmCompiler @Inject constructor(val dependencyManager: DependencyManager)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data class CompilerActionInfo(val dependencies: List<IClasspathDependency>,
|
data class CompilerActionInfo(val directory: String?, val dependencies: List<IClasspathDependency>,
|
||||||
val sourceFiles: List<String>, val outputDir: File, val compilerArgs: List<String>)
|
val sourceFiles: List<String>, val outputDir: File, val compilerArgs: List<String>)
|
||||||
|
|
||||||
interface ICompilerAction {
|
interface ICompilerAction {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import java.io.File
|
||||||
class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler) {
|
class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler) {
|
||||||
fun compilerAction(executable: File) = object : ICompilerAction {
|
fun compilerAction(executable: File) = object : ICompilerAction {
|
||||||
override fun compile(info: CompilerActionInfo): TaskResult {
|
override fun compile(info: CompilerActionInfo): TaskResult {
|
||||||
|
info.outputDir.mkdirs()
|
||||||
|
|
||||||
val allArgs = arrayListOf(
|
val allArgs = arrayListOf(
|
||||||
executable.absolutePath,
|
executable.absolutePath,
|
||||||
|
@ -30,7 +31,9 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler) {
|
||||||
allArgs.addAll(info.sourceFiles)
|
allArgs.addAll(info.sourceFiles)
|
||||||
|
|
||||||
val pb = ProcessBuilder(allArgs)
|
val pb = ProcessBuilder(allArgs)
|
||||||
pb.directory(info.outputDir)
|
info.directory?.let {
|
||||||
|
pb.directory(File(it))
|
||||||
|
}
|
||||||
pb.inheritIO()
|
pb.inheritIO()
|
||||||
val line = allArgs.joinToString(" ")
|
val line = allArgs.joinToString(" ")
|
||||||
log(2, " Compiling $line")
|
log(2, " Compiling $line")
|
||||||
|
@ -46,19 +49,20 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler) {
|
||||||
* Create an ICompilerAction based on the parameters and send it to JvmCompiler.doCompile() with
|
* Create an ICompilerAction based on the parameters and send it to JvmCompiler.doCompile() with
|
||||||
* the given executable.
|
* the given executable.
|
||||||
*/
|
*/
|
||||||
private fun run(project: Project?, context: KobaltContext?, dependencies: List<IClasspathDependency>,
|
private fun run(project: Project?, context: KobaltContext?, directory: String?,
|
||||||
sourceFiles: List<String>, outputDir: File, args: List<String>, executable: File) : TaskResult {
|
dependencies: List<IClasspathDependency>, sourceFiles: List<String>, outputDir: File,
|
||||||
val info = CompilerActionInfo(dependencies, sourceFiles, outputDir, args)
|
args: List<String>, executable: File): TaskResult {
|
||||||
|
val info = CompilerActionInfo(directory, dependencies, sourceFiles, outputDir, args)
|
||||||
return jvmCompiler.doCompile(project, context, compilerAction(executable), info)
|
return jvmCompiler.doCompile(project, context, compilerAction(executable), info)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun compile(project: Project?, context: KobaltContext?, dependencies: List<IClasspathDependency>,
|
fun compile(project: Project?, context: KobaltContext?, dependencies: List<IClasspathDependency>,
|
||||||
sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult
|
sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult
|
||||||
= run(project, context, dependencies, sourceFiles, outputDir, args,
|
= run(project, context, project?.directory, dependencies, sourceFiles, outputDir, args,
|
||||||
JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!)
|
JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!)
|
||||||
|
|
||||||
fun javadoc(project: Project?, context: KobaltContext?, dependencies: List<IClasspathDependency>,
|
fun javadoc(project: Project?, context: KobaltContext?, dependencies: List<IClasspathDependency>,
|
||||||
sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult
|
sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult
|
||||||
= run(project, context, dependencies, sourceFiles, outputDir, args,
|
= run(project, context, project?.directory, dependencies, sourceFiles, outputDir, args,
|
||||||
JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!)
|
JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!)
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ class KotlinCompiler @Inject constructor(val localRepo : LocalRepo,
|
||||||
.map { FileDependency(it) }
|
.map { FileDependency(it) }
|
||||||
|
|
||||||
val dependencies = compileDependencies + classpathList + otherClasspath.map { FileDependency(it)}
|
val dependencies = compileDependencies + classpathList + otherClasspath.map { FileDependency(it)}
|
||||||
val info = CompilerActionInfo(dependencies, sourceFiles, outputDir, args)
|
val info = CompilerActionInfo(project?.directory, dependencies, sourceFiles, outputDir, args)
|
||||||
return jvmCompiler.doCompile(project, context, compilerAction, info)
|
return jvmCompiler.doCompile(project, context, compilerAction, info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue