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

Comments.

This commit is contained in:
Cedric Beust 2015-12-06 08:09:44 -08:00
parent 9c62a4e90d
commit e93f4ba85f

View file

@ -27,11 +27,14 @@ class RetrolambdaPlugin @Inject constructor(val dependencyManager: DependencyMan
companion object { companion object {
const val PLUGIN_NAME = "Retrolambda" const val PLUGIN_NAME = "Retrolambda"
// Note the use of the versionless id here (no version number specified, ends with ":") so that
// we will always be using the latest version of the Retrolambda jar
const val ID = "net.orfjackal.retrolambda:retrolambda:" const val ID = "net.orfjackal.retrolambda:retrolambda:"
val JAR = MavenDependency.create(ID) val JAR = MavenDependency.create(ID)
} }
// IClasspathContributor // IClasspathContributor
// Only add the Retrolambda jar file if the user specified a `retrolambda{}` directive in their build file
override fun entriesFor(project: Project?) = override fun entriesFor(project: Project?) =
if (project != null && configurationFor(project) != null) listOf(JAR) if (project != null && configurationFor(project) != null) listOf(JAR)
else emptyList() else emptyList()
@ -40,24 +43,25 @@ class RetrolambdaPlugin @Inject constructor(val dependencyManager: DependencyMan
alwaysRunAfter = arrayOf(JvmCompilerPlugin.TASK_COMPILE)) alwaysRunAfter = arrayOf(JvmCompilerPlugin.TASK_COMPILE))
fun taskRetrolambda(project: Project): TaskResult { fun taskRetrolambda(project: Project): TaskResult {
val config = configurationFor(project) val config = configurationFor(project)
val result = if (config != null) { val result =
val classpath = dependencyManager.transitiveClosure(project.compileDependencies).map { if (config != null) {
it.jarFile.get() val classpath = dependencyManager.transitiveClosure(project.compileDependencies).map {
}.joinToString(File.separator) it.jarFile.get()
}.joinToString(File.separator)
val args = listOf( val args = listOf(
"-Dretrolambda.inputDir=" + project.classesDir(context), "-Dretrolambda.inputDir=" + project.classesDir(context),
"-Dretrolambda.classpath=" + classpath, "-Dretrolambda.classpath=" + classpath,
"-Dretrolambda.bytecodeVersion=${config.byteCodeVersion}", "-Dretrolambda.bytecodeVersion=${config.byteCodeVersion}",
"-jar", JAR.jarFile.get().path) "-jar", JAR.jarFile.get().path)
val result = RunCommand("java").apply { val result = RunCommand("java").apply {
directory = File(project.directory) directory = File(project.directory)
}.run(args) }.run(args)
TaskResult(result == 0) TaskResult(result == 0)
} else { } else {
TaskResult() TaskResult()
} }
return result return result
} }