Permalink
Browse files

Recursively add test dependencies

Update TestSourceSetDependenciesPlugin to recursively search project
dependencies when adding test source sets.
  • Loading branch information...
1 parent c892b81 commit 0b2c3050727be0774e11519024284389cfb680fa Phillip Webb committed Jan 2, 2013
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,18 +34,24 @@ class TestSourceSetDependenciesPlugin implements Plugin<Project> {
public void apply(Project project) {
project.afterEvaluate {
Set<ProjectDependency> projectDependencies = new LinkedHashSet<>()
- for(def configurationName in ["compile", "optional", "provided"]) {
- Configuration configuration = project.getConfigurations().findByName(configurationName)
- if(configuration) {
- projectDependencies.addAll(
- configuration.dependencies.findAll { it instanceof ProjectDependency }
- )
- }
- }
+ collectProjectDependencies(projectDependencies, project)
projectDependencies.each {
project.dependencies.add("testCompile", it.dependencyProject.sourceSets.test.output)
}
}
}
+ private void collectProjectDependencies(Set<ProjectDependency> projectDependencies,
+ Project project) {
+ for(def configurationName in ["compile", "optional", "provided"]) {
+ Configuration configuration = project.getConfigurations().findByName(configurationName)
+ if(configuration) {
+ configuration.dependencies.findAll { it instanceof ProjectDependency }.each {
+ projectDependencies.add(it)
+ collectProjectDependencies(projectDependencies, it.dependencyProject)
+ }
+ }
+ }
+ }
+
}

0 comments on commit 0b2c305

Please sign in to comment.