Skip to content

Commit fc9a801

Browse files
authored
Document wildcard dependency matching in DependencyFilter (#1596)
* Update `excludeDependencyUsingWildcardSyntax` * Add more examples for `Using Regex Patterns to Filter Dependencies`
1 parent d946bb8 commit fc9a801

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

docs/configuration/dependencies/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,14 @@ Any of the individual fields can be safely absent and will function as though a
229229

230230
The above code snippet is functionally equivalent to the previous example.
231231

232-
This same pattern can be used for any of the dependency notation fields.
232+
This same pattern can be used for any of the dependency notation fields. e.g.
233+
234+
- `org.apache.logging.log4j:.*`
235+
- `org.apache.logging.log4j:log4j.*`
236+
- `org.apache.logging.log4j:log4j-core:.*`
237+
- `org.apache.logging.*:log4j-core:.*`
238+
- `.*:log4j-core:.*`
239+
- ...
233240

234241
=== "Kotlin"
235242

src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/FilteringTest.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.BeforeAll
88
import org.junit.jupiter.api.BeforeEach
99
import org.junit.jupiter.api.Test
1010
import org.junit.jupiter.params.ParameterizedTest
11+
import org.junit.jupiter.params.provider.MethodSource
1112
import org.junit.jupiter.params.provider.ValueSource
1213

1314
class FilteringTest : BasePluginTest() {
@@ -73,16 +74,17 @@ class FilteringTest : BasePluginTest() {
7374
commonAssertions()
7475
}
7576

76-
@Test
77-
fun excludeDependencyUsingWildcardSyntax() {
77+
@ParameterizedTest
78+
@MethodSource("wildcardDepProvider")
79+
fun excludeDependencyUsingWildcardSyntax(wildcard: String) {
7880
projectScriptPath.appendText(
7981
"""
8082
dependencies {
8183
implementation 'my:d:1.0'
8284
}
8385
$shadowJar {
8486
dependencies {
85-
exclude(dependency('my:d:.*'))
87+
exclude(dependency('$wildcard'))
8688
}
8789
}
8890
""".trimIndent(),
@@ -240,4 +242,16 @@ class FilteringTest : BasePluginTest() {
240242
)
241243
}
242244
}
245+
246+
private companion object {
247+
@JvmStatic
248+
fun wildcardDepProvider() = listOf(
249+
"my:d",
250+
"m.*:d",
251+
"my:d:.*",
252+
"m.*:d:.*",
253+
"m.*:d.*:.*",
254+
".*:d:.*",
255+
)
256+
}
243257
}

0 commit comments

Comments
 (0)