task checkCompileDuplicateClasses {
group = "Verification"
description = "Checks for duplicate classes in the compile classpath."
doLast {
def classMap = [:]
def duplicatesFound = false
// Switching to compileClasspath to mirror what the compiler and JIT see
configurations.compileClasspath.each { file ->
if (file.name.endsWith('.jar')) {
def zip = new java.util.zip.ZipFile(file)
try {
zip.entries().each { entry ->
// We only care about .class files
if (entry.name.endsWith('.class') && !entry.name.contains('META-INF')) {
if (classMap.containsKey(entry.name)) {
println "CLASS CONFLICT: ${entry.name}"
println " [Priority] 1. ${classMap[entry.name]}"
println " [Shadowed] 2. ${file.name}"
println "--------------------------------------"
duplicatesFound = true
} else {
classMap[entry.name] = file.name
}
}
}
} finally {
zip.close()
}
}
}
if (duplicatesFound) {
println "⚠️ WARNING: Duplicate classes found. The JIT will prioritize the JAR listed first (Priority 1)."
} else {
println "No compile-time duplicates found! ✅"
}
}
}
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)