diff --git a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy index a4bfe6b6..e90e3f5e 100644 --- a/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy +++ b/src/main/groovy/nebula/plugin/dependencylock/DependencyLockPlugin.groovy @@ -281,7 +281,7 @@ class DependencyLockPlugin implements Plugin { def subprojects = project.subprojects.collect { subproject -> def ext = subproject.getExtensions().findByType(DependencyLockExtension) if (ext != null) { - def configurations = getConfigurationsFromConfigurationNames(subproject, ext.configurationNames) + def configurations = getConfigurationsFromConfigurationNames(project, subproject, ext.configurationNames) configurations.collect { configuration -> project.dependencies.create(project.dependencies.project(path: subproject.path, configuration: configuration.name)) } @@ -293,7 +293,7 @@ class DependencyLockPlugin implements Plugin { def conf = project.configurations.detachedConfiguration(subprojectsArray) project.allprojects.each { it.configurations.add(conf) } - [conf] + getConfigurationsFromConfigurationNames(project, extension.configurationNames) + [conf] + getConfigurationsFromConfigurationNames(project, project, extension.configurationNames) } } diff --git a/src/main/groovy/nebula/plugin/dependencylock/tasks/GenerateLockTask.groovy b/src/main/groovy/nebula/plugin/dependencylock/tasks/GenerateLockTask.groovy index 8bfdd0d0..127dd274 100644 --- a/src/main/groovy/nebula/plugin/dependencylock/tasks/GenerateLockTask.groovy +++ b/src/main/groovy/nebula/plugin/dependencylock/tasks/GenerateLockTask.groovy @@ -23,7 +23,7 @@ import org.gradle.api.artifacts.ExternalDependency import org.gradle.api.artifacts.ResolvedDependency import org.gradle.api.tasks.TaskAction -import static nebula.plugin.dependencylock.DependencyLockPlugin.* +import static nebula.plugin.dependencylock.DependencyLockPlugin.GLOBAL_LOCK_CONFIG class GenerateLockTask extends AbstractLockTask { String description = 'Create a lock file in build/' @@ -37,14 +37,24 @@ class GenerateLockTask extends AbstractLockTask { @TaskAction void lock() { - Collection confs = getConfigurations() ?: getConfigurationsFromConfigurationNames(project, getConfigurationNames()) + Collection confs = getConfigurations() ?: getConfigurationsFromConfigurationNames(project, project, getConfigurationNames()) def dependencyMap = readDependenciesFromConfigurations(confs) writeLock(dependencyMap) } - public static Collection getConfigurationsFromConfigurationNames(Project project, Set configurationNames) { + public static Collection getConfigurationsFromConfigurationNames(Project taskProject, Project project, Set configurationNames) { if (configurationNames.empty) { - project.configurations.asList() + if (Configuration.class.declaredMethods.any { it.name == 'isCanBeResolved' }) { + project.configurations.findAll { + if (taskProject == project) { + it.canBeResolved + } else { + it.canBeResolved && it.canBeConsumed + } + } + } else { + project.configurations.asList() + } } else { configurationNames.collect { project.configurations.getByName(it) } } diff --git a/src/test/groovy/nebula/plugin/dependencylock/util/LockGenerator.groovy b/src/test/groovy/nebula/plugin/dependencylock/util/LockGenerator.groovy index 653e2f13..353fa4d7 100644 --- a/src/test/groovy/nebula/plugin/dependencylock/util/LockGenerator.groovy +++ b/src/test/groovy/nebula/plugin/dependencylock/util/LockGenerator.groovy @@ -16,7 +16,7 @@ package nebula.plugin.dependencylock.util class LockGenerator { - static final Collection DEFAULT_CONFIG_NAMES = ['compile', 'compileClasspath', 'compileOnly', 'default', 'runtime', 'testCompile', 'testCompileClasspath', 'testCompileOnly', 'testRuntime'] + static final Collection DEFAULT_CONFIG_NAMES = ['compile', 'compileClasspath', 'default', 'runtime', 'runtimeClasspath', 'testCompile', 'testCompileClasspath', 'testRuntime', 'testRuntimeClasspath'] /** * Helper to copy the exact same lock block multiple times into different configurations