Ant multi-module project for separate build.xml files

565 views
Skip to first unread message

gena...@gmail.com

unread,
Nov 20, 2017, 7:47:56 AM11/20/17
to SonarQube
Hi all, I need help with the following sonar setting.
I have separate modules/components each with its own Ant build.xml file, and each of these ant files are called separately, they are NOT all imported into one "root" or "top-level" build.xml whatsoever. The result of build system's work is a "repository" of components.

Yet, I want to make sonar consider these components as modules of the same projects, so that I can have aggregated stats for all of them in a single project report.
Is this possible with sonar?

This is what I'm trying to do (with no success). I'm defining sonar.* properties for the whole project (same for each build.xml) and <module>.sonar.* properties specific for each component, like so:

  <property name="sonar.host.url" value="http://myhost:9000" />
  <property name="sonar.login" value="token" />

  <property name="sonar.projectKey" value="mykey" />
  <property name="sonar.projectName" value="ProjectX" />
  <property name="sonar.projectVersion" value="version" />
  <property name="sonar.modules" value="component1,component2" />

  <property name="${ant.project.name}.sonar.projectName" value="${ant.project.name}" />
  <property name="${ant.project.name}.sonar.sources" value="${src.java.dir}" />
  <property name="${ant.project.name}.sonar.java.binaries" value="${build.classes.dir}" />
...

Am I missing something or sonar is just not fit for such a use case?

G. Ann Campbell

unread,
Nov 28, 2017, 3:10:41 PM11/28/17
to SonarQube
Hi,

You seem to be combining the two different approaches to setting multi-module properties laid out here.

Specifically, you've got your module-specific properties distributed in module-specific files, but you're naming them as though all properties were contained in a single, top-level file (foo.sonar.[property]=).

Try this in your module-level files instead:
  <property name="sonar.projectName" value="${ant.project.name}" />
  <property name="sonar.sources" value="${src.java.dir}" />
  <property name="sonar.java.binaries" value="${build.classes.dir}" />

Note that the docs I pointed you to are for multi-module analysis using SonarQube Scanner, rather than for SonarQube Scanner for Ant, but the latter is just a wrapper for the former, so it should all translate directly once you Ant-ify it, which you've already done.


Ann
Reply all
Reply to author
Forward
0 new messages