diff --git a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt index b075032a..f75eeaf6 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -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(), 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) : List { val result = arrayListOf() 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() + private val aptDependencies = ArrayListMultimap.create() fun addAptDependency(dependencies: Dependencies, it: String) { aptDependencies.put(dependencies.project.name, it)