From 1e36cdb432f9f2af206f13f5ca96cea76e23fe4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Kautler?= Date: Thu, 22 Aug 2024 13:11:59 +0200 Subject: [PATCH] Allow to use Action for configuration in extensions to better support non-Groovy consumers (#187) (#404) --- .../gradle/extension/AnalyzerExtension.groovy | 61 ++++++++++++++ .../extension/DependencyCheckExtension.groovy | 84 +++++++++++++++++++ 2 files changed, 145 insertions(+) diff --git a/src/main/groovy/org/owasp/dependencycheck/gradle/extension/AnalyzerExtension.groovy b/src/main/groovy/org/owasp/dependencycheck/gradle/extension/AnalyzerExtension.groovy index e823a8c..c7b807b 100644 --- a/src/main/groovy/org/owasp/dependencycheck/gradle/extension/AnalyzerExtension.groovy +++ b/src/main/groovy/org/owasp/dependencycheck/gradle/extension/AnalyzerExtension.groovy @@ -17,6 +17,7 @@ */ package org.owasp.dependencycheck.gradle.extension +import org.gradle.api.Action import org.gradle.api.Project /** @@ -211,44 +212,104 @@ class AnalyzerExtension { * Allows programmatic configuration of the retirejs extension * @param configClosure the closure to configure the retirejs extension * @return the retirejs extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated() def retirejs(Closure configClosure) { return project.configure(retirejs, configClosure) } + /** + * Allows programmatic configuration of the retirejs extension + * @param config the action to configure the retirejs extension + * @return the retirejs extension + */ + def retirejs(Action config) { + config.execute(retirejs) + return retirejs + } + /** * Allows programmatic configuration of the artifactory extension * @param configClosure the closure to configure the artifactory extension * @return the artifactory extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated() def artifactory(Closure configClosure) { return project.configure(artifactory, configClosure) } + /** + * Allows programmatic configuration of the artifactory extension + * @param config the action to configure the artifactory extension + * @return the artifactory extension + */ + def artifactory(Action config) { + config.execute(artifactory) + return artifactory + } + /** * Allows programmatic configuration of the ossIndex extension * @param configClosure the closure to configure the ossIndex extension * @return the ossIndex extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated() def ossIndex(Closure configClosure) { return project.configure(ossIndex, configClosure) } + /** + * Allows programmatic configuration of the ossIndex extension + * @param config the action to configure the ossIndex extension + * @return the ossIndex extension + */ + def ossIndex(Action config) { + config.execute(ossIndex) + return ossIndex + } + /** * Allows programmatic configuration of the nodeAudit extension * @param configClosure the closure to configure the ossIndex extension * @return the ossIndex extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated() def nodeAudit(Closure configClosure) { return project.configure(nodeAudit, configClosure) } + /** + * Allows programmatic configuration of the nodeAudit extension + * @param config the action to configure the ossIndex extension + * @return the ossIndex extension + */ + def nodeAudit(Action config) { + config.execute(nodeAudit) + return nodeAudit + } + /** * Allows programmatic configuration of the node package extension * @param configClosure the closure to configure the node extension * @return the node extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated() def nodePackage(Closure configClosure) { return project.configure(nodePackage, configClosure) } + + /** + * Allows programmatic configuration of the node package extension + * @param config the action to configure the node extension + * @return the node extension + */ + def nodePackage(Action config) { + config.execute(nodePackage) + return nodePackage + } } diff --git a/src/main/groovy/org/owasp/dependencycheck/gradle/extension/DependencyCheckExtension.groovy b/src/main/groovy/org/owasp/dependencycheck/gradle/extension/DependencyCheckExtension.groovy index a02916b..ed8ad2f 100644 --- a/src/main/groovy/org/owasp/dependencycheck/gradle/extension/DependencyCheckExtension.groovy +++ b/src/main/groovy/org/owasp/dependencycheck/gradle/extension/DependencyCheckExtension.groovy @@ -224,65 +224,149 @@ class DependencyCheckExtension { * Allows programmatic configuration of the proxy extension * @param configClosure the closure to configure the proxy extension * @return the proxy extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated def proxy(Closure configClosure) { return project.configure(proxy, configClosure) } + /** + * Allows programmatic configuration of the proxy extension + * @param config the action to configure the proxy extension + * @return the proxy extension + */ + def proxy(Action config) { + config.execute(proxy) + return proxy + } + /** * Allows programmatic configuration of the slack extension * @param configClosure the closure to configure the slack extension * @return the slack extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated def slack(Closure configClosure) { return project.configure(slack, configClosure) } + /** + * Allows programmatic configuration of the slack extension + * @param config the action to configure the slack extension + * @return the slack extension + */ + def slack(Action config) { + config.execute(slack) + return slack + } + /** * Allows programmatic configuration of the nvd extension * @param configClosure the closure to configure the nvd extension * @return the nvd extension + * n @deprecated Use the {@code Action} variant instead */ + @Deprecated def nvd(Closure configClosure) { return project.configure(nvd, configClosure) } + /** + * Allows programmatic configuration of the nvd extension + * @param config the action to configure the nvd extension + * @return the nvd extension + */ + def nvd(Action config) { + config.execute(nvd) + return nvd + } + /** * Allows programmatic configuration of the hostedSuppressions extension. * @param configClosure the closure to configure the hostedSuppressions extension * @return the hostedSuppressions extension + * n @deprecated Use the {@code Action} variant instead */ + @Deprecated def hostedSuppressions(Closure configClosure) { return project.configure(hostedSuppressions, configClosure) } + /** + * Allows programmatic configuration of the hostedSuppressions extension. + * @param config the action to configure the hostedSuppressions extension + * @return the hostedSuppressions extension + */ + def hostedSuppressions(Action config) { + config.execute(hostedSuppressions) + return hostedSuppressions + } + /** * Allows programmatic configuration of the analyzer extension * @param configClosure the closure to configure the analyzers extension * @return the analyzers extension + * @deprecated Use the {@code Action} variant instead @deprecated Use the {@code Action} variant instead */ + @Deprecated def analyzers(Closure configClosure) { return project.configure(analyzers, configClosure) } + /** + * Allows programmatic configuration of the analyzer extension + * @param config the action to configure the analyzers extension + * @return the analyzers extension + */ + def analyzers(Action config) { + config.execute(analyzers) + return analyzers + } + /** * Allows programmatic configuration of the data extension * @param configClosure the closure to configure the data extension * @return the data extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated def data(Closure configClosure) { return project.configure(data, configClosure) } + /** + * Allows programmatic configuration of the data extension + * @param config the action to configure the data extension + * @return the data extension + */ + def data(Action config) { + config.execute(data) + return data + } + /** * Allows programmatic configuration of the cache extension * @param configClosure the closure to configure the cache extension * @return the cache extension + * @deprecated Use the {@code Action} variant instead */ + @Deprecated def cache(Closure configClosure) { return project.configure(cache, configClosure) } + /** + * Allows programmatic configuration of the cache extension + * @param config the action to configure the cache extension + * @return the cache extension + */ + def cache(Action config) { + config.execute(cache) + return cache + } + /** * Allows programmatic configuration of additional CPEs to be analyzed * @param action the action used to add entries to additional CPEs container.