Skip to content

Commit

Permalink
fix: migrate deprecated Gradle API usages (#974)
Browse files Browse the repository at this point in the history
* Replace deprecated ClosureBackedAction

* Replace deprecated ConfigureUtil
  • Loading branch information
Goooler authored Oct 8, 2023
1 parent fda1755 commit b1ef0d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 10 additions & 2 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import javax.annotation.Nullable;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
Expand All @@ -29,7 +30,6 @@
import org.gradle.api.resources.TextResource;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.util.ConfigureUtil;

public abstract class SpotBugsReport
implements SingleFileReport,
Expand Down Expand Up @@ -118,7 +118,15 @@ public void setDestination(Provider<File> provider) {

@Override
public Report configure(Closure closure) {
ConfigureUtil.configureSelf(closure, this);
return configure(
report -> {
closure.setDelegate(report);
closure.call(report);
});
}

public Report configure(Action<? super Report> action) {
action.execute(this);
return this;
}

Expand Down
11 changes: 1 addition & 10 deletions src/main/groovy/com/github/spotbugs/snom/SpotBugsTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package com.github.spotbugs.snom

import com.github.spotbugs.snom.internal.SemanticVersion;
import com.github.spotbugs.snom.internal.SpotBugsHtmlReport
import com.github.spotbugs.snom.internal.SpotBugsRunnerForHybrid;
import com.github.spotbugs.snom.internal.SpotBugsRunnerForJavaExec;
Expand All @@ -23,7 +22,7 @@ import com.github.spotbugs.snom.internal.SpotBugsTextReport;
import com.github.spotbugs.snom.internal.SpotBugsXmlReport;
import edu.umd.cs.findbugs.annotations.NonNull
import edu.umd.cs.findbugs.annotations.Nullable
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.Action
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.plugins.JavaPluginExtension
Expand All @@ -32,7 +31,6 @@ import org.gradle.api.provider.Provider
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.SkipWhenEmpty

import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.NamedDomainObjectContainer;
Expand All @@ -54,7 +52,6 @@ import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.VerificationTask
import org.gradle.jvm.toolchain.JavaLauncher
import org.gradle.jvm.toolchain.JavaToolchainService;
import org.gradle.util.ClosureBackedAction
import org.gradle.workers.WorkerExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory
Expand Down Expand Up @@ -428,12 +425,6 @@ abstract class SpotBugsTask extends DefaultTask implements VerificationTask {
}
}

final NamedDomainObjectContainer<? extends SpotBugsReport> reports(
Closure<NamedDomainObjectContainer<? extends SpotBugsReport>> closure) {
return reports(
new ClosureBackedAction<NamedDomainObjectContainer<? extends SpotBugsReport>>(closure))
}

final NamedDomainObjectContainer<? extends SpotBugsReport> reports(
Action<NamedDomainObjectContainer<? extends SpotBugsReport>> configureAction) {
configureAction.execute(reports)
Expand Down

0 comments on commit b1ef0d0

Please sign in to comment.