Skip to content

Commit

Permalink
Fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielThomas committed Jan 27, 2017
1 parent d362381 commit 0d18f8c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class DependencyLockPlugin implements Plugin<Project> {
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))
}
Expand All @@ -293,7 +293,7 @@ class DependencyLockPlugin implements Plugin<Project> {
def conf = project.configurations.detachedConfiguration(subprojectsArray)
project.allprojects.each { it.configurations.add(conf) }

[conf] + getConfigurationsFromConfigurationNames(project, extension.configurationNames)
[conf] + getConfigurationsFromConfigurationNames(project, project, extension.configurationNames)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/<configured name>'
Expand All @@ -37,14 +37,24 @@ class GenerateLockTask extends AbstractLockTask {

@TaskAction
void lock() {
Collection<Configuration> confs = getConfigurations() ?: getConfigurationsFromConfigurationNames(project, getConfigurationNames())
Collection<Configuration> confs = getConfigurations() ?: getConfigurationsFromConfigurationNames(project, project, getConfigurationNames())
def dependencyMap = readDependenciesFromConfigurations(confs)
writeLock(dependencyMap)
}

public static Collection<Configuration> getConfigurationsFromConfigurationNames(Project project, Set<String> configurationNames) {
public static Collection<Configuration> getConfigurationsFromConfigurationNames(Project taskProject, Project project, Set<String> 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) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package nebula.plugin.dependencylock.util

class LockGenerator {
static final Collection<String> DEFAULT_CONFIG_NAMES = ['compile', 'compileClasspath', 'compileOnly', 'default', 'runtime', 'testCompile', 'testCompileClasspath', 'testCompileOnly', 'testRuntime']
static final Collection<String> 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
Expand Down

0 comments on commit 0d18f8c

Please sign in to comment.