Reputation: 20119
I am writing a custom Gradle plugin that applies the Gradle sonar runner plugin and defaults some of the parameters. I want to write a test to confirm that the properties are set correctly, but I cannot figure out how to access the data after it is set.
I tried project.getExtensions().sonarRunner.sonarProperties.getProperties()
and a few variants, but this either throws a null pointer or returns something other than the sonar properties.
Is it possible to read the sonar properties after they are set? How?
Upvotes: 2
Views: 1770
Reputation: 98
This works for me, just remember to pass in the property key with quotes:
project.tasks.sonarRunner.sonarProperties.get("sonar.host.url")
Upvotes: 1
Reputation: 5326
For our own tests we are using a "secret" property that will dump all SQ properties in a file so that you can write assertions on it.
-DsonarRunner.dumpToFile=out.properties
See for example how I wrote integration tests for the new Gradle SonarQube plugin: https://github.com/SonarCommunity/sonar-gradle/blob/master/integrationTests/src/test/java/org/sonarqube/gradle/GradleTest.java#L22
Upvotes: 1