我找不到课程错误。无法通过类加载器访问该类,并且从gradle运行sonarrunner时会出现错误提示。
这些类作为依赖项包含在gradle的编译时,gradle构建工作正常。如何在声纳中包含这些类?
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...
答案 0 :(得分:9)
要执行源代码分析,除源代码外,SQ Java插件还需要字节码。由于属性sonar.java.binaries
和sonar.java.test.binaries
,提供了源文件的字节码位置。第三方库的字节码(或JAR)位置由属性sonar.java.libraries
和sonar.java.test.libraries
提供。
如果您没有正确提供这些属性,那么您会看到一些“未找到类”错误。这并不妨碍完成分析,但许多SQ Java规则可能无法正常工作,也无法检测到任何问题。
(部分)示例:
sonar-runner -Dsonar.sources=src -Dsonar.java.binaries=bin/classes -Dsonar.java.libraries=libs/*.jar