简体   繁体   中英

Globs in sonar-project.properties

I'm working on a large legacy project that I'm trying to componentize, starting with SonarQube. I'm configuring a multi-module project in sonar-project.properties . This works fine. However, I have an issue precisely identifying source folders.

Unfortunately, our modules aren't neatly separated in the file system. The project is separated into many Eclipse projects, and several Eclipse projects together form one module. I can, of course, enumerate all the projects, but this is very cumbersome as there are a lot of them. Here's a (simplified) version of our directory structure:

projects/
    moduleAsubmodule1/
        src/
            com/mycompany/moduleA/submodule1/
    moduleAsubmodule2/
        src/
            com/mycompany/moduleA/submodule2/
    moduleBsubmodule1/
        src/
            com/mycompany/moduleB/submodule1/
    moduleBsubmodule2/
        src/
            com/mycompany/moduleB/submodule2/
    moduleBsubmodule3/
        src/
            com/mycompany/moduleB/submodule3/

Imagine many more modules and submodules, where the project name is concatenated, but the package names are nicely divided, making it much easier to differentiate on those.

moduleA.sonar.projectBaseDir=.
moduleA.sonar.sources=projects/**/src/com/mycompany/moduleA/**/*
moduleA.sonar.test=projects/**/*.test/src/com/mycompany/moduleA/**/*

According to the documentation , this should be possible for exclusions. However, I get the following error message:

16:10:44 ERROR: Unable to execute Sonar
16:10:44 ERROR: Caused by: The folder 'projects/**/src/com/mycompany/mymodule/**/*' does not exist for 'XXX:XXX:mymodule' (base directory = D:\XxxSonar\.)

So I guess globs don't work for sources? If that's indeed the case, what can I do?

We use SonarQube 4.1.2.

Wildcards are not allowed when specifying "sonar.sources". Instead, you should play with the properties that allow to narrow your source and test files. See the documentation page on how to include or exclude files to narrow the focus .

I had the same issue, but I solved it by doing like this:

sonar.sources=.
sonar.inclusions=projects/*/src/**/*

The inclusions/exclusions properties support wildcards. Same for your tests:

sonar.test.inclusions=projects/*/*.test/src/**/*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM