Browse Source

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
pull/1143/merge
Rob Winch 9 years ago
parent
commit
09f16747b5
  1. 19
      buildSrc/src/main/groovy/org/springframework/build/gradle/MergePlugin.groovy

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

@ -64,6 +64,7 @@ class MergePlugin implements Plugin<Project> { @@ -64,6 +64,7 @@ class MergePlugin implements Plugin<Project> {
project.plugins.apply(IdeaPlugin)
MergeModel model = project.extensions.create("merge", MergeModel)
model.project = project
project.configurations.create("merging")
Configuration runtimeMerge = project.configurations.create("runtimeMerge")
@ -76,6 +77,7 @@ class MergePlugin implements Plugin<Project> { @@ -76,6 +77,7 @@ class MergePlugin implements Plugin<Project> {
if (it.merge.into != null) {
setup(it)
}
setupIdeDependencies(it)
}
// Hook to build runtimeMerge dependencies
@ -114,6 +116,16 @@ class MergePlugin implements Plugin<Project> { @@ -114,6 +116,16 @@ class MergePlugin implements Plugin<Project> {
}
}
private void setupIdeDependencies(Project project) {
project.configurations.each { c ->
c.dependencies.findAll( { it instanceof org.gradle.api.artifacts.ProjectDependency } ).each { d ->
d.dependencyProject.merge.from.each { from ->
project.dependencies.add("runtimeMerge", from)
}
}
}
}
private void setupMaven(Project project) {
project.configurations.each { configuration ->
Conf2ScopeMapping mapping = project.conf2ScopeMappings.getMapping([configuration])
@ -154,5 +166,12 @@ class MergePlugin implements Plugin<Project> { @@ -154,5 +166,12 @@ class MergePlugin implements Plugin<Project> {
}
class MergeModel {
Project project;
Project into;
List<Project> from = [];
public void setInto(Project into) {
this.into = into;
into.merge.from.add(project);
}
}

Loading…
Cancel
Save