Skip to content

Commit

Permalink
Merge pull request #261 from nebula-plugins/fix-generateLock
Browse files Browse the repository at this point in the history
GenerateLockTask: go back to conventionMapping
  • Loading branch information
rpalcolea authored Nov 14, 2023
2 parents f224afb + 19e0b0e commit eb2fd35
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,17 @@ class DependencyLockTaskConfigurer {
shouldIgnoreDependencyLock.set(isIgnoreDependencyLock(project))
filter.set(extension.dependencyFilter)
peers.set(getProjectPeers())
configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, extension.configurationNames.get(), extension.skippedConfigurationNamesPrefixes.get()).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

lockTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
package nebula.plugin.dependencylock.tasks

import nebula.plugin.dependencylock.model.ConfigurationResolutionData
import org.gradle.api.provider.ListProperty
import org.gradle.api.tasks.Internal
import org.gradle.work.DisableCachingByDefault

@DisableCachingByDefault
abstract class GenerateLockTask extends AbstractGenerateLockTask {
@Internal
abstract ListProperty<ConfigurationResolutionData> getConfigurationResolutionData()
Collection<ConfigurationResolutionData> configurationResolutionData = []

@Override
List<ConfigurationResolutionData> resolveConfigurations() {
return configurationResolutionData.get()
return getConfigurationResolutionData()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.dependenciesLock.set new File(project.layout.buildDirectory.getAsFile().get(), 'dependencies.lock')
task.configurationNames.set(['testRuntimeClasspath'])
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}

}

Expand Down Expand Up @@ -93,15 +95,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set configurationNames

task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, configurationNames).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

when:
Expand Down Expand Up @@ -141,15 +145,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
def skippedConfigurationNames = ['zinc', 'incrementalAnalysis'] as Set<String>
task.skippedConfigurationNames.set(skippedConfigurationNames)
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project,configurationNames, skippedConfigurationNames).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

when:
Expand Down Expand Up @@ -179,15 +185,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.skippedDependencies.set(['test.example:foo'])
task.includeTransitives.set(true)
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

String lockText = '''\
Expand Down Expand Up @@ -233,15 +241,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.dependenciesLock.set(new File(app.layout.buildDirectory.getAsFile().get(), 'dependencies.lock'))
task.configurationNames.set( ['testRuntimeClasspath'])
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}
task.peers.set(app.rootProject.allprojects.collect { new LockKey(group: it.group, artifact: it.name) })

Expand Down Expand Up @@ -290,15 +300,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.includeTransitives.set(true)
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}
task.peers.set(app.rootProject.allprojects.collect { new LockKey(group: it.group, artifact: it.name) })

Expand Down Expand Up @@ -355,15 +367,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.dependenciesLock.set new File(app.layout.buildDirectory.getAsFile().get(), 'dependencies.lock')
task.configurationNames.set(['testRuntimeClasspath'])
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}
task.peers.set(app.rootProject.allprojects.collect { new LockKey(group: it.group, artifact: it.name) })

Expand Down Expand Up @@ -441,15 +455,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.dependenciesLock.set new File(app.layout.buildDirectory.getAsFile().get(), 'dependencies.lock')
task.configurationNames.set(['testRuntimeClasspath'])
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}
task.peers.set(app.rootProject.allprojects.collect { new LockKey(group: it.group, artifact: it.name) })

Expand Down Expand Up @@ -500,15 +516,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.includeTransitives.set true
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

when:
Expand Down Expand Up @@ -545,15 +563,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.includeTransitives.set true
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

when:
Expand Down Expand Up @@ -593,15 +613,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.includeTransitives.set true
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

when:
Expand Down Expand Up @@ -646,15 +668,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.includeTransitives.set true
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}
when:
task.lock()
Expand Down Expand Up @@ -700,15 +724,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.includeTransitives.set true
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}
when:
task.lock()
Expand Down Expand Up @@ -765,15 +791,17 @@ class GenerateLockTaskSpec extends ProjectSpec {
task.configurationNames.set(['testRuntimeClasspath'])
task.filter.set(filter as Closure)
task.configure { generateLockTask ->
generateLockTask.configurationResolutionData.set(
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, ['testRuntimeClasspath'] as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
)
}
}
}

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ class UpdateLockTaskSpec extends ProjectSpec {
task.dependenciesLock = new File(project.layout.buildDirectory.getAsFile().get(), 'dependencies.lock')
task.configurationNames = LockGenerator.DEFAULT_CONFIG_NAMES
task.configure { generateLockTask ->
configurationResolutionData.set(lockableConfigurations(project, LockGenerator.DEFAULT_CONFIG_NAMES as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
})
generateLockTask.conventionMapping.with {
configurationResolutionData = {
lockableConfigurations(project, LockGenerator.DEFAULT_CONFIG_NAMES as Set<String>).findAll { it.isCanBeResolved() }.collect {
new ConfigurationResolutionData(
it.name,
it.incoming.resolutionResult.getAllDependencies(),
it.incoming.resolutionResult.rootComponent
)
}
}
}
}
task
}
Expand Down

0 comments on commit eb2fd35

Please sign in to comment.