-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply a specific rule to exclude JUnit
This avoids excluding junit from the test classpath, even if explicitly added by a downstream user, which doesn't make sense, and allows people to add junit to the main classpath if they need to for some reason.
- Loading branch information
1 parent
de15167
commit bee8002
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ght-userdev/src/main/kotlin/io/papermc/paperweight/userdev/internal/JunitExclusionRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* paperweight is a Gradle plugin for the PaperMC project. | ||
* | ||
* Copyright (c) 2023 Kyle Wood (DenWav) | ||
* Contributors | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; | ||
* version 2.1 only, no later versions. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 | ||
* USA | ||
*/ | ||
|
||
package io.papermc.paperweight.userdev.internal | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Excludes `junit:junit` from the transitive dependencies of all variants. | ||
*/ | ||
@CacheableRule | ||
abstract class JunitExclusionRule : ComponentMetadataRule { | ||
override fun execute(ctx: ComponentMetadataContext) { | ||
ctx.details.allVariants { | ||
withDependencies { | ||
removeIf { | ||
it.group == "junit" && it.name == "junit" | ||
} | ||
} | ||
} | ||
} | ||
} |