Skip to content

Commit

Permalink
add exclusions to pom file
Browse files Browse the repository at this point in the history
  • Loading branch information
mneedham committed Apr 6, 2020
1 parent fbeedab commit 9729fc6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.gradle.api.internal.artifacts.DefaultExcludeRule

plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '4.0.2'
Expand Down Expand Up @@ -415,20 +417,27 @@ publishing {

def dependenciesNode = root.get("dependencies")[0]

configurations.implementation.allDependencies.forEach {
configurations.default.allDependencies.forEach {
def dependency = dependenciesNode.appendNode('dependency')
dependency.appendNode('groupId', it.group)
dependency.appendNode('artifactId', it.name)
dependency.appendNode('version', it.version)
dependency.appendNode('scope', "compile")

def myExcludeRules = it.excludeRules
if (myExcludeRules.size() == 0) {
myExcludeRules = new HashSet<>()
}

myExcludeRules.add(new DefaultExcludeRule("org.slf4j", "slf4j-nop"))

// for exclusions
if (it.excludeRules.size() > 0) {
if (myExcludeRules.size() > 0) {
def exclusions = dependency.appendNode('exclusions')
it.excludeRules.each { ExcludeRule ex ->
myExcludeRules.each { ExcludeRule ex ->
def exclusion = exclusions.appendNode('exclusion')
exclusion.appendNode('artifactId', ex.module ? ex.module : "*")
exclusion.appendNode('groupId', ex.group)
exclusion.appendNode('artifactId', ex.module)
}
}

Expand Down

0 comments on commit 9729fc6

Please sign in to comment.