diff --git a/src/main/kotlin/com/beust/kobalt/api/JarFinder.kt b/src/main/kotlin/com/beust/kobalt/api/JarFinder.kt new file mode 100644 index 00000000..829cae53 --- /dev/null +++ b/src/main/kotlin/com/beust/kobalt/api/JarFinder.kt @@ -0,0 +1,24 @@ +package com.beust.kobalt.api + +import com.beust.kobalt.maven.DepFactory +import com.beust.kobalt.misc.KobaltExecutors +import java.io.File +import java.util.concurrent.Future + +public class JarFinder { + companion object { + /** + * @return a Future for the jar file corresponding to this id. + */ + fun byIdFuture(id: String) : Future { + val executor = Kobalt.INJECTOR.getInstance(KobaltExecutors::class.java).miscExecutor + val depFactory = Kobalt.INJECTOR.getInstance(DepFactory::class.java) + return depFactory.create(id, executor).jarFile + } + + /** + * @return the jar file corresponding to this id. This might cause a network call. + */ + fun byId(id: String) = byIdFuture(id).get() + } +} 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 37bd5831..fcb51ce4 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/apt/AptPlugin.kt @@ -37,9 +37,9 @@ public class AptPlugin @Inject constructor(val depFactory: DepFactory, val execu val result = arrayListOf() configs[project.name]?.let { config -> aptDependencies.get(key = project.name)?.let { aptDependency -> - val dependency = depFactory.create(aptDependency, executors.miscExecutor) + val dependencyJarFile = JarFinder.byId(aptDependency) result.add("-processorpath") - result.add(dependency.jarFile.get().absolutePath) + result.add(dependencyJarFile.absolutePath) val generated = KFiles.joinAndMakeDir(project.directory, project.buildDirectory!!, config.outputDir) result.add("-s") result.add(generated) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt index 3ce6243e..38bc7ef3 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/dokka/DokkaPlugin.kt @@ -4,6 +4,7 @@ import com.beust.kobalt.JavaInfo import com.beust.kobalt.SystemProperties import com.beust.kobalt.TaskResult import com.beust.kobalt.api.ConfigPlugin +import com.beust.kobalt.api.JarFinder import com.beust.kobalt.api.Kobalt import com.beust.kobalt.api.Project import com.beust.kobalt.api.annotation.Directive @@ -40,7 +41,7 @@ class DokkaPlugin @Inject constructor(val depFactory: DepFactory) : ConfigPlugin val classpathString = (classpath.map { it.jarFile.get().absolutePath } + listOf(buildDir)) .joinToString(File.pathSeparator) - val dokkaJar = depFactory.create(DOKKA_ID, context.executors.miscExecutor).jarFile.get().absolutePath + val dokkaJar = JarFinder.byId(DOKKA_ID) if (config != null) { val args = listOf( "-classpath", classpathString,