Skip to content

Commit 09f1674

Browse files
author
Rob Winch
committed
Fix MergePlugin transitive dependencies
A little terminiology first: * merge.from - a project that contains source that will be merged into merge.into * merge.into - a project that contains source code that will have code from merge.from merged into it. Previously a module that dependended on merge.into would not see the merge.from module as a transitive dependency. This worked fine from a Gradle build because all the code from merge.from is merged into the merge.into jar. However, in an IDE it did not work because the IDE does not assemble a jar. This fix ensures that merge.from modules are automatically added to the classpath of any module relying on the merge.into project. Fixes SPR-14650
1 parent 634d1c0 commit 09f1674

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class MergePlugin implements Plugin<Project> {
6464
project.plugins.apply(IdeaPlugin)
6565

6666
MergeModel model = project.extensions.create("merge", MergeModel)
67+
model.project = project
6768
project.configurations.create("merging")
6869
Configuration runtimeMerge = project.configurations.create("runtimeMerge")
6970

@@ -76,6 +77,7 @@ class MergePlugin implements Plugin<Project> {
7677
if (it.merge.into != null) {
7778
setup(it)
7879
}
80+
setupIdeDependencies(it)
7981
}
8082

8183
// Hook to build runtimeMerge dependencies
@@ -114,6 +116,16 @@ class MergePlugin implements Plugin<Project> {
114116
}
115117
}
116118

119+
private void setupIdeDependencies(Project project) {
120+
project.configurations.each { c ->
121+
c.dependencies.findAll( { it instanceof org.gradle.api.artifacts.ProjectDependency } ).each { d ->
122+
d.dependencyProject.merge.from.each { from ->
123+
project.dependencies.add("runtimeMerge", from)
124+
}
125+
}
126+
}
127+
}
128+
117129
private void setupMaven(Project project) {
118130
project.configurations.each { configuration ->
119131
Conf2ScopeMapping mapping = project.conf2ScopeMappings.getMapping([configuration])
@@ -154,5 +166,12 @@ class MergePlugin implements Plugin<Project> {
154166
}
155167

156168
class MergeModel {
169+
Project project;
157170
Project into;
171+
List<Project> from = [];
172+
173+
public void setInto(Project into) {
174+
this.into = into;
175+
into.merge.from.add(project);
176+
}
158177
}

0 commit comments

Comments
 (0)