Skip to content

Commit 5f8ae02

Browse files
fix: make spotbugs/sonarqube plugins conditional for restricted CI environments
Moves spotbugs and sonarqube from the plugins block to buildscript dependencies with conditional application. Pass -PskipCodeAnalysis to skip loading these plugins in environments without external Maven repository access (e.g., ADO 1ESPT pipeline agents). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5c84da0 commit 5f8ae02

2 files changed

Lines changed: 44 additions & 24 deletions

File tree

‎.azure-pipelines/daily-ci-build.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ extends:
5050
jdkArchitectureOption: 'x64'
5151
jdkSourceOption: 'PreInstalled'
5252

53-
- script: chmod +x gradlew && ./gradlew assemble
53+
- script: chmod +x gradlew && ./gradlew assemble -PskipCodeAnalysis
5454
displayName: Build SDK
5555
workingDirectory: $(Build.SourcesDirectory)
5656

57-
- script: ./gradlew test
57+
- script: ./gradlew test -PskipCodeAnalysis
5858
displayName: Run unit tests
5959
workingDirectory: $(Build.SourcesDirectory)

‎build.gradle‎

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
buildscript {
2+
repositories {
3+
gradlePluginPortal()
4+
mavenCentral()
5+
}
6+
if (!hasProperty('skipCodeAnalysis')) {
7+
dependencies {
8+
classpath 'com.github.spotbugs.snom:spotbugs-gradle-plugin:6.5.4'
9+
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:7.3.0.8198'
10+
}
11+
}
12+
}
13+
114
plugins {
215
// Apply the java-library plugin to add support for Java Library
316
id 'java-library'
417
id 'eclipse'
518
id 'maven-publish'
619
id 'signing'
720
id 'jacoco'
8-
id 'com.github.spotbugs' version '6.5.4'
9-
id "org.sonarqube" version "7.3.0.8198"
1021

1122
}
1223

24+
if (!project.hasProperty('skipCodeAnalysis')) {
25+
apply plugin: 'com.github.spotbugs'
26+
apply plugin: 'org.sonarqube'
27+
}
28+
1329
java {
1430
modularity.inferModulePath = true
1531
withSourcesJar()
@@ -29,24 +45,26 @@ jacoco {
2945
toolVersion = "0.8.12"
3046
}
3147

32-
spotbugsMain {
33-
excludeFilter = file("spotBugsExcludeFilter.xml")
34-
reports {
35-
html {
36-
required
37-
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
38-
stylesheet = 'fancy-hist.xsl'
48+
if (!project.hasProperty('skipCodeAnalysis')) {
49+
spotbugsMain {
50+
excludeFilter = file("spotBugsExcludeFilter.xml")
51+
reports {
52+
html {
53+
required
54+
outputLocation = file("$buildDir/reports/spotbugs/main/spotbugs.html")
55+
stylesheet = 'fancy-hist.xsl'
56+
}
3957
}
4058
}
41-
}
4259

43-
spotbugsTest {
44-
excludeFilter = file("spotBugsExcludeFilter.xml")
45-
reports {
46-
html {
47-
required
48-
outputLocation = file("$buildDir/reports/spotbugs/test/spotbugs.html")
49-
stylesheet = 'fancy-hist.xsl'
60+
spotbugsTest {
61+
excludeFilter = file("spotBugsExcludeFilter.xml")
62+
reports {
63+
html {
64+
required
65+
outputLocation = file("$buildDir/reports/spotbugs/test/spotbugs.html")
66+
stylesheet = 'fancy-hist.xsl'
67+
}
5068
}
5169
}
5270
}
@@ -83,11 +101,13 @@ def pomConfig = {
83101
}
84102
}
85103

86-
sonarqube {
87-
properties {
88-
property "sonar.projectKey", "microsoftgraph_msgraph-sdk-java-core"
89-
property "sonar.organization", "microsoftgraph2"
90-
property "sonar.host.url", "https://sonarcloud.io"
104+
if (!project.hasProperty('skipCodeAnalysis')) {
105+
sonarqube {
106+
properties {
107+
property "sonar.projectKey", "microsoftgraph_msgraph-sdk-java-core"
108+
property "sonar.organization", "microsoftgraph2"
109+
property "sonar.host.url", "https://sonarcloud.io"
110+
}
91111
}
92112
}
93113

0 commit comments

Comments
 (0)