Skip to content

Commit 855b7cd

Browse files
authored
[ANE-695] gradle: check if configuration is deprecated (#1457)
* gradle: check if configuration is deprecated * update changelog * update gradle strategy * polish
1 parent 19e2bac commit 855b7cd

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# FOSSA CLI Changelog
22

3+
## Unreleased
4+
5+
- Gradle: ignore deprecated configurations ([#1457](https://github.com/fossas/fossa-cli/pull/1457))
6+
37
## 3.9.30
48

59
- Vendored Dependencies: add support for metadata (description, and homepage) for dependencies. ([#1455](https://github.com/fossas/fossa-cli/pull/1455))

docs/references/strategies/languages/gradle/gradle.md

+7
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ experimental:
221221
222222
## Reference
223223
224+
### Deprecated Configurations
225+
226+
> [!Note]
227+
> FOSSA CLI excludes deprecated configurations from analysis.
228+
229+
With newer versions of gradle, some configurations are no longer supported (`compile` for example). Before the configurations are removed, gradle deprecates the configuration with a warning. These configurations should not declare dependencies and resolution will be incorrect ([see here](https://github.com/gradle/gradle/issues/8585)).
230+
224231
### Development and Test Configurations
225232

226233
> [!NOTE]

scripts/jsondeps.gradle

+11-5
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ allprojects {
151151
def jsonConfigs = []
152152
// project.configurations returns a `ConfigurationContainer`, which iteself implements the `DomainObjectCollection` interface.
153153
// This interface provides two additional ways of configuring elements in the collection in addition to Groovy's `each`:
154-
// `all`, a method that eagerly executes the provided `Action` or `Closure` against the current elements of the collection
154+
// `all`, a method that eagerly executes the provided `Action` or `Closure` against the current elements of the collection
155155
// **and** any subsequent additions
156-
// and `configureEach`, a method that lazily executes the provied `Closure` against the current elements of the collection
156+
// and `configureEach`, a method that lazily executes the provied `Closure` against the current elements of the collection
157157
// and anay additions on an as-needed basis.
158158
//
159159
// While theoretically the use of `each` should produce similar results to the use of `all` or `configureEach`, that cannot be
160160
// guaranteed as other plugins or even gradle build authors also have the ability to access and modify the configurations during
161161
// the Gradle configuration phase (eg, via dependency substitution). This is a particular risk for this script plugin, as it is
162-
// highly likely that the jsonDepstask will be configured early in the configuration phase (because it is added as an init
162+
// highly likely that the jsonDepstask will be configured early in the configuration phase (because it is added as an init
163163
// script). The solution here is to use `all` or `configureEach` for enhanced laziness; `all` seems most prudent given the
164-
// functionaliy that this task attempts to achieve.
164+
// functionaliy that this task attempts to achieve.
165165
//
166166
// links:
167167
// ConfiguationContainer: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/ConfigurationContainer.html
@@ -174,7 +174,13 @@ allprojects {
174174
// If we are in gradle v3.3 or greater (isCanBeResolved method should exists)
175175
// And if configuration is not resolvable, disregard current config for dependency resolution.
176176
if (config.respondsTo("isCanBeResolved") && !config.isCanBeResolved()) {
177-
printDebugToFossa ("Configuration is not resolvable: ${config}!", "projectToJsonWithResolutionApi")
177+
printDebugToFossa("Configuration is not resolvable: ${config}!", "projectToJsonWithResolutionApi")
178+
return null
179+
}
180+
// If we are in grade v6.0 we need to check `isFullyDeprecated` to ensure we ignore deprecated
181+
// configurations like `runtime`.
182+
if (config.respondsTo("isFullyDeprecated") && config.isFullyDeprecated()) {
183+
printDebugToFossa("Configuration is deprecated: ${config}", "projectToJsonWithResolutionApi")
178184
return null
179185
}
180186
result = resolvedConfigToJSON (config)

0 commit comments

Comments
 (0)