1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28: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.api.annotation.Directive
import com.beust.kobalt.maven.DepFactory import com.beust.kobalt.maven.DepFactory
import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log import com.beust.kobalt.misc.log
import com.google.common.collect.ArrayListMultimap
import com.google.inject.Inject import com.google.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
/** /**
* The AptPlugin has two components: * The AptPlugin has two components:
* 1) A new apt directive inside a dependency{} block (similar to compile()) that declares where * 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 * 2) An apt{} configuration on Project that lets the user configure how the annotation is performed
* (outputDir, etc...). * (outputDir, etc...).
*/ */
@Singleton @Singleton
public class AptPlugin @Inject constructor(val depFactory: DepFactory, val executors: KobaltExecutors) public class AptPlugin @Inject constructor(val depFactory: DepFactory)
: ConfigPlugin<AptConfig>(), ICompilerFlagContributor { : ConfigPlugin<AptConfig>(), ICompilerFlagContributor {
companion object { companion object {
const val PLUGIN_NAME = "Apt" 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> { override fun flagsFor(project: Project, currentFlags: List<String>) : List<String> {
val result = arrayListOf<String>() val result = arrayListOf<String>()
configurationFor(project)?.let { config -> configurationFor(project)?.let { config ->
aptDependencies.get(key = project.name)?.let { aptDependency -> aptDependencies[project.name]?.let { aptDependencies ->
val dependencyJarFile = JarFinder.byId(aptDependency) 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("-processorpath")
result.add(dependencyJarFile.absolutePath) result.add((dependencyJarFiles + dependencies).joinToString(":"))
val generated = KFiles.joinAndMakeDir(project.directory, project.buildDirectory, config.outputDir) val generated = KFiles.joinAndMakeDir(project.directory, project.buildDirectory, config.outputDir)
result.add("-s") result.add("-s")
result.add(generated) result.add(generated)
@ -42,7 +53,7 @@ public class AptPlugin @Inject constructor(val depFactory: DepFactory, val execu
return result return result
} }
private val aptDependencies = hashMapOf<String, String>() private val aptDependencies = ArrayListMultimap.create<String, String>()
fun addAptDependency(dependencies: Dependencies, it: String) { fun addAptDependency(dependencies: Dependencies, it: String) {
aptDependencies.put(dependencies.project.name, it) aptDependencies.put(dependencies.project.name, it)