声呐:声呐不支持"key"属性



我使用Sonar 3.5.1, Java 1.6.0_26和Apache Ant 1.9.0;并在apache-ant-1.9.0/lib/目录下下载插件sonar-ant-task-2.1.jar。

当我运行蚂蚁声纳任务时,我遇到了错误:

build.xml:115: sonar:sonar不支持"key"属性

这个问题真的让我发疯了一个星期。你能告诉我是什么问题吗?
<!-- ========= Define Sonar target ========= -->
<property name="sonar.projectKey" value="org.codehaus.sonar:${eid}-test" />
<property name="sonar.projectName" value="${eid}-test" />
<property name="sonar.sources" value="${src.dir}" />
<property name="sonar.language" value="c++" />
<property name="sonar.binaries" value="${classes.dir}" />
<property name="sonar.surefire.reportsPath" value="${reports.junit.xml.dir}" />   
<property name="sonar.cxx.cppcheck.reportPath" value="${reports.dir}/cppcheck-report.xml" />
<property name="sonar.cxx.gcovr.reportPath" value="${reports.dir}/gcovr-report.xml" />
<property name="sonar.cxx.xunit.reportPath" value="${reports.dir}/gtest-report.xml" />
<!-- The following properties are required to use JaCoCo: -->
<!-- 1. Tells Sonar to run the unit tests -->
<!--
<property name="sonar.dynamicAnalysis" value="true" />
-->
<!-- 2. Tells Sonar which "tests" targets to run -->
<!-- 3. Tells Sonar to use JaCoCo as the code coverage engine -->
<!--
<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
-->
<target name="sonar" depends="cppcheck-report">
    <sonar:sonar key="org.codehaus.sonar:${eid}-test" version="1.0" xmlns:sonar="antlib:org.sonar.ant" />
</target>
<!-- ========= The main target "all" ========= -->
<!-- Note that depending on the "run-tests" target is not mandatory, as Sonar Ant task will launch it thanks to the "sonar.jacoco.antTargets" property -->
<!-- However, note that compiling is required before running the Sonar Ant task -->
<target name="all" depends="clean,compile,cppcheck-report" />

下面是Sonar Ant任务文档的链接:

http://docs.codehaus.org/display/SONAR/Analyzing + + SonarQube + Ant +任务# AnalyzingwithSonarQubeAntTask-SimpleProject

您将看到应该使用sonar.projectKey属性来定义项目键。

我一直在寻找同样的问题,从一个多月,终于得到了解决。我关注了很多在线帮助& &;SonarQube在线文档提供的说明以及多个线程,但最终更令人沮丧。

然后我尝试声纳-反任务1.5,并遵循sonar:sonar命令中具有keyversion属性的build.xml,它工作了。然后我用sonar-ant-task-2.1(最新可用)尝试了这个命令,它也工作得很好。

这是我的构型

  • JDK: 1.6.0_12(32位)
  • Sonar Server: 3.7.2
  • 声纳蚂蚁任务运行器:Sonar - Ant - Task -2.1.jarApache Ant: 1.8.4

下面是我的ant的build.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="sonar-runner" name="vApplicationUtilities" xmlns:sonar="antlib:org.sonar.ant">
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.5"/>
<property name="source" value="1.5"/>
<!-- Define the SonarQube properties -->
<property name="sonar.host.url" value="http://my-sonar-server:9000/sonar" />
<property name="sonar.jdbc.url" value="jdbc:jtds:sqlserver://my-sql-server-host/sonar;SelectMethod=Cursor" />
<property name="sonar.jdbc.username" value="username" />
<property name="sonar.jdbc.password" value="password" />
<property name="sonar.projectKey" value="my-project-key" />
<property name="sonar.projectName" value="vApplicationUtilities" />
<property name="sonar.projectVersion" value="4.0.0020" />
<property name="sonar.language" value="java" />
<property name="sonar.profile" value="My Analyzer" />
<property name="sonar.sources" value="src" />
<property name="sonar.sourceEncoding" value="UTF-8" />
<path id="vApplicationUtilities.classpath">
    <pathelement location="build/classes"/>
    <path refid="EAR Libraries.libraryclasspath"/>
    <path refid="JBoss 5.0 Runtime [JBoss 5.0 Runtime].libraryclasspath"/>
</path>
<target name="init">
    <mkdir dir="build/classes"/>
    <copy includeemptydirs="false" todir="build/classes">
        <fileset dir="src">
            <exclude name="**/*.launch"/>
            <exclude name="**/*.java"/>
        </fileset>
    </copy>
</target>
<target name="clean">
    <delete dir="build/classes"/>
    <delete dir=".sonar"/>
</target>
<target depends="clean" name="cleanall"/>
<target depends="cleanall,build-project" name="build">
    <echo message="Creating dist/vApplicationUtilities.jar"/>
    <jar destfile="dist/vApplicationUtilities.jar" basedir="build/classes" manifest="build/classes/META-INF/MANIFEST.MF"/>
</target>
<target depends="init" name="build-project">
    <echo message="${ant.project.name}: ${ant.file}"/>
    <javac includeantruntime="false" debug="true" debuglevel="${debuglevel}" destdir="build/classes" source="${source}" target="${target}">
        <src path="src"/>
        <classpath refid="vApplicationUtilities.classpath"/>
    </javac>
</target>
<target depends="build" name="sonar-runner">
    <!-- run sonar for this project -->
    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        <!-- Update the following line, or put the "sonar-ant-task-*.jar" file 
            in your "$HOME/.ant/lib" folder -->
        <classpath path="${lib-dist}/sonar/sonar-ant-task-2.1.jar" />
    </taskdef>
    <!-- Execute Sonar -->
    <sonar:sonar key="${sonar.projectKey}" version="${sonar.projectVersion}" />
</target>
</project>

此外,您已经访问了一些在线帮助,讨论了最新版本的声纳蚂蚁任务(2.x)不需要声纳runner任务中的keyversion属性。太扯淡了,我浪费了很多时间在那个缺少指导方针的问题上。您确实需要这两个属性才能使声纳任务运行。

希望这将照亮你的一天。由于

相关内容

  • 没有找到相关文章

最新更新