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

Correct dependencies for -processorpath.

This commit is contained in:
Cedric Beust 2015-12-08 07:09:41 -08:00
parent f0d7c178d7
commit 114a2b7a3a

View file

@ -4,20 +4,20 @@ import com.beust.kobalt.api.*
import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.maven.DepFactory
import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log
import com.google.common.collect.ArrayListMultimap
import com.google.inject.Inject
import javax.inject.Singleton
/**
* The AptPlugin has two components:
* 1) A new apt directive inside a dependency{} block (similar to compile()) that declares where
* the annotation process is found
* the annotation processor is found
* 2) An apt{} configuration on Project that lets the user configure how the annotation is performed
* (outputDir, etc...).
*/
@Singleton
public class AptPlugin @Inject constructor(val depFactory: DepFactory, val executors: KobaltExecutors)
public class AptPlugin @Inject constructor(val depFactory: DepFactory)
: ConfigPlugin<AptConfig>(), ICompilerFlagContributor {
companion object {
const val PLUGIN_NAME = "Apt"
@ -29,10 +29,21 @@ public class AptPlugin @Inject constructor(val depFactory: DepFactory, val execu
override fun flagsFor(project: Project, currentFlags: List<String>) : List<String> {
val result = arrayListOf<String>()
configurationFor(project)?.let { config ->
aptDependencies.get(key = project.name)?.let { aptDependency ->
val dependencyJarFile = JarFinder.byId(aptDependency)
aptDependencies[project.name]?.let { aptDependencies ->
val dependencyJarFiles = aptDependencies.map {
JarFinder.byId(it)
}.map {
it.absolutePath
}
val deps = aptDependencies.map { depFactory.create(it) }
val dependencies = context.dependencyManager.calculateDependencies(null, context, emptyList(),
deps).map { it.jarFile.get().path }
// result.add("-Xbootclasspath/a:" + dependencies)
result.add("-processorpath")
result.add(dependencyJarFile.absolutePath)
result.add((dependencyJarFiles + dependencies).joinToString(":"))
val generated = KFiles.joinAndMakeDir(project.directory, project.buildDirectory, config.outputDir)
result.add("-s")
result.add(generated)
@ -42,7 +53,7 @@ public class AptPlugin @Inject constructor(val depFactory: DepFactory, val execu
return result
}
private val aptDependencies = hashMapOf<String, String>()
private val aptDependencies = ArrayListMultimap.create<String, String>()
fun addAptDependency(dependencies: Dependencies, it: String) {
aptDependencies.put(dependencies.project.name, it)