Skip to content

Commit 2c34254

Browse files
authored
Automatically exclude JUnit 5 metadata files (#233)
The default PackagingOptions catch a lot of these META-INF files already, but JUnit dependencies have Markdown versions of their licenses, which trip up the instrumentation tests ("duplicate file entry" etc).
1 parent f2bfb7b commit 2c34254

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

plugin/android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/Plugin.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ class AndroidJUnitPlatformPlugin : Plugin<Project> {
4545
}
4646

4747
private fun Project.configureExtensions() {
48+
// Add default ignore rules for JUnit 5 metadata files to the packaging options of the plugin,
49+
// so that consumers don't need to do this explicitly
50+
excludedPackagingOptions().forEach(android.packagingOptions::exclude)
51+
4852
// Hook the JUnit Platform configuration into the Android testOptions
4953
attachDsl(this, projectConfig)
5054
}

plugin/android-junit5/src/main/kotlin/de/mannodermaus/gradle/plugins/junit5/internal/Extensions.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ import java.util.Properties
3333

3434
/* General */
3535

36+
internal fun excludedPackagingOptions() = listOf(
37+
"/META-INF/LICENSE.md",
38+
"/META-INF/LICENSE-notice.md"
39+
)
40+
3641
internal fun requireGradle(version: String, message: () -> String) {
3742
require(GradleVersion.current() >= GradleVersion.version(version)) {
3843
throw GradleException(message())

0 commit comments

Comments
 (0)