diff --git a/initializr-web/src/main/java/io/spring/initializr/web/project/ProjectGenerationInvoker.java b/initializr-web/src/main/java/io/spring/initializr/web/project/ProjectGenerationInvoker.java index 229efde605..dcddd74f72 100644 --- a/initializr-web/src/main/java/io/spring/initializr/web/project/ProjectGenerationInvoker.java +++ b/initializr-web/src/main/java/io/spring/initializr/web/project/ProjectGenerationInvoker.java @@ -59,7 +59,7 @@ public class ProjectGenerationInvoker { private final ProjectAssetGenerator projectAssetGenerator = new DefaultProjectAssetGenerator(); - private final transient Map> temporaryFiles = new ConcurrentHashMap<>(); + private final Map> temporaryFiles = new ConcurrentHashMap<>(); public ProjectGenerationInvoker(ApplicationContext parentApplicationContext, ProjectRequestToDescriptionConverter requestConverter) { @@ -83,8 +83,7 @@ public ProjectGenerationResult invokeProjectStructureGeneration(R request) { InitializrMetadata metadata = this.parentApplicationContext.getBean(InitializrMetadataProvider.class).get(); try { ProjectDescription description = this.requestConverter.convert(request, metadata); - ProjectGenerator projectGenerator = new ProjectGenerator(( - projectGenerationContext) -> customizeProjectGenerationContext(projectGenerationContext, metadata)); + ProjectGenerator projectGenerator = createProjectGenerator(metadata); ProjectGenerationResult result = projectGenerator.generate(description, generateProject(description, request)); addTempFile(result.getRootDirectory(), result.getRootDirectory()); @@ -125,8 +124,7 @@ public byte[] invokeBuildGeneration(R request) { InitializrMetadata metadata = this.parentApplicationContext.getBean(InitializrMetadataProvider.class).get(); try { ProjectDescription description = this.requestConverter.convert(request, metadata); - ProjectGenerator projectGenerator = new ProjectGenerator(( - projectGenerationContext) -> customizeProjectGenerationContext(projectGenerationContext, metadata)); + ProjectGenerator projectGenerator = createProjectGenerator(metadata); return projectGenerator.generate(description, generateBuild(request)); } catch (ProjectGenerationException ex) { @@ -135,6 +133,16 @@ public byte[] invokeBuildGeneration(R request) { } } + /** + * Creates the project generator using provided metadata. + * @param metadata metadata to build the {@link ProjectGenerator} used by this invoker + * @return project generator used to generate the project + */ + protected ProjectGenerator createProjectGenerator(InitializrMetadata metadata) { + return new ProjectGenerator( + (projectGenerationContext) -> customizeProjectGenerationContext(projectGenerationContext, metadata)); + } + private ProjectAssetGenerator generateBuild(R request) { return (context) -> { byte[] content = generateBuild(context);