【问题标题】:maven sonar problemmaven声纳问题
【发布时间】:2011-03-02 12:41:42
【问题描述】:

我想使用声纳进行分析,但我无法在 localhost:9000 中获取任何数据

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>KIS</artifactId>
  <groupId>KIS</groupId>
  <version>1.0</version>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
              <tasks>
                <property name="compile_classpath" refid="maven.compile.classpath"/>
                <property name="runtime_classpath" refid="maven.runtime.classpath"/>
                <property name="test_classpath" refid="maven.test.classpath"/>
                <property name="plugin_classpath" refid="maven.plugin.classpath"/>
                <ant antfile="${basedir}/build.xml">
                  <target name="maven-compile"/>
                </ant>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

运行声纳时输出:jar 文件为空

[INFO] Executed tasks
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory J:\ostalo_6i\KIS deploy\ANT\src\test\resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] No sources to compile
[INFO] [surefire:test {execution: default-test}]
[INFO] No tests to run.
[INFO] [jar:jar {execution: default-jar}]
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: J:\ostalo_6i\KIS deploy\ANT\target\KIS-1.0.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing J:\ostalo_6i\KIS deploy\ANT\target\KIS-1.0.jar to C:\Documents and Settings\MitjaG\.m2\repository\KIS\KIS\1.0\KIS-1.0.jar
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - KIS:KIS:jar:1.0
[INFO]    task-segment: [sonar:sonar] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [sonar:sonar {execution: default-cli}]
[INFO] Sonar host: http://localhost:9000
[INFO] Sonar version: 2.1.2
[INFO] [sonar-core:internal {execution: default-internal}]
[INFO]  Database dialect class org.sonar.api.database.dialect.Oracle
[INFO]  -------------  Analyzing Unnamed - KIS:KIS:jar:1.0
[INFO]  Selected quality profile : KIS, language=java
[INFO]  Configure maven plugins...
[INFO]  Sensor SquidSensor...
[INFO]  Sensor SquidSensor done: 16 ms
[INFO]  Sensor JavaSourceImporter...
[INFO]  Sensor JavaSourceImporter done: 0 ms
[INFO]  Sensor AsynchronousMeasuresSensor...
[INFO]  Sensor AsynchronousMeasuresSensor done: 15 ms
[INFO]  Sensor SurefireSensor...
[INFO]  parsing J:\ostalo_6i\KIS deploy\ANT\target\surefire-reports
[INFO]  Sensor SurefireSensor done: 47 ms
[INFO]  Sensor ProfileSensor...
[INFO]  Sensor ProfileSensor done: 16 ms
[INFO]  Sensor ProjectLinksSensor...
[INFO]  Sensor ProjectLinksSensor done: 0 ms
[INFO]  Sensor VersionEventsSensor...
[INFO]  Sensor VersionEventsSensor done: 31 ms
[INFO]  Sensor CpdSensor...
[INFO]  Sensor CpdSensor done: 0 ms
[INFO]  Sensor Maven dependencies...
[INFO]  Sensor Maven dependencies done: 16 ms
[INFO]  Execute decorators...
[INFO]  ANALYSIS SUCCESSFUL, you can browse http://localhost:9000
[INFO]  Database optimization...
[INFO]  Database optimization done: 172 ms
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6 minutes 16 seconds
[INFO] Finished at: Fri Jun 11 08:28:26 CEST 2010
[INFO] Final Memory: 24M/43M
[INFO] ------------------------------------------------------------------------

知道为什么,我使用 maven ant 插件 java 项目成功编译。

【问题讨论】:

    标签: maven-2 ant sonarqube


    【解决方案1】:

    【讨论】:

    • 嗯,我使用的是 oracle DB 而不是 postgre
    【解决方案2】:

    你确定你启动了声纳服务器吗?您可以检查它是否仍在运行。

    我还发现 POM 和问题之间几乎没有相关性,输出中的运行时表明您的计算机速度非常快,或者它什么也没做。

    我会先确保您有一些可以正常编译/测试/安装的类和单元测试,然后再尝试从 Sonar 中获取某些内容。

    【讨论】:

    • 是的,声纳正在工作。我是否必须指定我的项目类在哪里。编译 java sorce 代码时,无法从 maven ant 看到声纳?
    【解决方案3】:

    Maven 不编译任何东西,并在此处构建一个空 jar(没有要编译的源代码没有要运行的测试JAR 将是空的 - 否内容被标记为包含!)因此,当 Sonar 处理它时,实际上没有什么可分析的。

    实际上,我认为将 Ant 构建包装到 Maven 项目中对于 Sonar 来说是不够的,Sonar 不会发现您的源和输出目录。根据Non-Maven projects (sonar light mode),您必须在最小的pom.xml 中声明源和输出目录(并在运行Sonar 之前构建您的项目)。

    【讨论】:

      猜你喜欢
      • 2013-01-29
      • 2020-11-14
      • 2012-11-03
      • 2015-12-02
      • 2011-06-15
      • 2010-11-16
      • 2019-10-27
      • 2019-05-25
      • 1970-01-01
      相关资源
      最近更新 更多