From 07a7fe1d0dcac85912fbd088ac9096090f757807 Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Tue, 14 Nov 2023 21:11:24 -0800 Subject: [PATCH] DependencyLockExtension: skippedConfigurationNamesPrefixes not lazy api for backwrads compatibility --- .../plugin/dependencylock/DependencyLockExtension.groovy | 4 ++-- .../dependencylock/DependencyLockTaskConfigurer.groovy | 8 ++++---- .../nebula/plugin/dependencylock/DependencyLockPlugin.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockExtension.groovy b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockExtension.groovy index 73ecae6..1c973c2 100644 --- a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockExtension.groovy +++ b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockExtension.groovy @@ -23,7 +23,6 @@ abstract class DependencyLockExtension { lockFile.convention('dependencies.lock') globalLockFile.convention('global.lock') configurationNames.convention([]) - skippedConfigurationNamesPrefixes.convention([]) updateDependencies.convention([]) skippedDependencies.convention([]) includeTransitives.convention(false) @@ -37,7 +36,6 @@ abstract class DependencyLockExtension { abstract Property getLockFile() abstract Property getGlobalLockFile() abstract SetProperty getConfigurationNames() - abstract SetProperty getSkippedConfigurationNamesPrefixes() abstract SetProperty getUpdateDependencies() abstract SetProperty getSkippedDependencies() abstract Property getIncludeTransitives() @@ -47,5 +45,7 @@ abstract class DependencyLockExtension { abstract Property getUpdateDependenciesFailOnNonSpecifiedDependenciesToUpdate() abstract SetProperty getAdditionalConfigurationsToLock() + Set skippedConfigurationNamesPrefixes = [] as Set + Closure dependencyFilter = { String group, String name, String version -> true } } diff --git a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy index 1cfc022..0088020 100644 --- a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy +++ b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockTaskConfigurer.groovy @@ -202,7 +202,7 @@ class DependencyLockTaskConfigurer { peers.set(getProjectPeers()) generateLockTask.conventionMapping.with { configurationResolutionData = { - lockableConfigurations(project, extension.configurationNames.get(), extension.skippedConfigurationNamesPrefixes.get()).findAll { it.isCanBeResolved() }.collect { + lockableConfigurations(project, extension.configurationNames.get(), extension.skippedConfigurationNamesPrefixes).findAll { it.isCanBeResolved() }.collect { new ConfigurationResolutionData( it.name, it.incoming.resolutionResult.getAllDependencies(), @@ -237,7 +237,7 @@ class DependencyLockTaskConfigurer { def subprojects = project.subprojects.collect { subproject -> def ext = subproject.getExtensions().findByType(DependencyLockExtension) if (ext != null) { - Collection lockableConfigurations = lockableConfigurations(subproject, ext.configurationNames.get(), extension.skippedConfigurationNamesPrefixes.get()) + Collection lockableConfigurations = lockableConfigurations(subproject, ext.configurationNames.get(), extension.skippedConfigurationNamesPrefixes) Collection configurations = filterNonLockableConfigurationsAndProvideWarningsForGlobalLockSubproject(subproject, ext.configurationNames.get(), lockableConfigurations) Configuration aggregate = subproject.configurations.create("aggregateConfiguration") aggregate.setCanBeConsumed(true) @@ -245,7 +245,7 @@ class DependencyLockTaskConfigurer { configurations .findAll { configuration -> !configurationsToSkipForGlobalLockPrefixes.any { String prefix -> configuration.name.startsWith(prefix) } - && !extension.skippedConfigurationNamesPrefixes.get().any { String prefix -> configuration.name.startsWith(prefix) } + && !extension.skippedConfigurationNamesPrefixes.any { String prefix -> configuration.name.startsWith(prefix) } } .each { configuration -> aggregate.extendsFrom(configuration) @@ -259,7 +259,7 @@ class DependencyLockTaskConfigurer { def conf = project.configurations.detachedConfiguration(subprojectsArray) project.allprojects.each { it.configurations.add(conf) } - def configs = [conf] + ConfigurationUtils.lockableConfigurations(project, extension.configurationNames.get(), extension.skippedConfigurationNamesPrefixes.get()) + def configs = [conf] + ConfigurationUtils.lockableConfigurations(project, extension.configurationNames.get(), extension.skippedConfigurationNamesPrefixes) configs.findAll { it.isCanBeResolved() }.collect { new ConfigurationResolutionData( it.name, diff --git a/src/main/kotlin/nebula/plugin/dependencylock/DependencyLockPlugin.kt b/src/main/kotlin/nebula/plugin/dependencylock/DependencyLockPlugin.kt index 1c2afc3..d13386a 100644 --- a/src/main/kotlin/nebula/plugin/dependencylock/DependencyLockPlugin.kt +++ b/src/main/kotlin/nebula/plugin/dependencylock/DependencyLockPlugin.kt @@ -186,7 +186,7 @@ class DependencyLockPlugin : Plugin { } private fun maybeApplyLock(conf: Configuration, extension: DependencyLockExtension, overrides: Map<*, *>, globalLockFileName: String?, lockFilename: String?) { - val shouldIgnoreLock = (extension.skippedConfigurationNamesPrefixes.get() + DependencyLockTaskConfigurer.configurationsToSkipForGlobalLockPrefixes).any { + val shouldIgnoreLock = (extension.skippedConfigurationNamesPrefixes + DependencyLockTaskConfigurer.configurationsToSkipForGlobalLockPrefixes).any { prefix -> conf.name.startsWith(prefix) && !conf.name.contains("resolutionRules") } if(shouldIgnoreLock) {