Skip to content

Commit bbc4225

Browse files
feat(sonar): Let task run without dependencies on other tasks
1 parent 59c00cd commit bbc4225

File tree

5 files changed

+38
-11
lines changed

5 files changed

+38
-11
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ group = org.kordamp.gradle
2020
sourceCompatibility = 1.8
2121
targetCompatibility = 1.8
2222

23-
kordampPluginVersion = 0.46.4
23+
kordampPluginVersion = 0.46.5
2424
kordampBuildVersion = 2.8.0
2525
gitPluginVersion = 3.0.1
2626
grgitVersion = 4.1.1

plugins/base-gradle-plugin/src/main/groovy/org/kordamp/gradle/plugin/base/ProjectConfigurationExtension.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,9 @@ class ProjectConfigurationExtension {
453453
List<String> validate(ProjectConfigurationExtension extension) {
454454
List<String> errors = []
455455

456-
errors.addAll(sonar.validate(extension))
456+
if (project.rootProject == project) {
457+
errors.addAll(sonar.validate(extension))
458+
}
457459

458460
errors
459461
}

plugins/base-gradle-plugin/src/main/groovy/org/kordamp/gradle/plugin/base/plugins/Sonar.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class Sonar extends AbstractFeature {
4141
Map<String, Object> configProperties = [:]
4242
Set<String> excludes = new LinkedHashSet<>()
4343
final Set<Project> excludedProjects = new LinkedHashSet<>()
44+
boolean standalone = true
45+
46+
private boolean standaloneSet
4447

4548
Sonar(ProjectConfigurationExtension config, Project project) {
4649
super(config, project, PLUGIN_ID)
@@ -65,6 +68,7 @@ class Sonar extends AbstractFeature {
6568
)
6669

6770
if (isRoot()) {
71+
map.standalone = this.standalone
6872
map.hostUrl = this.hostUrl
6973
map.projectKey = this.projectKey
7074
map.organization = this.organization
@@ -87,6 +91,15 @@ class Sonar extends AbstractFeature {
8791
this.ignoreFailures != null
8892
}
8993

94+
void setStandalone(boolean standalone) {
95+
this.@standalone = standalone
96+
this.standaloneSet = true
97+
}
98+
99+
boolean isStandaloneSet() {
100+
this.standaloneSet
101+
}
102+
90103
void normalize() {
91104
if (null == projectKey) {
92105
projectKey = String.valueOf(project.group) + ':' + project.name
@@ -136,6 +149,7 @@ class Sonar extends AbstractFeature {
136149

137150
static void merge(Sonar o1, Sonar o2) {
138151
AbstractQualityFeature.merge(o1, o2)
152+
o1.@standalone = (boolean) (o1.standaloneSet ? o1.standalone : o2.standalone)
139153
o1.hostUrl = o1.hostUrl ?: o2.hostUrl
140154
o1.projectKey = o1.projectKey ?: o2.projectKey
141155
o1.organization = o1.organization ?: o2.organization

plugins/sonar-gradle-plugin/src/main/groovy/org/kordamp/gradle/plugin/sonar/SonarPlugin.groovy

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ class SonarPlugin extends AbstractKordampPlugin {
128128
addIfUndefined('sonar.host.url', config.quality.sonar.hostUrl, p)
129129
addIfUndefined('sonar.projectKey', config.quality.sonar.projectKey, p)
130130
addIfUndefined('sonar.exclusions', config.quality.sonar.excludes.join(','), p)
131+
if (config.coverage.jacoco.enabled) {
132+
p.property('sonar.coverage.jacoco.xmlReportPaths', config.coverage.jacoco.aggregateReportXmlFile.absolutePath)
133+
}
134+
if (config.quality.spotbugs.enabled) {
135+
p.property('sonar.java.spotbugs.reportPaths', resolveBuiltFile(project, 'reports/spotbugs/aggregateSpotbugs.xml'))
136+
}
131137
if (config.quality.checkstyle.enabled) {
132138
p.property('sonar.java.checkstyle.reportPaths', resolveBuiltFile(project, 'reports/checkstyle/aggregate.xml'))
133139
}
@@ -161,14 +167,19 @@ class SonarPlugin extends AbstractKordampPlugin {
161167
@Override
162168
void execute(SonarQubeTask t) {
163169
t.setGroup('Quality')
164-
if (config.coverage.jacoco.enabled) {
165-
t.dependsOn(project.tasks.named('aggregateJacocoReport'))
166-
}
167-
if (config.quality.codenarc.enabled) {
168-
t.dependsOn(project.tasks.named('aggregateCodenarc'))
169-
}
170-
if (config.quality.checkstyle.enabled) {
171-
t.dependsOn(project.tasks.named('aggregateCheckstyle'))
170+
if (!config.coverage.coveralls.standalone) {
171+
if (config.coverage.jacoco.enabled) {
172+
t.dependsOn(project.tasks.named('aggregateJacocoReport'))
173+
}
174+
if (config.quality.codenarc.enabled) {
175+
t.dependsOn(project.tasks.named('aggregateCodenarc'))
176+
}
177+
if (config.quality.checkstyle.enabled) {
178+
t.dependsOn(project.tasks.named('aggregateCheckstyle'))
179+
}
180+
if (config.quality.spotbugs.enabled) {
181+
t.dependsOn(project.tasks.named('aggregateSpotbugs'))
182+
}
172183
}
173184
}
174185
})

plugins/spotbugs-gradle-plugin/src/main/groovy/org/kordamp/gradle/plugin/spotbugs/SpotbugsPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class SpotbugsPlugin extends AbstractKordampPlugin {
247247
switch (config.quality.spotbugs.report?.toLowerCase()) {
248248
case 'xml':
249249
t.reports.maybeCreate('xml').enabled = true
250-
t.reports.maybeCreate('htm').enabled = false
250+
t.reports.maybeCreate('html').enabled = false
251251
break
252252
case 'html':
253253
default:

0 commit comments

Comments
 (0)