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

Validate classpath.

This commit is contained in:
Cedric Beust 2015-10-12 22:54:51 -07:00
parent c93caf5989
commit 281ae2071b
3 changed files with 13 additions and 1 deletions

View file

@ -110,6 +110,14 @@ abstract public class JvmCompilerPlugin @Inject constructor(
lp(project, "No resources to copy for ${sourceSet}") lp(project, "No resources to copy for ${sourceSet}")
} }
} }
protected fun validateClasspath(cp: List<String>) {
cp.forEach {
if (! File(it).exists()) {
throw KobaltException("Couldn't find $it")
}
}
}
} }

View file

@ -51,8 +51,10 @@ public class JavaPlugin @Inject constructor(
javac!!.absolutePath, javac!!.absolutePath,
"-d", outputDirectory.absolutePath) "-d", outputDirectory.absolutePath)
if (cpList.size() > 0) { if (cpList.size() > 0) {
val stringClasspath = cpList.map { it.jarFile.get().absolutePath }
validateClasspath(stringClasspath)
args.add("-classpath") args.add("-classpath")
args.add(cpList.map { it.jarFile.get().absolutePath }.join(File.pathSeparator)) args.add(stringClasspath.join(File.pathSeparator))
} }
args.addAll(sourceFiles) args.addAll(sourceFiles)

View file

@ -48,6 +48,8 @@ class KotlinCompiler @Inject constructor(override val localRepo : LocalRepo,
classpathList.addAll(otherClasspath) classpathList.addAll(otherClasspath)
classpathList.addAll(calculateClasspath(compileDependencies).map { it.id }) classpathList.addAll(calculateClasspath(compileDependencies).map { it.id })
validateClasspath(classpathList)
log(2, "Compiling ${source.size()} files with classpath:\n " + classpathList.join("\n ")) log(2, "Compiling ${source.size()} files with classpath:\n " + classpathList.join("\n "))
K2JVMCompiler.main(arrayOf( K2JVMCompiler.main(arrayOf(
"-d", output, "-d", output,