Allow scanning for key identifying methods
MODIFY
.gitignore
.gitignore
@@ -48,3 +48,4 @@ Thumbs.db
/bin
/out
*/out
+dd-trace-examples/*/out

ADD
buildSrc/src/main/groovy/ClassAnalyzer.groovy
+import org.objectweb.asm.ClassReader
+import org.objectweb.asm.tree.ClassNode
+
+import java.util.jar.JarEntry
+import java.util.jar.JarFile
+
+class ClassAnalyzer {
+ static def findMethodNames(JarFile jar, JarEntry entry) {
+ def stream = jar.getInputStream(entry)
+
+ def classNode = new ClassNode()
+ def cr = new ClassReader(stream)
+ cr.accept(classNode, 0)
+
+ return classNode.methods.collect { it.name }
+ }
+}

MODIFY
buildSrc/src/main/groovy/VersionScanPlugin.groovy
buildSrc/src/main/groovy/VersionScanPlugin.groovy
@@ -55,9 +55,9 @@ class VersionScanPlugin implements Plugin<Project> {
def exclusiveMissing = keyMissing.get().size()
if (project.hasProperty("showClasses")) {
- println "keyPresent: $inCommonPresent->$exclusivePresent - ${keyPresent.get()}"
+ println "keyPresent: ${allInclude.size()}->$inCommonPresent->$exclusivePresent - ${keyPresent.get()}"
println "+++++++++++++++++++++"
- println "keyMissing: $inCommonMissing->$exclusiveMissing - ${keyMissing.get()}"
+ println "keyMissing: ${allExclude.size()}->$inCommonMissing->$exclusiveMissing - ${keyMissing.get()}"
} else {
println "keyPresent: $inCommonPresent->$exclusivePresent"
println "keyMissing: $inCommonMissing->$exclusiveMissing"
@@ -105,11 +105,20 @@ class VersionScanPlugin implements Plugin<Project> {
def task = project.task(name) {
doLast {
+ Set<String> contentSet = Sets.newConcurrentHashSet()
project.configurations.getByName(name).resolvedConfiguration.files.each { jarFile ->
def jar = new JarFile(jarFile)
- Set<String> contentSet = Sets.newConcurrentHashSet()
for (jarEntry in jar.entries()) {
- contentSet.add(jarEntry.toString())
+ if (jarEntry.name.endsWith(".class")) {
+ if (project.versionScan.scanMethods) {
+ ClassAnalyzer.findMethodNames(jar, jarEntry).each {
+ contentSet.add("$jarEntry.name|$it")
+ }
+ } else {
+ contentSet.add("$jarEntry.name")
+ }
+ }
+ }
}
allInclude.addAll(contentSet)
@@ -119,7 +128,6 @@ class VersionScanPlugin implements Plugin<Project> {
}
}
}
- }
project.tasks.scanVersions.finalizedBy(task)
project.tasks.scanVersionsReport.mustRunAfter(task)
}
@@ -131,11 +139,20 @@ class VersionScanPlugin implements Plugin<Project> {
def task = project.task(name) {
doLast {
+ Set<String> contentSet = Sets.newConcurrentHashSet()
project.configurations.getByName(name).resolvedConfiguration.files.each { jarFile ->
def jar = new JarFile(jarFile)
- Set<String> contentSet = Sets.newConcurrentHashSet()
for (jarEntry in jar.entries()) {
- contentSet.add(jarEntry.toString())
+ if (jarEntry.name.endsWith(".class")) {
+ if (project.versionScan.scanMethods) {
+ ClassAnalyzer.findMethodNames(jar, jarEntry).each {
+ contentSet.add("$jarEntry.name|$it")
+ }
+ } else {
+ contentSet.add("$jarEntry.name")
+ }
+ }
+ }
}
allExclude.addAll(contentSet)
@@ -145,7 +162,6 @@ class VersionScanPlugin implements Plugin<Project> {
}
}
}
- }
project.tasks.scanVersions.finalizedBy(task)
project.tasks.scanVersionsReport.mustRunAfter(task)
}
@@ -155,7 +171,7 @@ class VersionScanPlugin implements Plugin<Project> {
def filter(List<Version> list) {
list.removeIf {
def version = it.toString().toLowerCase()
- return version.contains("rc") || version.contains("alpha") || version.contains("beta")
+ return version.contains("rc") || version.contains("alpha") || version.contains("beta") || version.contains("-b")
}
return list
}

Allow scanning for key identifying methods