mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Move exclude() management to DependencyManager, where it belongs.
This commit is contained in:
parent
64437761a4
commit
b54c4c63c8
3 changed files with 21 additions and 20 deletions
|
@ -75,9 +75,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager
|
||||||
File(project.directory, buildDirectory.path).mkdirs()
|
File(project.directory, buildDirectory.path).mkdirs()
|
||||||
|
|
||||||
// Remove all the excluded dependencies from the classpath
|
// Remove all the excluded dependencies from the classpath
|
||||||
var classpath = fullClasspath.filter {
|
var classpath = fullClasspath
|
||||||
! isDependencyExcluded(it, project.excludedDependencies)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The classpath needs to contain $buildDirectory/classes as well so that projects that contain
|
// The classpath needs to contain $buildDirectory/classes as well so that projects that contain
|
||||||
// multiple languages can use classes compiled by the compiler run before them.
|
// multiple languages can use classes compiled by the compiler run before them.
|
||||||
|
@ -225,15 +223,4 @@ class CompilerUtils @Inject constructor(val files: KFiles, val dependencyManager
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
fun isDependencyExcluded(dep: IClasspathDependency, excluded: List<IClasspathDependency>)
|
|
||||||
= excluded.any { excluded -> dep.id.startsWith(excluded.id) }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,9 +91,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
scopes = listOf(Scope.TEST))
|
scopes = listOf(Scope.TEST))
|
||||||
val compileDependencies = dependencyManager.calculateDependencies(project, context,
|
val compileDependencies = dependencyManager.calculateDependencies(project, context,
|
||||||
scopes = listOf(Scope.COMPILE))
|
scopes = listOf(Scope.COMPILE))
|
||||||
val allDependencies = (compileDependencies + testDependencies)
|
val allDependencies = (compileDependencies + testDependencies).toHashSet()
|
||||||
.toHashSet()
|
|
||||||
.filter { ! CompilerUtils.isDependencyExcluded(it, project.excludedDependencies) }
|
|
||||||
return testContributor.run(project, context, configName, allDependencies.toList())
|
return testContributor.run(project, context, configName, allDependencies.toList())
|
||||||
} else {
|
} else {
|
||||||
context.logger.log(project.name, 2,
|
context.logger.log(project.name, 2,
|
||||||
|
|
|
@ -85,8 +85,10 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors,
|
||||||
// project.compileDependencies + project.compileRuntimeDependencies)
|
// project.compileDependencies + project.compileRuntimeDependencies)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the classpath for this project, including the IClasspathContributors.
|
* @return the classpath for this project, including the IClasspathContributors. Excluded dependencies
|
||||||
* allDependencies is typically either compileDependencies or testDependencies. If no dependencies
|
* are removed from the result.
|
||||||
|
*
|
||||||
|
* @param{allDependencies} is typically either compileDependencies or testDependencies. If no dependencies
|
||||||
* are passed, they are calculated from the scope filters.
|
* are passed, they are calculated from the scope filters.
|
||||||
*/
|
*/
|
||||||
override fun calculateDependencies(project: Project?, context: KobaltContext,
|
override fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||||
|
@ -130,10 +132,24 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors,
|
||||||
result.addAll(runClasspathContributors(project, context))
|
result.addAll(runClasspathContributors(project, context))
|
||||||
result.addAll(dependentProjectDependencies(project, context, dependencyFilter, scopes))
|
result.addAll(dependentProjectDependencies(project, context, dependencyFilter, scopes))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
fun isDependencyExcluded(dep: IClasspathDependency, excluded: List<IClasspathDependency>)
|
||||||
|
= excluded.any { excluded -> dep.id.startsWith(excluded.id) }
|
||||||
|
|
||||||
// Dependencies get reordered by transitiveClosure() but since we just added a bunch of new ones,
|
// Dependencies get reordered by transitiveClosure() but since we just added a bunch of new ones,
|
||||||
// we need to reorder them again in case we're adding dependencies that are already present
|
// we need to reorder them again in case we're adding dependencies that are already present
|
||||||
// but with a different version
|
// but with a different version
|
||||||
val reordered = reorderDependencies(result)
|
val shortResult =
|
||||||
|
if (project != null) {
|
||||||
|
result.filter { ! isDependencyExcluded(it, project.excludedDependencies) }
|
||||||
|
} else {
|
||||||
|
result
|
||||||
|
}
|
||||||
|
val reordered = reorderDependencies(shortResult)
|
||||||
return reordered
|
return reordered
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue