From 0b2c3050727be0774e11519024284389cfb680fa Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 2 Jan 2013 11:51:10 -0800 Subject: [PATCH] Recursively add test dependencies Update TestSourceSetDependenciesPlugin to recursively search project dependencies when adding test source sets. --- .../TestSourceSetDependenciesPlugin.groovy | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy b/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy index 1e5cffcc7b..363c66c00f 100644 --- a/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy +++ b/buildSrc/src/main/groovy/org/springframework/build/gradle/TestSourceSetDependenciesPlugin.groovy @@ -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 { public void apply(Project project) { project.afterEvaluate { Set 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 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) + } + } + } + } + }