Make sure ProjectDescriptionDiff is created eagerly

This commit makes sure that the diff instance is created immediately,
taking a snapshot of the ProjectDescription before the customizers are
applied on it.

Previously, the instance was created as part of the supplier and
therefore created only once a component was requiring it.

See gh-1023
This commit is contained in:
Stephane Nicoll 2019-12-27 17:31:22 +01:00
parent 591f6885cb
commit 6c261fd8f1

View File

@ -123,7 +123,10 @@ public class ProjectGenerator {
MutableProjectDescription mutableDescription = (MutableProjectDescription) description;
ProjectDescriptionDiffFactory diffFactory = context.getBeanProvider(ProjectDescriptionDiffFactory.class)
.getIfAvailable(DefaultProjectDescriptionDiffFactory::new);
context.registerBean(ProjectDescriptionDiff.class, () -> diffFactory.create(mutableDescription));
// Create the diff here so that it takes a copy of the description
// immediately
ProjectDescriptionDiff diff = diffFactory.create(mutableDescription);
context.registerBean(ProjectDescriptionDiff.class, () -> diff);
context.getBeanProvider(ProjectDescriptionCustomizer.class).orderedStream()
.forEach((customizer) -> customizer.customize(mutableDescription));
}