mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Add exclude() dependencies.
This commit is contained in:
parent
c5cc1009ba
commit
db6e74b127
2 changed files with 26 additions and 4 deletions
|
@ -77,7 +77,8 @@ open class Project(
|
|||
|
||||
@Directive
|
||||
fun dependencies(init: Dependencies.() -> Unit) : Dependencies {
|
||||
dependencies = Dependencies(this, compileDependencies, compileProvidedDependencies, compileRuntimeDependencies)
|
||||
dependencies = Dependencies(this, compileDependencies, compileProvidedDependencies, compileRuntimeDependencies,
|
||||
excludedDependencies)
|
||||
dependencies!!.init()
|
||||
return dependencies!!
|
||||
}
|
||||
|
@ -85,10 +86,12 @@ open class Project(
|
|||
val compileDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val compileProvidedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val compileRuntimeDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
val excludedDependencies : ArrayList<IClasspathDependency> = arrayListOf()
|
||||
|
||||
@Directive
|
||||
fun dependenciesTest(init: Dependencies.() -> Unit) : Dependencies {
|
||||
dependencies = Dependencies(this, testDependencies, testProvidedDependencies, compileRuntimeDependencies)
|
||||
dependencies = Dependencies(this, testDependencies, testProvidedDependencies, compileRuntimeDependencies,
|
||||
excludedDependencies)
|
||||
dependencies!!.init()
|
||||
return dependencies!!
|
||||
}
|
||||
|
@ -130,7 +133,8 @@ class Sources(val project: Project, val sources: HashSet<String>) {
|
|||
|
||||
class Dependencies(val project: Project, val dependencies: ArrayList<IClasspathDependency>,
|
||||
val providedDependencies: ArrayList<IClasspathDependency>,
|
||||
val runtimeDependencies: ArrayList<IClasspathDependency>) {
|
||||
val runtimeDependencies: ArrayList<IClasspathDependency>,
|
||||
val excludedDependencies: ArrayList<IClasspathDependency>) {
|
||||
@Directive
|
||||
fun compile(vararg dep: String) {
|
||||
dep.forEach { dependencies.add(MavenDependency.create(it)) }
|
||||
|
@ -145,6 +149,11 @@ class Dependencies(val project: Project, val dependencies: ArrayList<IClasspathD
|
|||
fun runtime(vararg dep: String) {
|
||||
dep.forEach { runtimeDependencies.add(MavenDependency.create(it))}
|
||||
}
|
||||
|
||||
@Directive
|
||||
fun exclude(vararg dep: String) {
|
||||
dep.forEach { excludedDependencies.add(MavenDependency.create(it))}
|
||||
}
|
||||
}
|
||||
|
||||
class Scm(val connection: String, val developerConnection: String, val url: String)
|
||||
|
|
|
@ -212,6 +212,14 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Naïve implementation: just exclude all dependencies that start with one of the excluded dependencies.
|
||||
* Should probably make exclusion more generic (full on string) or allow exclusion to be specified
|
||||
* formally by groupId or artifactId.
|
||||
*/
|
||||
private fun isDependencyExcluded(id: IClasspathDependency, excluded: List<IClasspathDependency>)
|
||||
= excluded.any { id.id.startsWith(it.id) }
|
||||
|
||||
/**
|
||||
* Create a CompilerActionInfo (all the information that a compiler needs to know) for the given parameters.
|
||||
* Runs all the contributors and interceptors relevant to that task.
|
||||
|
@ -220,11 +228,16 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
|||
CompilerActionInfo {
|
||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
||||
|
||||
val classpath = if (isTest)
|
||||
val fullClasspath = if (isTest)
|
||||
dependencyManager.testDependencies(project, context, projects)
|
||||
else
|
||||
dependencyManager.dependencies(project, context, projects)
|
||||
|
||||
// Remove all the excluded dependencies from the classpath
|
||||
val classpath = fullClasspath.filter {
|
||||
! isDependencyExcluded(it, project.excludedDependencies)
|
||||
}
|
||||
|
||||
val projectDirectory = File(project.directory)
|
||||
val buildDirectory = if (isTest) KFiles.makeOutputTestDir(project)
|
||||
else File(project.classesDir(context))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue