Skip to content

Commit fcd47f1

Browse files
update after code review
1 parent b428ca0 commit fcd47f1

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

src/main/java/org/sonarqube/gradle/SonarQubePlugin.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,9 @@ private static List<File> registerAndConfigureResolverTasks(Project topLevelProj
118118
}
119119
task.setProjectName(SonarUtils.constructPrefixedProjectName(target.getPath()));
120120

121-
Provider<FileCollection> compile = target.provider(() -> {
122-
var sourceSets = SonarUtils.getSourceSets(target);
123-
if (sourceSets == null) {
124-
return null;
125-
}
126-
var set = sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME);
127-
return set == null ? null : set.getCompileClasspath();
128-
});
121+
Provider<FileCollection> compile = target.provider(() -> querySourceSet(target, SourceSet.MAIN_SOURCE_SET_NAME));
122+
Provider<FileCollection> test = target.provider(() -> querySourceSet(target, SourceSet.TEST_SOURCE_SET_NAME));
129123
task.setCompileClasspath(compile);
130-
Provider<FileCollection> test = target.provider(() -> {
131-
var sourceSets = SonarUtils.getSourceSets(target);
132-
if (sourceSets == null) {
133-
return null;
134-
}
135-
var set = sourceSets.findByName(SourceSet.TEST_SOURCE_SET_NAME);
136-
return set == null ? null : set.getCompileClasspath();
137-
});
138124
task.setTestCompileClasspath(test);
139125

140126
// Currently we only use the SonarResolverTask for Android projects to resolve libraries. Other projects use
@@ -153,6 +139,16 @@ private static List<File> registerAndConfigureResolverTasks(Project topLevelProj
153139
return resolverFiles;
154140
}
155141

142+
@Nullable
143+
private static FileCollection querySourceSet(Project project, String sourceSetName) {
144+
var sourceSets = SonarUtils.getSourceSets(project);
145+
if (sourceSets == null) {
146+
return null;
147+
}
148+
var set = sourceSets.findByName(sourceSetName);
149+
return set == null ? null : set.getCompileClasspath();
150+
}
151+
156152
private static void setAndroidLibrariesProperties(Project target, SonarResolverTask task) {
157153
AndroidUtils.LibrariesAndTestLibraries libraries = AndroidUtils.LibrariesAndTestLibraries.ofProject(target);
158154
task.setMainLibraries(libraries.getMainLibraries());

src/main/java/org/sonarqube/gradle/SonarResolverTask.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ void run() throws IOException {
140140
var mainClasspath = this.compileClasspath.getOrNull();
141141
var testClasspath = testCompileClasspath.getOrNull();
142142

143-
List<String> compileClasspathFilenames = SonarUtils.exists(mainClasspath == null ? List.of() : mainClasspath)
143+
List<String> compileClasspathFilenames = SonarUtils.exists(mainClasspath == null ? Collections.emptyList() : mainClasspath)
144144
.stream()
145145
.map(File::getAbsolutePath)
146146
.collect(Collectors.toList());
147-
List<String> testCompileClasspathFilenames = SonarUtils.exists(testClasspath == null ? List.of() : testClasspath)
147+
List<String> testCompileClasspathFilenames = SonarUtils.exists(testClasspath == null ? Collections.emptyList() : testClasspath)
148148
.stream()
149149
.map(File::getAbsolutePath)
150150
.collect(Collectors.toList());
@@ -175,9 +175,4 @@ void run() throws IOException {
175175
LOGGER.info("Resolved properties for " + displayName + " and wrote them to " + getOutputFile() + ".");
176176
}
177177
}
178-
179-
public boolean configurationCacheIsDisabled() {
180-
return true;
181-
}
182-
183178
}

0 commit comments

Comments
 (0)