@@ -47,42 +47,35 @@ internal sealed class AbstractDependencyFilter(
47
47
48
48
override fun project (notation : Any ): Spec <ResolvedDependency > {
49
49
@Suppress(" UNCHECKED_CAST" )
50
- return when (notation) {
51
- is ProjectDependency -> dependency( notation)
52
- is Provider <* > -> project( notation.get() as String )
53
- is String -> project( notation)
54
- is Map <* , * > -> project( notation as Map <String , * >)
55
- else -> error (" Unsupported notation type: ${notation::class .java} " )
50
+ val realNotation = when (notation) {
51
+ is ProjectDependency -> return notation.toSpec( )
52
+ is Provider <* > -> mapOf ( " path " to notation.get())
53
+ is String -> mapOf ( " path " to notation)
54
+ is Map <* , * > -> notation as Map <String , Any >
55
+ else -> throw IllegalArgumentException (" Unsupported notation type: ${notation::class .java} " )
56
56
}
57
- }
58
-
59
- override fun project (notation : Map <String , * >): Spec <ResolvedDependency > {
60
- return dependency(project.dependencies.project(notation))
61
- }
62
-
63
- override fun project (path : String ): Spec <ResolvedDependency > {
64
- return project(mapOf (" path" to path))
57
+ return project.dependencies.project(realNotation).toSpec()
65
58
}
66
59
67
60
override fun dependency (dependencyNotation : Any ): Spec <ResolvedDependency > {
68
61
val realNotation = when (dependencyNotation) {
69
62
is Provider <* > -> dependencyNotation.get()
70
63
else -> dependencyNotation
71
64
}
72
- return dependency(project.dependencies.create(realNotation))
73
- }
74
-
75
- override fun dependency (dependency : Dependency ): Spec <ResolvedDependency > {
76
- return Spec <ResolvedDependency > { resolvedDependency ->
77
- (dependency.group == null || resolvedDependency.moduleGroup.matches(dependency.group!! .toRegex())) &&
78
- resolvedDependency.moduleName.matches(dependency.name.toRegex()) &&
79
- (dependency.version == null || resolvedDependency.moduleVersion.matches(dependency.version!! .toRegex()))
80
- }
65
+ return project.dependencies.create(realNotation).toSpec()
81
66
}
82
67
83
68
protected fun ResolvedDependency.isIncluded (): Boolean {
84
69
val include = includeSpecs.isEmpty() || includeSpecs.any { it.isSatisfiedBy(this ) }
85
70
val exclude = excludeSpecs.isNotEmpty() && excludeSpecs.any { it.isSatisfiedBy(this ) }
86
71
return include && ! exclude
87
72
}
73
+
74
+ private fun Dependency.toSpec (): Spec <ResolvedDependency > {
75
+ return Spec <ResolvedDependency > { resolvedDependency ->
76
+ (group == null || resolvedDependency.moduleGroup.matches(group!! .toRegex())) &&
77
+ resolvedDependency.moduleName.matches(name.toRegex()) &&
78
+ (version == null || resolvedDependency.moduleVersion.matches(version!! .toRegex()))
79
+ }
80
+ }
88
81
}
0 commit comments