Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use internal property to avoid issues with configuration cache #857

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import org.gradle.api.tasks.PathSensitive;
import org.gradle.api.tasks.PathSensitivity;
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.VerificationTask
import org.gradle.internal.enterprise.test.FileProperty
import org.gradle.jvm.toolchain.JavaLauncher
import org.gradle.jvm.toolchain.JavaToolchainService;
import org.gradle.util.ClosureBackedAction
Expand All @@ -61,6 +60,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory

import javax.inject.Inject
import java.nio.file.Path

/**
* The Gradle task to run the SpotBugs analysis. All properties are optional.
Expand Down Expand Up @@ -264,6 +264,8 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
@NonNull
final Property<Boolean> useAuxclasspathFile

@Internal
private Path auxclasspathFile;
private FileCollection classes;

private boolean enableWorkerApi;
Expand Down Expand Up @@ -386,6 +388,9 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
* @param extension the source extension to copy the properties.
*/
void init(SpotBugsExtension extension, boolean enableWorkerApi, boolean enableHybridWorker) {
def taskName = getName()
auxclasspathFile = project.layout.buildDirectory.file("spotbugs/auxclasspath/$taskName").get().getAsFile().toPath()

ignoreFailures.convention(extension.ignoreFailures)
showStackTraces.convention(extension.showStackTraces)
showProgress.convention(extension.showProgress)
Expand All @@ -399,7 +404,7 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
excludeFilter.convention(extension.excludeFilter)
baselineFile.convention(extension.baselineFile)
onlyAnalyze.convention(extension.onlyAnalyze)
projectName.convention(extension.projectName.map({p -> String.format("%s (%s)", p, getName())}))
projectName.convention(extension.projectName.map({p -> String.format("%s (%s)", p, taskName)}))
release.convention(extension.release)
jvmArgs.convention(extension.jvmArgs)
extraArgs.convention(extension.extraArgs)
Expand Down Expand Up @@ -535,4 +540,8 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
}
return new StringBuilder().append(Character.toLowerCase(prunedName.charAt(0))).append(prunedName.substring(1)).toString()
}

Path getAuxclasspathFile() {
return auxclasspathFile
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -139,12 +138,7 @@ private String createFileForAuxClasspath(SpotBugsTask task) {
.map(File::getAbsolutePath)
.collect(Collectors.joining("\n"));
try {
Path auxClasspathFile =
Paths.get(
task.getProject().getBuildDir().getAbsolutePath(),
"spotbugs",
"auxclasspath",
task.getName());
Path auxClasspathFile = task.getAuxclasspathFile();
try {
Files.createDirectories(auxClasspathFile.getParent());
if (!Files.exists(auxClasspathFile)) {
Expand Down