1

I want to understand the scanning process of jqassistant in detail. For example will it scan all Jar-Files and all classes or only the one I directly reference from my classes. To answer such questions debugging is often a good option. How ever normally you start jqassistant as maven plugin. Debug maven plugin is not so easy. So I thought it's better to checkout the commandline-client. Debugging works fine, but unfortunately I get a complete different result. Here are my parameter scan --files ${project_loc:/sze}/target/classes,${project_loc:/sze}/target/test-classes --storeDirectory c:/trash/neo4j. The output is the same as in the maven-build it scans 441 and then 106 classes.

Can anyone give me a hint, what's wrong with the commandline-call? Or what whould be the best solution to answer the question from the beginning.

niels
  • 7,321
  • 2
  • 38
  • 58

1 Answers1

1

I think the best option is to debug the maven-plugin, because then all configuration and classpath-problems are solved. This isn't as complicated as I thought. The following step solve my problems:

  1. clone the project git clone https://github.com/buschmais/jqa-maven-plugin.git and checkout a stable version, for example git checkout -b 1.2.0
  2. Import jqassistant-maven-plugin into your eclipse workspace.
  3. Prepare your maven-run-configuration and add -Xdebug -Xnoagent -Djava.compile=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 as VM-Arguments.
  4. Create a debug-configuration for Remote Java Application and choose as Project jqassistant-maven-plugin. Set Connection Properties to localhost and 5005
  5. Set a breakpoint in ScannerImpl in methode scan. Further good candidates are the ClassFileScannerPlugin and ClassVisitor.
  6. Start the maven run configuration and then start the debug-configuration.

Now you can easily debug the code. Unfortunately many visitor patterns makes it difficult to understand how it works.

Based on my analysis I can say, that only file in classes and test-classes are analyzed. All classes from library only come into the database via reference. I guess that the org.objectweb.asm.ClassReader doesn't simply ignores references which are not in the classpath. This is the reason why the command line version doesn't find so much elements.

niels
  • 7,321
  • 2
  • 38
  • 58
  • The Maven plugin decides which elements are going to be scanned. As default these are the class folders for the main and the test artifacts. The ClassFileScannerPlugin is triggered for each .class file found in these folders. Additionally the scanIncludes option allows adding more files (e.g. additional src/main/ folders) to be added There's an idea to scan the whole file content of a Maven module as a default but this would be a feature request. – Dirk Mahler Mar 01 '17 at 15:30