-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added plugin to auto-exclude commons-logging, possibly more to …
…be added in the future
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
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
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/sh/tnn/gradle/plugins/auto_exclude/AutoExcludePlugin.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,26 @@ | ||
package sh.tnn.gradle.plugins.auto_exclude | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import sh.tnn.gradle.plugins.dotenv.DotEnvPlugin | ||
|
||
class AutoExcludePlugin : Plugin<Project> { | ||
companion object { | ||
val excluded = arrayOf( | ||
"commons-logging:commons-logging" unlessKeep "commons-logging", | ||
) | ||
} | ||
|
||
override fun apply(project: Project) { | ||
val keep = (DotEnvPlugin.get(project, "AUTO_EXCLUDE_KEEP") ?: "").split(",").map { it.trim().lowercase() } | ||
project.configurations.all { conf -> | ||
excluded.forEach { notation -> | ||
if (notation.second in keep) return@forEach | ||
val (group, module) = notation.first.split(":") | ||
conf.exclude(mapOf("group" to group, "module" to module)) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private infix fun String.unlessKeep(other: String): Pair<String, String> = this to other.lowercase() |