Multiple binary directories no longer supported in sonarqube-gradle-plugin 2.1-rc3

740 views
Skip to first unread message

lof...@gmail.com

unread,
Sep 20, 2016, 7:16:57 AM9/20/16
to SonarQube
Hi,

When updating to sonarqube-gradle-plugin 2.1-rc3 I noticed that the property "sonar.java.binaries" has changed from a file collection to a single file.

In our build we add a secondary directory with binaries. Is this no longer longer supported?

The change was part of "SONARGRADL-18 Support "compileOnly" dependencies introduced in Gradle 2.12"


https://github.com/SonarSource/sonar-scanner-gradle/commit/d21ebf5bfcddc8dce560cc77ef9bdf2de961c6a2#diff-c26acf2602feab05f4c0496e1656a572L246


Regards,
Erik

Julien HENRY

unread,
Sep 20, 2016, 9:48:31 AM9/20/16
to SonarQube, lof...@gmail.com
Hi Erik,

Thanks for the feedback. I was not aware of this ability to add more binary outputs. Can you share a sample project? Do you confirm this second binary folder contains .class of the project source code? If it contains classes of "external" code (ie code not part of the project) then it should be added to sonar.libraries.

++

Julien

lof...@gmail.com

unread,
Sep 20, 2016, 10:28:42 AM9/20/16
to SonarQube, lof...@gmail.com
Hi Julien,

Thanks for your fast response.

My scenario is a bit special and involves our CI environment. Shortly, we have one jenkins job that compiles the application, runs the unit tests and packs a jar-file for distribution. Then we have another jenkins job on another machine that executes integration tests of our application, this involves for example guitesting, where code coverage is measured. The test system unzips the class files from the distribution jar into a directory and adds this to "sonar.java.binaries".

I understand this is not a very common use case, but it gives us a clear separation of building/releasing and integration testing :)

As I understand it, several binary directories are supported by the sonar scanner. The property "sonar.java.binaries" is a list according to the docs at http://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode
 
sonar.java.binaries | Comma-separated paths to directories containing the compiled bytecode files corresponding to your source files

Regards,
Erik

Julien HENRY

unread,
Sep 20, 2016, 11:31:29 AM9/20/16
to SonarQube, lof...@gmail.com
Erik,

Please share a reproducer to let me understand how you make Gradle aware of that additional build output. For me it looks like the fact it was previously working was an unexpected side effect. Your best option if your are already telling Gradle about this extra build output is to do the same for sonarqube and override sonar.java.binaries.

++

Julien

lof...@gmail.com

unread,
Sep 22, 2016, 2:22:28 AM9/22/16
to SonarQube, lof...@gmail.com
Hi Julie,

Previously, we added the extra binary directory like this:

sonarqube {
    properties {
        properties["sonar.java.binaries"] += file("$buildDir/sonarBinaries")
        ...
    }
}

This worked since the property was of type Collection<File>. Perhaps this "feature" was an unwanted side effect?

This workaround seems to work, it will result in a comma-separated list when passed to the sonar analyzer:

properties["sonar.java.binaries"] = [
    file("$buildDir/classes/main"),
    file("$buildDir/sonarBinaries")
]


Regards,
Erik

Julien HENRY

unread,
Sep 22, 2016, 5:04:20 AM9/22/16
to SonarQube, lof...@gmail.com
Now I see what you mean.

Ticket created:

Thanks for the feedback.
Reply all
Reply to author
Forward
0 new messages