Skip to content

Commit a24fd6f

Browse files
committed
Modernization Phase 3.6: Convert DependencyResolutionVerifier to use findProperty
Replace eager hasProperty/property access with findProperty(): - verifySuccessfulResolution(): Use findProperty() for CONFIGURATIONS_TO_EXCLUDE - unresolvedDependenciesShouldFailTheBuild(): Use findProperty() for fail flag Benefits: - Single API call instead of hasProperty() + property() - Null-safe by design (returns null vs throwing exception) - Checks both gradle properties (-P) and project extras (ext) - Modern Gradle API recommended approach
1 parent b1b59df commit a24fd6f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/main/kotlin/nebula/plugin/dependencyverifier/DependencyResolutionVerifier.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ class DependencyResolutionVerifier {
6161
this.project = project
6262
this.extension = project.rootProject.extensions.findByType(DependencyResolutionVerifierExtension::class.java)!!
6363
this.configurationsToExcludeOverride = mutableSetOf()
64-
if (project.hasProperty(CONFIGURATIONS_TO_EXCLUDE)) {
65-
configurationsToExcludeOverride.addAll((project.property(CONFIGURATIONS_TO_EXCLUDE) as String).split(","))
64+
// Use findProperty to check both gradle properties (-P) and project extras (ext)
65+
val configurationsToExclude = project.findProperty(CONFIGURATIONS_TO_EXCLUDE)
66+
if (configurationsToExclude != null) {
67+
configurationsToExcludeOverride.addAll(configurationsToExclude.toString().split(","))
6668
}
6769
val uniqueProjectKey = uniqueProjectKey(project)
6870
failedDependenciesPerProjectForConfigurations[uniqueProjectKey] = mutableMapOf()
@@ -344,8 +346,10 @@ class DependencyResolutionVerifier {
344346
}
345347

346348
private fun unresolvedDependenciesShouldFailTheBuild(): Boolean {
347-
return if (project.hasProperty(UNRESOLVED_DEPENDENCIES_FAIL_THE_BUILD)) {
348-
(project.property(UNRESOLVED_DEPENDENCIES_FAIL_THE_BUILD) as String).toBoolean()
349+
// Use findProperty to check both gradle properties (-P) and project extras (ext)
350+
val shouldFailProp = project.findProperty(UNRESOLVED_DEPENDENCIES_FAIL_THE_BUILD)
351+
return if (shouldFailProp != null) {
352+
shouldFailProp.toString().toBoolean()
349353
} else {
350354
extension.shouldFailTheBuild.get()
351355
}

0 commit comments

Comments
 (0)