build.xml文件的配置使用Ant声纳模块 [英] Configuration of build.xml file for Sonar modules with Ant

查看:334
本文介绍了build.xml文件的配置使用Ant声纳模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设立一个声纳项目(使用Delphi的插件),为简单起见假设有两个模块,我要报告的。

I am setting up a Sonar project (using the delphi plugin), for simplicity sake assume there are two modules I want to report on.

每个模块在它自己的子文件夹,每个人都有它自己的build.xml文件。

Each module is in it's own sub-folder and each has it's own build.xml file.

在这一点上我能成功运行的声纳任务,并为每个模块作为一个独立的项目报告。

At this point I can successfully run the sonar tasks and generate reports for each module as an independent project.

我的问题是与配置主build.xml文件。

My problem is with configuring the "master" build.xml file.

模块build.xml文件看起来是这样的:

The module build.xml file looks like this:

<?xml version="1.0"?>
<project name = "CRM" default = "sonar" basedir = ".">
    <!-- Add the Sonar task -->
    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        <classpath path="c:/ANT/lib" />
    </taskdef>

    <target name="sonar">
        <property name="sonar.projectKey" value="EXO:CRM" />
        <property name="sonar.host.url" value="http://localhost:9000" />
        <sonar:sonar workDir="." key="CRM.key" version="0.1" xmlns:sonar="antlib:org.sonar.ant">
            <property key="sonar.sources" value="." />      <!-- project sources directories (required) -->
            <property key="sonar.language" value="delph" />                             <!-- project language -->
            <property key="sonar.delphi.codecoverage.excluded" value=".\tests" />           <!-- code coverage excluded directories -->
            <property key="sonar.importSources" value="true" />                         <!-- should we show sources or not? -->     
            <property key="sonar.delphi.sources.excluded" value="" />                       <!-- excluded directories -->
            <property key="sonar.delphi.sources.include" value=".\includes" />              <!-- include directories, "," separated -->
            <property key="sonar.delphi.sources.include.extend" value="true" />         <!-- should we extend includes in files? -->
        </sonar:sonar>
    </target>
</project>

大师的build.xml看起来是这样的:

The "Master" build.xml looks like this:

<?xml version="1.0"?>
<project name = "EXO" default = "sonar" basedir = ".">
    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        <classpath path="c:/ANT/lib" />
    </taskdef>

    <target name="sonar">
        <property name="sonar.modules" value="exonet6000/build.xml,CRM/build.xml" />
        <sonar:sonar workDir="." key="EXO.key" version="0.1" xmlns:sonar="antlib:org.sonar.ant">
            <!-- project sources directories (required) --> 
            <property key="sonar.sources" value="." />      
            <property key="sonar.language" value="delph" />
            <property key="sonar.importSources" value="true" /> 
            <property key="sonar.delphi.sources.excluded" value="" />                       
            <property key="sonar.delphi.sources.include" value=".\includes" />      
            <property key="sonar.delphi.sources.include.extend" value="true" />         
        </sonar:sonar>
    </target>
</project>

它总是扫描所有源(所需值),即它是不尊重我的模块。
我能得到这个工作,目前唯一的办法就是通过限制源$ C ​​$ C这样的

It is always scanning all sources (required value) i.e. it is not respecting my modules. The only way I can get this to work currently is by limiting the source code like this

<property key="sonar.sources" value="./crm/,./exonet6000/" />   

我敢肯定,我一定是错的东西配置明显这里。

I'm sure I must be mis-configuring something obvious here.

编辑:我现在有什么,我相信是基于这里的例子<一个更加一致的文件集href=\"https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/java-ant-modules\" rel=\"nofollow\">https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/java-ant-modules

I have now what I believe is a more consistent set of files based on examples here https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/java/java-ant-modules

主构建文件:

<?xml version="1.0" encoding="UTF-8"?>
<project name = "EXO" default = "sonar" basedir = "." xmlns:sonar="antlib:org.sonar.ant">
    <echo>Root Project</echo>

    <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        <classpath path="c:/ANT/lib" />
    </taskdef>

    <property name="sonar.host.url" value="http://localhost:9000" />
    <property name="sonar.modules" value="exonet6000/build.xml,CRM/build.xml" />

    <target name="sonar">
        <sonar:sonar key="EXO.key" version="0.1">   
        </sonar:sonar>
    </target>
</project>

和子模块文件中的一个

<?xml version="1.0" encoding="UTF-8"?>
<project name="CRM" default="all" basedir=".">
    <echo>CRM Module</echo>

    <property name="sonar.language" value="delph" />
    <property name="sonar.projectKey" value="EXO:CRM" />
    <property name="sonar.sources" value="." /> 

    <target name="all" />
</project>

此时声纳过程成功完成,但没有实际anlysis正在做。关键的一点是,我没有看到子模块的回声让我怀疑这些构建任务实际上并没有运行。

At this point the sonar process is completing successfully BUT no actual anlysis is being done. A key point is that I am not seeing the echo of the submodule so I suspect these build tasks are not actually running.

推荐答案

如果你看一下<一个href=\"https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/java/java-ant-modules/build.xml\"相对=nofollow>此示例项目使用Ant和multimodules 的,我会说,你不应该在指定的主build.xml文件,在标签内的任何财产,并让子模块指定这些属性。

If you look at this sample project using Ant and multimodules, I'd say that you should not specify any property inside the tag in your master build.xml file, and let the submodules specify those properties.

这篇关于build.xml文件的配置使用Ant声纳模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆