mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Rename DepFactory -> DependencyFactory.
This commit is contained in:
parent
21bc80b832
commit
9cc5d62cd3
18 changed files with 41 additions and 60 deletions
|
@ -3,7 +3,7 @@ package com.beust.kobalt
|
|||
import com.beust.kobalt.api.IClasspathDependency
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.maven.DepFactory
|
||||
import com.beust.kobalt.maven.DependencyFactory
|
||||
import com.beust.kobalt.maven.dependency.FileDependency
|
||||
import java.io.File
|
||||
|
||||
|
@ -24,7 +24,7 @@ fun plugins(vararg dependency : IClasspathDependency) {
|
|||
|
||||
@Directive
|
||||
fun plugins(vararg dependencies : String) {
|
||||
val factory = Kobalt.INJECTOR.getInstance(DepFactory::class.java)
|
||||
val factory = Kobalt.INJECTOR.getInstance(DependencyFactory::class.java)
|
||||
dependencies.forEach {
|
||||
Plugins.addDynamicPlugin(factory.create(it))
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.beust.kobalt.api.annotation.IncrementalTask
|
|||
import com.beust.kobalt.api.annotation.Task
|
||||
import com.beust.kobalt.internal.PluginInfo
|
||||
import com.beust.kobalt.internal.TaskManager
|
||||
import com.beust.kobalt.maven.DepFactory
|
||||
import com.beust.kobalt.maven.DependencyFactory
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.misc.JarUtils
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
|
@ -22,7 +22,7 @@ import javax.inject.Singleton
|
|||
@Singleton
|
||||
public class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManager>,
|
||||
val files: KFiles,
|
||||
val depFactory: DepFactory,
|
||||
val depFactory: DependencyFactory,
|
||||
val localRepo: LocalRepo,
|
||||
val executors: KobaltExecutors,
|
||||
val pluginInfo: PluginInfo,
|
||||
|
@ -152,7 +152,7 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
//
|
||||
// Load all the jar files synchronously (can't compile the build script until
|
||||
// they are installed locally).
|
||||
depFactory.create(it.id, executor = executor)
|
||||
depFactory.create(it.id)
|
||||
|
||||
//
|
||||
// Open the jar, parse its kobalt-plugin.xml and add the resulting PluginInfo to pluginInfo
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
package com.beust.kobalt.api
|
||||
|
||||
import com.beust.kobalt.maven.DepFactory
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.maven.DependencyFactory
|
||||
import java.io.File
|
||||
import java.util.concurrent.Future
|
||||
|
||||
public class JarFinder {
|
||||
class JarFinder {
|
||||
companion object {
|
||||
/**
|
||||
* @return a Future for the jar file corresponding to this id.
|
||||
*/
|
||||
fun byIdFuture(id: String) : Future<File> {
|
||||
val executor = Kobalt.INJECTOR.getInstance(KobaltExecutors::class.java).miscExecutor
|
||||
val depFactory = Kobalt.INJECTOR.getInstance(DepFactory::class.java)
|
||||
return depFactory.create(id, executor = executor).jarFile
|
||||
}
|
||||
fun byIdFuture(id: String) : Future<File> = DependencyFactory.create(id).jarFile
|
||||
|
||||
/**
|
||||
* @return the jar file corresponding to this id. This might cause a network call.
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.beust.kobalt.api
|
|||
import com.beust.kobalt.TestConfig
|
||||
import com.beust.kobalt.api.annotation.Directive
|
||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.maven.aether.KobaltAether
|
||||
import com.beust.kobalt.maven.DependencyFactory
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
@ -151,7 +151,7 @@ class Dependencies(val project: Project,
|
|||
*/
|
||||
private fun addToDependencies(dependencies: ArrayList<IClasspathDependency>, dep: Array<out String>)
|
||||
: List<File>
|
||||
= with(dep.map { KobaltAether.create(it)}) {
|
||||
= with(dep.map { DependencyFactory.create(it)}) {
|
||||
dependencies.addAll(this)
|
||||
this.map { it.jarFile.get() }
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.beust.kobalt.api.*
|
|||
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
||||
import com.beust.kobalt.api.annotation.IncrementalTask
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
import com.beust.kobalt.maven.DepFactory
|
||||
import com.beust.kobalt.maven.DependencyFactory
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.maven.Md5
|
||||
|
@ -29,7 +29,7 @@ import javax.inject.Singleton
|
|||
open class JvmCompilerPlugin @Inject constructor(
|
||||
open val localRepo: LocalRepo,
|
||||
open val files: KFiles,
|
||||
open val depFactory: DepFactory,
|
||||
open val depFactory: DependencyFactory,
|
||||
open val dependencyManager: DependencyManager,
|
||||
open val executors: KobaltExecutors,
|
||||
open val jvmCompiler: JvmCompiler,
|
||||
|
|
|
@ -4,31 +4,25 @@ import com.beust.kobalt.api.IClasspathDependency
|
|||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.maven.aether.KobaltAether
|
||||
import com.beust.kobalt.maven.dependency.FileDependency
|
||||
import com.beust.kobalt.misc.DependencyExecutor
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.google.inject.Key
|
||||
import java.util.concurrent.ExecutorService
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Use this class to create instances of `IClasspathDependency` from an id.
|
||||
*/
|
||||
class DepFactory @Inject constructor(val localRepo: LocalRepo,
|
||||
class DependencyFactory @Inject constructor(val localRepo: LocalRepo,
|
||||
val executors: KobaltExecutors,
|
||||
val aether: KobaltAether) {
|
||||
|
||||
companion object {
|
||||
val defExecutor : ExecutorService by lazy {
|
||||
Kobalt.INJECTOR.getInstance(Key.get(ExecutorService::class.java, DependencyExecutor::class.java))
|
||||
}
|
||||
fun create(id: String) =
|
||||
Kobalt.INJECTOR.getInstance(DependencyFactory::class.java).create(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the id and return the correct IClasspathDependency
|
||||
*/
|
||||
fun create(id: String, downloadSources: Boolean = false, downloadJavadocs: Boolean = false,
|
||||
localFirst : Boolean = true, showNetworkWarning: Boolean = true, executor: ExecutorService = defExecutor)
|
||||
: IClasspathDependency {
|
||||
fun create(id: String) : IClasspathDependency {
|
||||
if (id.startsWith(FileDependency.PREFIX_FILE)) {
|
||||
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
|
||||
} else {
|
|
@ -10,7 +10,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class DependencyManager @Inject constructor(val executors: KobaltExecutors, val depFactory: DepFactory) {
|
||||
class DependencyManager @Inject constructor(val executors: KobaltExecutors, val depFactory: DependencyFactory) {
|
||||
|
||||
/**
|
||||
* Create an IClasspathDependency from a Maven id.
|
||||
|
@ -77,7 +77,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
|||
dependencies.forEach { projectDependency ->
|
||||
result.add(projectDependency)
|
||||
projectDependency.id.let {
|
||||
result.add(depFactory.create(it, executor = executor))
|
||||
result.add(depFactory.create(it))
|
||||
val downloaded = transitiveClosure(projectDependency.directDependencies())
|
||||
|
||||
result.addAll(downloaded)
|
||||
|
|
|
@ -30,12 +30,6 @@ class DependencyResult(val dependency: IClasspathDependency, val repoUrl: String
|
|||
class KobaltAether @Inject constructor (val settings: KobaltSettings) {
|
||||
val localRepo: File get() = File(settings.localRepo)
|
||||
|
||||
companion object {
|
||||
val aether : KobaltAether get() = Kobalt.INJECTOR.getInstance(KobaltAether::class.java)
|
||||
|
||||
fun create(id: String) = aether.create(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't call this method directly, use `DepFactory` instead.
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.beust.kobalt.misc
|
|||
|
||||
import com.beust.kobalt.KobaltException
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.maven.DepFactory
|
||||
import com.beust.kobalt.maven.DependencyFactory
|
||||
import com.beust.kobalt.maven.MavenId
|
||||
import com.beust.kobalt.maven.aether.AetherDependency
|
||||
import javax.inject.Inject
|
||||
|
@ -10,7 +10,7 @@ import javax.inject.Inject
|
|||
/**
|
||||
* Find out if any newer versions of the dependencies are available.
|
||||
*/
|
||||
public class CheckVersions @Inject constructor(val depFactory : DepFactory,
|
||||
public class CheckVersions @Inject constructor(val depFactory : DependencyFactory,
|
||||
val executors : KobaltExecutors) {
|
||||
|
||||
fun run(projects: List<Project>) {
|
||||
|
@ -22,8 +22,7 @@ public class CheckVersions @Inject constructor(val depFactory : DepFactory,
|
|||
cds.forEach { compileDependency ->
|
||||
if (MavenId.isMavenId(compileDependency.id)) {
|
||||
try {
|
||||
val dep = depFactory.create(compileDependency.shortId, localFirst = false,
|
||||
showNetworkWarning = false, executor = executor)
|
||||
val dep = depFactory.create(compileDependency.shortId)
|
||||
val other = compileDependency as AetherDependency
|
||||
if (dep.id != compileDependency.id
|
||||
&& Versions.toLongVersion(dep.version) > Versions.toLongVersion(other.version)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue