@@ -55,12 +55,49 @@ publishing {
55
55
56
56
pom. withXml {
57
57
def dependenciesNode = asNode(). appendNode(' dependencies' )
58
- // Iterate over the implementation dependencies and add them to the pom.xml
59
- configurations. implementation. allDependencies. each {
58
+
59
+ // Log the start of dependency processing
60
+ def dependencyExclusions = [:]
61
+
62
+ // Create a map of dependencies and their exclusion rules
63
+ configurations. implementation. allDependencies
64
+ .findAll { dep -> ! dep. excludeRules?. isEmpty() }
65
+ .forEach { dep ->
66
+ def rules = dep. excludeRules. collect { rule ->
67
+ [groupId : rule. group, artifactId : rule. module]
68
+ }
69
+ // Use group:name as the key
70
+ dependencyExclusions. put(String . valueOf(" ${ dep.group} :${ dep.name} " ), rules)
71
+ }
72
+
73
+ // Iterate over implementation dependencies
74
+ configurations. implementation. allDependencies. each { dependency ->
75
+ def dependencyKey = " ${ dependency.group} :${ dependency.name} "
76
+ logger. lifecycle(" Dependency key class map: ${ dependencyKey.getClass()} " )
77
+
78
+ def exclusions = dependencyExclusions[dependencyKey]
79
+ logger. lifecycle(" Looking for exclusion: ${ dependencyKey} " )
80
+
81
+ // Add the dependency to the POM
60
82
def dependencyNode = dependenciesNode. appendNode(' dependency' )
61
- dependencyNode. appendNode(' groupId' , it. group)
62
- dependencyNode. appendNode(' artifactId' , it. name)
63
- dependencyNode. appendNode(' version' , it. version)
83
+ dependencyNode. appendNode(' groupId' , dependency. group ?: ' unknown-group' )
84
+ dependencyNode. appendNode(' artifactId' , dependency. name ?: ' unknown-artifact' )
85
+ dependencyNode. appendNode(' version' , dependency. version ?: ' unspecified-version' )
86
+
87
+ if (exclusions) {
88
+ // Add exclusions to the current dependency if applicable
89
+ def exclusionsNode = dependencyNode. appendNode(' exclusions' )
90
+ exclusions. each { exclusion ->
91
+ def exclusionNode = exclusionsNode. appendNode(' exclusion' )
92
+ exclusionNode. appendNode(' groupId' , exclusion. groupId)
93
+ exclusionNode. appendNode(' artifactId' , exclusion. artifactId)
94
+ }
95
+
96
+ // Log the added exclusions
97
+ logger. lifecycle(" Added exclusions for dependency: group='${ dependency.group} ', name='${ dependency.name} ', exclusions=${ exclusions} " )
98
+ } else {
99
+ logger. lifecycle(" No exclusions for dependency: group='${ dependency.group} ', name='${ dependency.name} '" )
100
+ }
64
101
}
65
102
}
66
103
}
0 commit comments