[GRADLE-1499] projectProperty setter of Sonar task adds to globalProperties Created: 28/Apr/11  Updated: 04/Jan/13  Resolved: 28/Apr/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: 1.0-milestone-4

Type: Bug
Reporter: Gary Hale Assignee: Peter Niederwieser
Resolution: Fixed Votes: 0


 Description   

Attempting to set project properties on the Sonar task using the single property setter doesn't work. e.g.

sonar

{ ... projectProperty 'sonar.dynamicAnalysis', 'reuseReports' projectProperty 'sonar.cobertura.reportPath', '/some/path/to/coverage.xml' }

On the other hand, using the map setter, it works fine:

sonar

{ ... projectProperties([ 'sonar.dynamicAnalysis': 'reuseReports', 'sonar.cobertura.reportPath': '/some/path/to/coverage.xml' ]) }

Looking at the code, the problem is the single property setter sets the property in globalProperties instead of projectProperties:

From org/gradle/api/plugins/sonar/Sonar.groovy:

void projectProperty(String name, String value)

{ globalProperties.put(name, value) }

 Comments   
Comment by Matt Read [ 05/Jun/11 ]

Not sure if this is expected behaviour but in milestone-4 after the original issue was fixed, using projectProperty overwrites/ignores the defaults. So if I want to add a single projectProperty as follows:

projectProperty "sonar.cobertura.reportPath", "build/reports/cobertura/coverage.xml"

I have to re-add all those configured in configureConventions()

projectProperty "sonar.java.source", project.sourceCompatibility as String
projectProperty "sonar.java.target", project.targetCompatibility as String
projectProperty "sonar.dynamicAnalysis", "reuseReports"
projectProperty "sonar.surefire.reportsPath", project.test.testResultsDir as String
projectProperty "sonar.cobertura.reportPath", "build/reports/cobertura/coverage.xml"

Generated at Wed Jun 30 11:57:04 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.