运行 sonarrunner 时找不到类错误
我收到类未找到错误.该类无法通过类加载器访问,并且从 gradle 运行 sonarrunner 时会提示错误.
I am getting class not found error. The the class is not accessible through class loader and an error is being prompt when running the sonarrunner from gradle.
这些类在 gradle 中作为编译时的依赖项包含在内,并且 gradle build 可以正常工作.如何为声纳包含这些类?
These classes are included as dependencies in compile time in gradle and gradle build works fine. How to include these classes for sonar ?
14:53:24.322 INFO - Load module settings
14:53:24.335 INFO - Base dir: /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base
14:53:24.335 INFO - Working dir: /Users/srao1/Documents/GradleTest/lds_warehouse/build/sonar/lds_warehouse_lds_warehouse_base
14:53:24.336 INFO - Source paths: src
14:53:24.336 INFO - Test paths: test
14:53:24.336 INFO - Binary dirs: build/classes/main
14:53:24.336 INFO - Source encoding: UTF-8, default locale: en_US
14:53:24.336 INFO - Index files
14:53:24.444 INFO - 50 files indexed
14:53:24.593 INFO - Quality profile for java: Sonar way
14:53:24.604 INFO - Sensor JavaSquidSensor
14:53:24.620 WARN - sonar.binaries and sonar.libraries are deprecated since version 2.5 of sonar-java-plugin, please use sonar.java.binaries and sonar.java.libraries instead
14:53:24.628 INFO - Java Main Files AST scan...
14:53:24.628 INFO - 45 source files to be analyzed
14:53:25.070 ERROR - Class not found: com.lim.dw.dao.base.bean.WarehouseFeed
14:53:25.070 ERROR - Class not found: com.lim.dw.dao.base.bean.PhaseTimer
14:53:32.459 WARN - Class 'com/lim/lds/LdsDataFeed' is not accessible through the ClassLoader.
14:53:32.459 WARN - Class 'com/lim/lds/LdsDataFeed' is not accessible through the ClassLoader.
14:53:32.459 WARN - Class 'com/lim/logger/Logger' is not accessible through the ClassLoader.
14:53:32.459 WARN - Class 'com/lim/logger/Logger' is not accessible through the ClassLoader.
14:53:32.477 INFO - Java bytecode scan done: 162 ms
14:53:32.477 INFO - Java Test Files AST scan...
14:53:32.477 INFO - 5 source files to be analyzed
14:53:32.727 INFO - Java Test Files AST scan done: 250 ms
14:53:32.728 INFO - 5/5 source files have been analyzed
14:53:32.728 INFO - Package design analysis...
14:53:32.800 INFO - Package design analysis done: 72 ms
14:53:32.889 INFO - Sensor JavaSquidSensor (done) | time=8285ms
14:53:32.889 INFO - Sensor Lines Sensor
14:53:32.892 INFO - Sensor Lines Sensor (done) | time=3ms
14:53:32.892 INFO - Sensor QProfileSensor
14:53:32.894 INFO - Sensor QProfileSensor (done) | time=2ms
14:53:32.904 INFO - Sensor InitialOpenIssuesSensor
14:53:33.016 INFO - Sensor InitialOpenIssuesSensor (done) | time=112ms
14:53:33.016 INFO - Sensor ProjectLinksSensor
14:53:33.018 INFO - Sensor ProjectLinksSensor (done) | time=2ms
14:53:33.018 INFO - Sensor VersionEventsSensor
14:53:33.023 INFO - Sensor VersionEventsSensor (done) | time=5ms
14:53:33.023 INFO - Sensor SurefireSensor
14:53:33.023 INFO - parsing /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/target/surefire-reports
14:53:33.023 ERROR - Reports path not found or is not a directory: /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/target/surefire-reports
14:53:33.023 INFO - Sensor SurefireSensor (done) | time=0ms
14:53:33.023 INFO - Sensor JaCoCoOverallSensor
14:53:33.037 WARN - You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
14:53:33.037 INFO - Analysing /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/build/jacoco/jacocoTest.exec
14:53:33.072 WARN - You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
14:53:33.072 INFO - Analysing /Users/srao1/Documents/GradleTest/lds_warehouse/build/sonar/lds_warehouse_lds_warehouse_base/jacoco-overall.exec
14:53:33.234 INFO - No information about coverage per test.
14:53:33.234 INFO - Sensor JaCoCoOverallSensor (done) | time=211ms
14:53:33.234 INFO - Sensor SCM Sensor
14:53:33.234 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
14:53:33.234 INFO - Sensor SCM Sensor (done) | time=0ms
14:53:33.234 INFO - Sensor JaCoCoSensor
14:53:33.236 WARN - You are not using the latest JaCoCo binary format version, please consider upgrading to latest JaCoCo version.
14:53:33.236 INFO - Analysing /Users/srao1/Documents/GradleTest/lds_warehouse/lds_warehouse_base/build/jacoco/jacocoTest.exec
14:53:33.306 INFO - No information about coverage per test.
14:53:33.306 INFO - Sensor JaCoCoSensor (done) | time=72ms
14:53:33.306 INFO - Sensor CPD Sensor
14:53:33.306 INFO - JavaCpdEngine is used for java
14:53:33.307 INFO - Cross-project analysis disabled
14:53:33.545 INFO - Sensor CPD Sensor (done) | time=239ms
14:53:33.546 INFO - No quality gate is configured.
14:53:33.549 INFO - Compare to previous analysis (2015-07-23)
14:53:33.550 INFO - Compare over 30 days (2015-06-24, analysis of Wed Jul 22 16:29:23 CDT 2015)
14:53:33.716 INFO - Execute decorators...
推荐答案
要执行源代码分析,SQ Java 插件除了源代码之外还需要字节码.源文件的字节码位置由 sonar.java.binaries
和 sonar.java.test.binaries
属性提供.第三方库的字节码(或 JAR)位置由属性 sonar.java.libraries
和 sonar.java.test.libraries
提供.
To perform source code analysis the SQ Java plugin needs bytecode in addition to the source code. Bytecode location for source files is provided thanks to properties sonar.java.binaries
and sonar.java.test.binaries
. Bytecode (or JAR) locations for third party libs is provided by properties sonar.java.libraries
and sonar.java.test.libraries
.
如果您没有正确提供这些属性,那么您会看到一些找不到类"错误.这并不妨碍完成分析,但许多 SQ Java 规则可能不起作用,也不会检测到任何问题.
If you don't provide correctly those properties then you'll see some 'Class not found' errors. That doesn't prevent to complete the analysis but many SQ Java rules will probably not work and not detect any issue.
(部分)示例:sonar-runner -Dsonar.sources=src -Dsonar.java.binaries=bin/classes -Dsonar.java.libraries=libs/*.jar
相关文章