mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Include global excludes.
This commit is contained in:
parent
934ffb01f5
commit
229e0b8f36
3 changed files with 12 additions and 7 deletions
|
@ -40,7 +40,8 @@ interface IDependencyManager {
|
||||||
* allDependencies is typically either compileDependencies or testDependencies
|
* allDependencies is typically either compileDependencies or testDependencies
|
||||||
*/
|
*/
|
||||||
fun calculateDependencies(project: Project?, context: KobaltContext,
|
fun calculateDependencies(project: Project?, context: KobaltContext,
|
||||||
dependencyFilter: DependencyFilter = createDependencyFilter(project?.compileDependencies ?: emptyList()),
|
dependencyFilter: DependencyFilter =
|
||||||
|
createDependencyFilter(project, project?.compileDependencies ?: emptyList()),
|
||||||
scopes: List<Scope> = listOf(Scope.COMPILE),
|
scopes: List<Scope> = listOf(Scope.COMPILE),
|
||||||
vararg passedDependencies: List<IClasspathDependency>): List<IClasspathDependency>
|
vararg passedDependencies: List<IClasspathDependency>): List<IClasspathDependency>
|
||||||
|
|
||||||
|
@ -48,21 +49,25 @@ interface IDependencyManager {
|
||||||
* Create an Aether dependency filter that uses the dependency configuration included in each
|
* Create an Aether dependency filter that uses the dependency configuration included in each
|
||||||
* IClasspathDependency.
|
* IClasspathDependency.
|
||||||
*/
|
*/
|
||||||
fun createDependencyFilter(dependencies: List<IClasspathDependency>) : DependencyFilter {
|
fun createDependencyFilter(project: Project?, dependencies: List<IClasspathDependency>) : DependencyFilter {
|
||||||
return DependencyFilter { p0, p1 ->
|
return DependencyFilter { p0, p1 ->
|
||||||
fun isNodeExcluded(passedDep: IClasspathDependency, node: DependencyNode) : Boolean {
|
fun isNodeExcluded(node: DependencyNode, passedDep: IClasspathDependency) : Boolean {
|
||||||
val dep = create(KobaltMavenResolver.artifactToId(node.artifact))
|
val dep = create(KobaltMavenResolver.artifactToId(node.artifact))
|
||||||
return passedDep.excluded.any { ex -> ex.isExcluded(dep)}
|
return passedDep.excluded.any { ex -> ex.isExcluded(dep)}
|
||||||
}
|
}
|
||||||
|
fun isDepExcluded(node: DependencyNode, excluded: List<IClasspathDependency>?) : Boolean {
|
||||||
|
val dep = create(KobaltMavenResolver.artifactToId(node.artifact))
|
||||||
|
return excluded?.map { it.id }?.contains(dep.id) ?: false
|
||||||
|
}
|
||||||
|
|
||||||
val accept = dependencies.any {
|
val accept = dependencies.any {
|
||||||
// Is this dependency excluded?
|
// Is this dependency excluded?
|
||||||
val isExcluded = isNodeExcluded(it, p0)
|
val isExcluded = isNodeExcluded(p0, it) || isDepExcluded(p0, project?.excludedDependencies)
|
||||||
|
|
||||||
// Is the parent dependency excluded?
|
// Is the parent dependency excluded?
|
||||||
val isParentExcluded =
|
val isParentExcluded =
|
||||||
if (p1.any()) {
|
if (p1.any()) {
|
||||||
isNodeExcluded(it, p1[0])
|
isNodeExcluded(p1[0], it) || isDepExcluded(p1[0], project?.excludedDependencies)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
if (testContributor != null && testContributor.affinity(project, context) > 0) {
|
if (testContributor != null && testContributor.affinity(project, context) > 0) {
|
||||||
// val td1 = dependencyManager.testDependencies(project, context)
|
// val td1 = dependencyManager.testDependencies(project, context)
|
||||||
val testDependencies = dependencyManager.calculateDependencies(project, context,
|
val testDependencies = dependencyManager.calculateDependencies(project, context,
|
||||||
dependencyFilter = dependencyManager.createDependencyFilter(project.testDependencies),
|
dependencyFilter = dependencyManager.createDependencyFilter(project, project.testDependencies),
|
||||||
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))
|
||||||
|
|
|
@ -140,7 +140,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors,
|
||||||
* formally by groupId or artifactId.
|
* formally by groupId or artifactId.
|
||||||
*/
|
*/
|
||||||
fun isDependencyExcluded(dep: IClasspathDependency, excluded: List<IClasspathDependency>): Boolean {
|
fun isDependencyExcluded(dep: IClasspathDependency, excluded: List<IClasspathDependency>): Boolean {
|
||||||
excluded.any { excluded -> dep.id.startsWith(excluded.id) }.let { result ->
|
excluded.any { excluded -> dep.id == excluded.id }.let { result ->
|
||||||
if (result) {
|
if (result) {
|
||||||
context.logger.log(project?.name ?: "", 2, " Excluding dependency $dep")
|
context.logger.log(project?.name ?: "", 2, " Excluding dependency $dep")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue