mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Remove DependencyFactory, introduce IDependencyManager.
This commit is contained in:
parent
10f2344edb
commit
984c514fa4
18 changed files with 107 additions and 97 deletions
|
@ -3,7 +3,7 @@ package com.beust.kobalt
|
||||||
import com.beust.kobalt.api.IClasspathDependency
|
import com.beust.kobalt.api.IClasspathDependency
|
||||||
import com.beust.kobalt.api.Kobalt
|
import com.beust.kobalt.api.Kobalt
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ fun plugins(vararg dependency : IClasspathDependency) {
|
||||||
|
|
||||||
@Directive
|
@Directive
|
||||||
fun plugins(vararg dependencies : String) {
|
fun plugins(vararg dependencies : String) {
|
||||||
val factory = Kobalt.INJECTOR.getInstance(DependencyFactory::class.java)
|
val factory = Kobalt.INJECTOR.getInstance(DependencyManager::class.java)
|
||||||
dependencies.forEach {
|
dependencies.forEach {
|
||||||
Plugins.addDynamicPlugin(factory.create(it))
|
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.api.annotation.Task
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.internal.TaskManager
|
import com.beust.kobalt.internal.TaskManager
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.LocalRepo
|
import com.beust.kobalt.maven.LocalRepo
|
||||||
import com.beust.kobalt.misc.JarUtils
|
import com.beust.kobalt.misc.JarUtils
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
@ -20,9 +20,9 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManager>,
|
class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManager>,
|
||||||
val files: KFiles,
|
val files: KFiles,
|
||||||
val depFactory: DependencyFactory,
|
val depManager: DependencyManager,
|
||||||
val localRepo: LocalRepo,
|
val localRepo: LocalRepo,
|
||||||
val executors: KobaltExecutors,
|
val executors: KobaltExecutors,
|
||||||
val pluginInfo: PluginInfo,
|
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
|
// Load all the jar files synchronously (can't compile the build script until
|
||||||
// they are installed locally).
|
// they are installed locally).
|
||||||
depFactory.create(it.id)
|
depManager.create(it.id)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Open the jar, parse its kobalt-plugin.xml and add the resulting PluginInfo to pluginInfo
|
// Open the jar, parse its kobalt-plugin.xml and add the resulting PluginInfo to pluginInfo
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.beust.kobalt.api
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage the creation of dependencies and also provide dependencies for projects.
|
||||||
|
*/
|
||||||
|
interface IDependencyManager {
|
||||||
|
/**
|
||||||
|
* Parse the id and return the correct IClasspathDependency
|
||||||
|
*/
|
||||||
|
fun create(id: String): IClasspathDependency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an IClasspathDependency from a Maven id.
|
||||||
|
*/
|
||||||
|
fun createMaven(id: String): IClasspathDependency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an IClasspathDependency from a path.
|
||||||
|
*/
|
||||||
|
fun createFile(path: String): IClasspathDependency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the source dependencies for this project, including the contributors.
|
||||||
|
*/
|
||||||
|
fun dependencies(project: Project, context: KobaltContext): List<IClasspathDependency>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the test dependencies for this project, including the contributors.
|
||||||
|
*/
|
||||||
|
fun testDependencies(project: Project, context: KobaltContext): List<IClasspathDependency>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the classpath for this project, including the IClasspathContributors.
|
||||||
|
* allDependencies is typically either compileDependencies or testDependencies
|
||||||
|
*/
|
||||||
|
fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||||
|
dependentProjects: List<ProjectDescription> = emptyList(),
|
||||||
|
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency>
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
package com.beust.kobalt.api
|
package com.beust.kobalt.api
|
||||||
|
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class JarFinder {
|
||||||
/**
|
/**
|
||||||
* @return a Future for the jar file corresponding to this id.
|
* @return a Future for the jar file corresponding to this id.
|
||||||
*/
|
*/
|
||||||
fun byIdFuture(id: String) : Future<File> = DependencyFactory.create(id).jarFile
|
fun byIdFuture(id: String) : Future<File> = DependencyManager.create(id).jarFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the jar file corresponding to this id. This might cause a network call.
|
* @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.TestConfig
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
@ -151,7 +151,7 @@ class Dependencies(val project: Project,
|
||||||
*/
|
*/
|
||||||
private fun addToDependencies(dependencies: ArrayList<IClasspathDependency>, dep: Array<out String>)
|
private fun addToDependencies(dependencies: ArrayList<IClasspathDependency>, dep: Array<out String>)
|
||||||
: List<File>
|
: List<File>
|
||||||
= with(dep.map { DependencyFactory.create(it)}) {
|
= with(dep.map { DependencyManager.create(it)}) {
|
||||||
dependencies.addAll(this)
|
dependencies.addAll(this)
|
||||||
this.map { it.jarFile.get() }
|
this.map { it.jarFile.get() }
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
import com.beust.kobalt.api.annotation.ExportedProjectProperty
|
||||||
import com.beust.kobalt.api.annotation.IncrementalTask
|
import com.beust.kobalt.api.annotation.IncrementalTask
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.LocalRepo
|
import com.beust.kobalt.maven.LocalRepo
|
||||||
import com.beust.kobalt.maven.Md5
|
import com.beust.kobalt.maven.Md5
|
||||||
|
@ -29,10 +28,8 @@ import javax.inject.Singleton
|
||||||
open class JvmCompilerPlugin @Inject constructor(
|
open class JvmCompilerPlugin @Inject constructor(
|
||||||
open val localRepo: LocalRepo,
|
open val localRepo: LocalRepo,
|
||||||
open val files: KFiles,
|
open val files: KFiles,
|
||||||
open val depFactory: DependencyFactory,
|
|
||||||
open val dependencyManager: DependencyManager,
|
open val dependencyManager: DependencyManager,
|
||||||
open val executors: KobaltExecutors,
|
open val executors: KobaltExecutors,
|
||||||
open val jvmCompiler: JvmCompiler,
|
|
||||||
open val taskContributor : TaskContributor)
|
open val taskContributor : TaskContributor)
|
||||||
: BasePlugin(), ISourceDirectoryContributor, IProjectContributor, ITaskContributor by taskContributor {
|
: BasePlugin(), ISourceDirectoryContributor, IProjectContributor, ITaskContributor by taskContributor {
|
||||||
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package com.beust.kobalt.maven
|
|
||||||
|
|
||||||
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.KobaltExecutors
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this class to create instances of `IClasspathDependency` from an id.
|
|
||||||
*/
|
|
||||||
class DependencyFactory @Inject constructor(val localRepo: LocalRepo,
|
|
||||||
val executors: KobaltExecutors,
|
|
||||||
val aether: KobaltAether) {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun create(id: String) =
|
|
||||||
Kobalt.INJECTOR.getInstance(DependencyFactory::class.java).create(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the id and return the correct IClasspathDependency
|
|
||||||
*/
|
|
||||||
fun create(id: String) : IClasspathDependency {
|
|
||||||
if (id.startsWith(FileDependency.PREFIX_FILE)) {
|
|
||||||
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
|
|
||||||
} else {
|
|
||||||
val mavenId = MavenId.create(id)
|
|
||||||
val result = if (mavenId.hasVersion) aether.create(id)
|
|
||||||
else aether.create(id + "(0,]")
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.beust.kobalt.maven
|
package com.beust.kobalt.maven
|
||||||
|
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
|
import com.beust.kobalt.maven.aether.KobaltAether
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
|
@ -10,27 +11,47 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class DependencyManager @Inject constructor(val executors: KobaltExecutors, val depFactory: DependencyFactory) {
|
class DependencyManager @Inject constructor(val executors: KobaltExecutors, val aether: KobaltAether)
|
||||||
|
: IDependencyManager {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun create(id: String) =
|
||||||
|
Kobalt.INJECTOR.getInstance(DependencyManager::class.java).create(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the id and return the correct IClasspathDependency
|
||||||
|
*/
|
||||||
|
override fun create(id: String) : IClasspathDependency {
|
||||||
|
if (id.startsWith(FileDependency.PREFIX_FILE)) {
|
||||||
|
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
|
||||||
|
} else {
|
||||||
|
val mavenId = MavenId.create(id)
|
||||||
|
val result = if (mavenId.hasVersion) aether.create(id)
|
||||||
|
else aether.create(id + "(0,]")
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an IClasspathDependency from a Maven id.
|
* Create an IClasspathDependency from a Maven id.
|
||||||
*/
|
*/
|
||||||
fun createMaven(id: String) : IClasspathDependency = depFactory.create(id)
|
override fun createMaven(id: String) : IClasspathDependency = create(id)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an IClasspathDependency from a path.
|
* Create an IClasspathDependency from a path.
|
||||||
*/
|
*/
|
||||||
fun createFile(path: String) : IClasspathDependency = FileDependency(path)
|
override fun createFile(path: String) : IClasspathDependency = FileDependency(path)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the source dependencies for this project, including the contributors.
|
* @return the source dependencies for this project, including the contributors.
|
||||||
*/
|
*/
|
||||||
fun dependencies(project: Project, context: KobaltContext) = dependencies(project, context, false)
|
override fun dependencies(project: Project, context: KobaltContext) = dependencies(project, context, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the test dependencies for this project, including the contributors.
|
* @return the test dependencies for this project, including the contributors.
|
||||||
*/
|
*/
|
||||||
fun testDependencies(project: Project, context: KobaltContext) = dependencies(project, context, true)
|
override fun testDependencies(project: Project, context: KobaltContext) = dependencies(project, context, true)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transitive dependencies for the compilation of this project.
|
* Transitive dependencies for the compilation of this project.
|
||||||
|
@ -43,8 +64,8 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
||||||
* @return the classpath for this project, including the IClasspathContributors.
|
* @return the classpath for this project, including the IClasspathContributors.
|
||||||
* allDependencies is typically either compileDependencies or testDependencies
|
* allDependencies is typically either compileDependencies or testDependencies
|
||||||
*/
|
*/
|
||||||
fun calculateDependencies(project: Project?, context: KobaltContext,
|
override fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||||
dependentProjects: List<ProjectDescription> = emptyList(),
|
dependentProjects: List<ProjectDescription>,
|
||||||
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
vararg allDependencies: List<IClasspathDependency>): List<IClasspathDependency> {
|
||||||
var result = arrayListOf<IClasspathDependency>()
|
var result = arrayListOf<IClasspathDependency>()
|
||||||
allDependencies.forEach { dependencies ->
|
allDependencies.forEach { dependencies ->
|
||||||
|
@ -77,7 +98,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
||||||
dependencies.forEach { projectDependency ->
|
dependencies.forEach { projectDependency ->
|
||||||
result.add(projectDependency)
|
result.add(projectDependency)
|
||||||
projectDependency.id.let {
|
projectDependency.id.let {
|
||||||
result.add(depFactory.create(it))
|
result.add(create(it))
|
||||||
val downloaded = transitiveClosure(projectDependency.directDependencies())
|
val downloaded = transitiveClosure(projectDependency.directDependencies())
|
||||||
|
|
||||||
result.addAll(downloaded)
|
result.addAll(downloaded)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.beust.kobalt.misc
|
||||||
|
|
||||||
import com.beust.kobalt.KobaltException
|
import com.beust.kobalt.KobaltException
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.MavenId
|
import com.beust.kobalt.maven.MavenId
|
||||||
import com.beust.kobalt.maven.aether.AetherDependency
|
import com.beust.kobalt.maven.aether.AetherDependency
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -10,7 +10,7 @@ import javax.inject.Inject
|
||||||
/**
|
/**
|
||||||
* Find out if any newer versions of the dependencies are available.
|
* Find out if any newer versions of the dependencies are available.
|
||||||
*/
|
*/
|
||||||
public class CheckVersions @Inject constructor(val depFactory : DependencyFactory,
|
public class CheckVersions @Inject constructor(val depManager: DependencyManager,
|
||||||
val executors : KobaltExecutors) {
|
val executors : KobaltExecutors) {
|
||||||
|
|
||||||
fun run(projects: List<Project>) {
|
fun run(projects: List<Project>) {
|
||||||
|
@ -22,7 +22,7 @@ public class CheckVersions @Inject constructor(val depFactory : DependencyFactor
|
||||||
cds.forEach { compileDependency ->
|
cds.forEach { compileDependency ->
|
||||||
if (MavenId.isMavenId(compileDependency.id)) {
|
if (MavenId.isMavenId(compileDependency.id)) {
|
||||||
try {
|
try {
|
||||||
val dep = depFactory.create(compileDependency.shortId)
|
val dep = depManager.create(compileDependency.shortId)
|
||||||
val other = compileDependency as AetherDependency
|
val other = compileDependency as AetherDependency
|
||||||
if (dep.id != compileDependency.id
|
if (dep.id != compileDependency.id
|
||||||
&& Versions.toLongVersion(dep.version) > Versions.toLongVersion(other.version)) {
|
&& Versions.toLongVersion(dep.version) > Versions.toLongVersion(other.version)) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import com.beust.kobalt.api.Kobalt
|
||||||
import com.beust.kobalt.api.PluginTask
|
import com.beust.kobalt.api.PluginTask
|
||||||
import com.beust.kobalt.api.Project
|
import com.beust.kobalt.api.Project
|
||||||
import com.beust.kobalt.app.*
|
import com.beust.kobalt.app.*
|
||||||
import com.beust.kobalt.app.remote.DependencyData
|
|
||||||
import com.beust.kobalt.app.remote.KobaltClient
|
import com.beust.kobalt.app.remote.KobaltClient
|
||||||
import com.beust.kobalt.app.remote.KobaltServer
|
import com.beust.kobalt.app.remote.KobaltServer
|
||||||
import com.beust.kobalt.internal.Gc
|
import com.beust.kobalt.internal.Gc
|
||||||
|
@ -14,7 +13,7 @@ import com.beust.kobalt.internal.KobaltSettings
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.internal.TaskManager
|
import com.beust.kobalt.internal.TaskManager
|
||||||
import com.beust.kobalt.internal.build.BuildFile
|
import com.beust.kobalt.internal.build.BuildFile
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.Http
|
import com.beust.kobalt.maven.Http
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.misc.*
|
import com.beust.kobalt.misc.*
|
||||||
|
@ -59,6 +58,7 @@ private class Main @Inject constructor(
|
||||||
val http: Http,
|
val http: Http,
|
||||||
val files: KFiles,
|
val files: KFiles,
|
||||||
val executors: KobaltExecutors,
|
val executors: KobaltExecutors,
|
||||||
|
val dependencyManager: DependencyManager,
|
||||||
val checkVersions: CheckVersions,
|
val checkVersions: CheckVersions,
|
||||||
val github: GithubApi2,
|
val github: GithubApi2,
|
||||||
val updateKobalt: UpdateKobalt,
|
val updateKobalt: UpdateKobalt,
|
||||||
|
@ -66,8 +66,6 @@ private class Main @Inject constructor(
|
||||||
val server: KobaltServer,
|
val server: KobaltServer,
|
||||||
val pluginInfo: PluginInfo,
|
val pluginInfo: PluginInfo,
|
||||||
val projectGenerator: ProjectGenerator,
|
val projectGenerator: ProjectGenerator,
|
||||||
val depFactory: DependencyFactory,
|
|
||||||
val dependencyData: DependencyData,
|
|
||||||
val resolveDependency: ResolveDependency) {
|
val resolveDependency: ResolveDependency) {
|
||||||
|
|
||||||
data class RunInfo(val jc: JCommander, val args: Args)
|
data class RunInfo(val jc: JCommander, val args: Args)
|
||||||
|
@ -77,7 +75,7 @@ private class Main @Inject constructor(
|
||||||
val dependencies = arrayListOf<IClasspathDependency>()
|
val dependencies = arrayListOf<IClasspathDependency>()
|
||||||
args.pluginIds?.let {
|
args.pluginIds?.let {
|
||||||
// We want this call to go to the network if no version was specified, so set localFirst to false
|
// We want this call to go to the network if no version was specified, so set localFirst to false
|
||||||
dependencies.addAll(it.split(",").map { depFactory.create(it) })
|
dependencies.addAll(it.split(",").map { dependencyManager.create(it) })
|
||||||
}
|
}
|
||||||
args.pluginJarFiles?.let {
|
args.pluginJarFiles?.let {
|
||||||
dependencies.addAll(it.split(",").map { FileDependency(it) })
|
dependencies.addAll(it.split(",").map { FileDependency(it) })
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.beust.kobalt.app.BuildFileCompiler
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.internal.build.BuildFile
|
import com.beust.kobalt.internal.build.BuildFile
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
@ -17,13 +16,12 @@ import java.io.File
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
|
|
||||||
class DependencyData @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager,
|
class DependencyData @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager,
|
||||||
val buildFileCompilerFactory: BuildFileCompiler.IFactory, val pluginInfo: PluginInfo,
|
val buildFileCompilerFactory: BuildFileCompiler.IFactory, val pluginInfo: PluginInfo) {
|
||||||
val depFactory: DependencyFactory) {
|
|
||||||
fun dependenciesDataFor(buildFilePath: String, args: Args) : GetDependenciesData {
|
fun dependenciesDataFor(buildFilePath: String, args: Args) : GetDependenciesData {
|
||||||
val projectDatas = arrayListOf<ProjectData>()
|
val projectDatas = arrayListOf<ProjectData>()
|
||||||
|
|
||||||
fun toDependencyData(d: IClasspathDependency, scope: String): DependencyData {
|
fun toDependencyData(d: IClasspathDependency, scope: String): DependencyData {
|
||||||
val dep = depFactory.create(d.id)
|
val dep = dependencyManager.create(d.id)
|
||||||
return DependencyData(d.id, scope, dep.jarFile.get().absolutePath)
|
return DependencyData(d.id, scope, dep.jarFile.get().absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.beust.kobalt.plugin.apt
|
||||||
|
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.google.common.collect.ArrayListMultimap
|
import com.google.common.collect.ArrayListMultimap
|
||||||
|
@ -18,7 +18,7 @@ import javax.inject.Singleton
|
||||||
* (outputDir, etc...).
|
* (outputDir, etc...).
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
class AptPlugin @Inject constructor(val depFactory: DependencyFactory, val configActor: ConfigActor<AptConfig>)
|
class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val configActor: ConfigActor<AptConfig>)
|
||||||
: BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, IConfigActor<AptConfig> by configActor {
|
: BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, IConfigActor<AptConfig> by configActor {
|
||||||
|
|
||||||
// ISourceDirectoryContributor
|
// ISourceDirectoryContributor
|
||||||
|
@ -54,7 +54,7 @@ class AptPlugin @Inject constructor(val depFactory: DependencyFactory, val confi
|
||||||
val result = arrayListOf<String>()
|
val result = arrayListOf<String>()
|
||||||
configurationFor(project)?.let { config ->
|
configurationFor(project)?.let { config ->
|
||||||
aptDependencies[project.name]?.let { aptDependencies ->
|
aptDependencies[project.name]?.let { aptDependencies ->
|
||||||
val deps = aptDependencies.map { depFactory.create(it) }
|
val deps = aptDependencies.map { dependencyManager.create(it) }
|
||||||
|
|
||||||
val dependencies = context.dependencyManager.calculateDependencies(null, context, emptyList(), deps)
|
val dependencies = context.dependencyManager.calculateDependencies(null, context, emptyList(), deps)
|
||||||
.map { it.jarFile.get().path }
|
.map { it.jarFile.get().path }
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.internal.ICompilerAction
|
import com.beust.kobalt.internal.ICompilerAction
|
||||||
import com.beust.kobalt.internal.JvmCompiler
|
import com.beust.kobalt.internal.JvmCompiler
|
||||||
import com.beust.kobalt.kotlin.ParentLastClassLoader
|
import com.beust.kobalt.kotlin.ParentLastClassLoader
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
|
@ -31,7 +30,6 @@ import kotlin.properties.Delegates
|
||||||
class KotlinCompiler @Inject constructor(
|
class KotlinCompiler @Inject constructor(
|
||||||
val files: KFiles,
|
val files: KFiles,
|
||||||
val dependencyManager: DependencyManager,
|
val dependencyManager: DependencyManager,
|
||||||
val depFactory: DependencyFactory,
|
|
||||||
val executors: KobaltExecutors,
|
val executors: KobaltExecutors,
|
||||||
val jvmCompiler: JvmCompiler) {
|
val jvmCompiler: JvmCompiler) {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -137,7 +135,7 @@ class KotlinCompiler @Inject constructor(
|
||||||
otherClasspath: List<String>, sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult {
|
otherClasspath: List<String>, sourceFiles: List<String>, outputDir: File, args: List<String>) : TaskResult {
|
||||||
|
|
||||||
val executor = executors.newExecutor("KotlinCompiler", 10)
|
val executor = executors.newExecutor("KotlinCompiler", 10)
|
||||||
val compilerDep = depFactory.create("org.jetbrains.kotlin:kotlin-compiler-embeddable:$KOTLIN_VERSION")
|
val compilerDep = dependencyManager.create("org.jetbrains.kotlin:kotlin-compiler-embeddable:$KOTLIN_VERSION")
|
||||||
val deps = dependencyManager.transitiveClosure(listOf(compilerDep))
|
val deps = dependencyManager.transitiveClosure(listOf(compilerDep))
|
||||||
|
|
||||||
// Force a download of the compiler dependencies
|
// Force a download of the compiler dependencies
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.internal.BaseJvmPlugin
|
import com.beust.kobalt.internal.BaseJvmPlugin
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||||
import com.beust.kobalt.maven.DependencyFactory
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
|
@ -17,7 +17,7 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depFactory: DependencyFactory,
|
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager,
|
||||||
override val configActor: ConfigActor<KotlinConfig>)
|
override val configActor: ConfigActor<KotlinConfig>)
|
||||||
: BaseJvmPlugin<KotlinConfig>(configActor), IDocContributor, IClasspathContributor, ICompilerContributor,
|
: BaseJvmPlugin<KotlinConfig>(configActor), IDocContributor, IClasspathContributor, ICompilerContributor,
|
||||||
IBuildConfigContributor {
|
IBuildConfigContributor {
|
||||||
|
@ -95,7 +95,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depFa
|
||||||
|
|
||||||
private fun getKotlinCompilerJar(name: String): String {
|
private fun getKotlinCompilerJar(name: String): String {
|
||||||
val id = "org.jetbrains.kotlin:$name:${KotlinCompiler.KOTLIN_VERSION}"
|
val id = "org.jetbrains.kotlin:$name:${KotlinCompiler.KOTLIN_VERSION}"
|
||||||
val dep = depFactory.create(id)
|
val dep = dependencyManager.create(id)
|
||||||
val result = dep.jarFile.get().absolutePath
|
val result = dep.jarFile.get().absolutePath
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,7 @@ import javax.inject.Inject
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
@Guice(modules = arrayOf(TestModule::class))
|
@Guice(modules = arrayOf(TestModule::class))
|
||||||
public class DependencyTest @Inject constructor(val depFactory: DependencyFactory,
|
public class DependencyTest @Inject constructor(val executors: KobaltExecutors) {
|
||||||
val executors: KobaltExecutors) {
|
|
||||||
|
|
||||||
@DataProvider
|
@DataProvider
|
||||||
fun dpVersions(): Array<Array<out Any>> {
|
fun dpVersions(): Array<Array<out Any>> {
|
||||||
|
|
|
@ -18,7 +18,6 @@ class DownloadTest @Inject constructor(
|
||||||
val localRepo: LocalRepo,
|
val localRepo: LocalRepo,
|
||||||
val pomFactory: Pom.IFactory,
|
val pomFactory: Pom.IFactory,
|
||||||
val dependencyManager: DependencyManager,
|
val dependencyManager: DependencyManager,
|
||||||
val depFactory: DependencyFactory,
|
|
||||||
val aether: KobaltAether,
|
val aether: KobaltAether,
|
||||||
val executors: KobaltExecutors) : KobaltTest() {
|
val executors: KobaltExecutors) : KobaltTest() {
|
||||||
private var executor: ExecutorService by Delegates.notNull()
|
private var executor: ExecutorService by Delegates.notNull()
|
||||||
|
@ -40,7 +39,7 @@ class DownloadTest @Inject constructor(
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
arrayListOf("$groupId:$artifactId:$version", "$groupId:$artifactId:$previousVersion").forEach {
|
arrayListOf("$groupId:$artifactId:$version", "$groupId:$artifactId:$previousVersion").forEach {
|
||||||
val dep = depFactory.create(it)
|
val dep = dependencyManager.create(it)
|
||||||
val future = dep.jarFile
|
val future = dep.jarFile
|
||||||
val file = future.get()
|
val file = future.get()
|
||||||
Assert.assertTrue(file.exists(), "Couldn't find ${file.absolutePath}")
|
Assert.assertTrue(file.exists(), "Couldn't find ${file.absolutePath}")
|
||||||
|
@ -60,7 +59,7 @@ class DownloadTest @Inject constructor(
|
||||||
fun shouldDownloadNoVersion() {
|
fun shouldDownloadNoVersion() {
|
||||||
val success = deleteDir()
|
val success = deleteDir()
|
||||||
if (success) {
|
if (success) {
|
||||||
val dep = depFactory.create(idNoVersion)
|
val dep = dependencyManager.create(idNoVersion)
|
||||||
|
|
||||||
val future = dep.jarFile
|
val future = dep.jarFile
|
||||||
val file = future.get()
|
val file = future.get()
|
||||||
|
@ -77,7 +76,7 @@ class DownloadTest @Inject constructor(
|
||||||
val range = "[2.5,)"
|
val range = "[2.5,)"
|
||||||
val expected = "3.0-alpha-1"
|
val expected = "3.0-alpha-1"
|
||||||
|
|
||||||
val dep = depFactory.create("javax.servlet:servlet-api:$range")
|
val dep = dependencyManager.create("javax.servlet:servlet-api:$range")
|
||||||
val future = dep.jarFile
|
val future = dep.jarFile
|
||||||
val file = future.get()
|
val file = future.get()
|
||||||
Assert.assertEquals(file.name, "servlet-api-$expected.jar")
|
Assert.assertEquals(file.name, "servlet-api-$expected.jar")
|
||||||
|
@ -86,8 +85,8 @@ class DownloadTest @Inject constructor(
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun shouldFindLocalJar() {
|
fun shouldFindLocalJar() {
|
||||||
depFactory.create("$idNoVersion$version")
|
dependencyManager.create("$idNoVersion$version")
|
||||||
val dep = depFactory.create("$idNoVersion$version")
|
val dep = dependencyManager.create("$idNoVersion$version")
|
||||||
val future = dep.jarFile
|
val future = dep.jarFile
|
||||||
// Assert.assertTrue(future is CompletedFuture)
|
// Assert.assertTrue(future is CompletedFuture)
|
||||||
val file = future.get()
|
val file = future.get()
|
||||||
|
@ -96,11 +95,11 @@ class DownloadTest @Inject constructor(
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun shouldFindLocalJarNoVersion() {
|
fun shouldFindLocalJarNoVersion() {
|
||||||
val dep = depFactory.create("$idNoVersion$version")
|
val dep = dependencyManager.create("$idNoVersion$version")
|
||||||
val future = dep.jarFile
|
val future = dep.jarFile
|
||||||
future.get().delete()
|
future.get().delete()
|
||||||
|
|
||||||
val dep2 = depFactory.create("$idNoVersion$version")
|
val dep2 = dependencyManager.create("$idNoVersion$version")
|
||||||
val file = dep2.jarFile.get()
|
val file = dep2.jarFile.get()
|
||||||
Assert.assertNotNull(file)
|
Assert.assertNotNull(file)
|
||||||
Assert.assertTrue(file.exists(), "Couldn't find ${file.absolutePath}")
|
Assert.assertTrue(file.exists(), "Couldn't find ${file.absolutePath}")
|
||||||
|
@ -140,7 +139,7 @@ class DownloadTest @Inject constructor(
|
||||||
@Test
|
@Test
|
||||||
fun containerPomTest() {
|
fun containerPomTest() {
|
||||||
File(localRepo.toFullPath("nl/komponents/kovenant")).deleteRecursively()
|
File(localRepo.toFullPath("nl/komponents/kovenant")).deleteRecursively()
|
||||||
val dep = depFactory.create("nl.komponents.kovenant:kovenant:3.0.0")
|
val dep = dependencyManager.create("nl.komponents.kovenant:kovenant:3.0.0")
|
||||||
dep.directDependencies().forEach {
|
dep.directDependencies().forEach {
|
||||||
Assert.assertTrue(it.jarFile.get().exists(), "Dependency was not downloaded: $it")
|
Assert.assertTrue(it.jarFile.get().exists(), "Dependency was not downloaded: $it")
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@ import org.testng.Assert
|
||||||
import org.testng.annotations.Test
|
import org.testng.annotations.Test
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
class PomGenerationTest @Inject constructor(val depFactory: DependencyFactory): KobaltTest() {
|
class PomGenerationTest @Inject constructor(val dependencyManager: DependencyManager): KobaltTest() {
|
||||||
fun shouldGenerateDependencies() {
|
fun shouldGenerateDependencies() {
|
||||||
val md = depFactory.create("org.testng:testng:6.9.9").toMavenDependencies()
|
val md = dependencyManager.create("org.testng:testng:6.9.9").toMavenDependencies()
|
||||||
Assert.assertEquals(md.groupId, "org.testng")
|
Assert.assertEquals(md.groupId, "org.testng")
|
||||||
Assert.assertEquals(md.artifactId, "testng")
|
Assert.assertEquals(md.artifactId, "testng")
|
||||||
Assert.assertEquals(md.version, "6.9.9")
|
Assert.assertEquals(md.version, "6.9.9")
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
package com.beust.kobalt.maven
|
package com.beust.kobalt.maven
|
||||||
|
|
||||||
import com.beust.kobalt.Args
|
|
||||||
import com.beust.kobalt.TestModule
|
import com.beust.kobalt.TestModule
|
||||||
import com.beust.kobalt.misc.DependencyExecutor
|
|
||||||
import org.testng.Assert
|
import org.testng.Assert
|
||||||
import org.testng.annotations.Test
|
import org.testng.annotations.Test
|
||||||
import java.util.concurrent.ExecutorService
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@org.testng.annotations.Guice(modules = arrayOf(TestModule::class))
|
@org.testng.annotations.Guice(modules = arrayOf(TestModule::class))
|
||||||
class RemoteRepoTest @Inject constructor(val repoFinder: RepoFinder, val depFactory: DependencyFactory,
|
class RemoteRepoTest @Inject constructor(val repoFinder: RepoFinder, val dependencyManager: DependencyManager){
|
||||||
@DependencyExecutor val executor: ExecutorService, val args: Args){
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun mavenMetadata() {
|
fun mavenMetadata() {
|
||||||
val dep = depFactory.create("org.codehaus.groovy:groovy-all:")
|
val dep = dependencyManager.create("org.codehaus.groovy:groovy-all:")
|
||||||
// Note: this test might fail if a new version of Groovy gets uploaded, need
|
// Note: this test might fail if a new version of Groovy gets uploaded, need
|
||||||
// to find a stable (i.e. abandoned) package
|
// to find a stable (i.e. abandoned) package
|
||||||
with(dep.id.split(":")[2]) {
|
with(dep.id.split(":")[2]) {
|
||||||
|
@ -25,7 +21,7 @@ class RemoteRepoTest @Inject constructor(val repoFinder: RepoFinder, val depFact
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = false)
|
||||||
fun metadataForSnapshots() {
|
fun metadataForSnapshots() {
|
||||||
val jar = depFactory.create("org.apache.maven.wagon:wagon-provider-test:2.10-SNAPSHOT")
|
val jar = dependencyManager.create("org.apache.maven.wagon:wagon-provider-test:2.10-SNAPSHOT")
|
||||||
Assert.assertTrue(jar.jarFile.get().exists())
|
Assert.assertTrue(jar.jarFile.get().exists())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue