mirror of
https://gitee.com/dcren/initializr.git
synced 2026-08-13 15:03:33 +08:00
Migrate ProjectDescription to an interface
This commit migrates ProjectDescription to an interface with read-only accessors and create a MutableProjectDescription implementation that can be used for both purposes. As a result, the type separation between ResolvedProjectDescription and ProjectDescription is no longer necessary. Closes gh-993
This commit is contained in:
@@ -25,7 +25,7 @@ import io.spring.initializr.generator.io.template.MustacheTemplateRenderer;
|
||||
import io.spring.initializr.generator.language.Language;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.project.DefaultProjectAssetGenerator;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerator;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
@@ -62,8 +62,8 @@ class ProjectGeneratorSetupExampleTests {
|
||||
assertThat(helloFile).exists().isRegularFile().hasContent("Test");
|
||||
}
|
||||
|
||||
private ProjectDescription createProjectDescription() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
private MutableProjectDescription createProjectDescription() {
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setGroupId("com.example");
|
||||
description.setArtifactId("demo");
|
||||
description.setApplicationName("DemoApplication");
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.spring.initializr.generator.buildsystem.DependencyScope;
|
||||
import io.spring.initializr.generator.condition.ConditionalOnPackaging;
|
||||
import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.maven.DefaultMavenBuildCustomizer;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
@@ -72,8 +72,8 @@ public class BuildProjectGenerationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DefaultMavenBuildCustomizer initializrMetadataMavenBuildCustomizer(
|
||||
ResolvedProjectDescription projectDescription, InitializrMetadata metadata) {
|
||||
public DefaultMavenBuildCustomizer initializrMetadataMavenBuildCustomizer(ProjectDescription projectDescription,
|
||||
InitializrMetadata metadata) {
|
||||
return new DefaultMavenBuildCustomizer(projectDescription, metadata);
|
||||
}
|
||||
|
||||
@@ -85,18 +85,17 @@ public class BuildProjectGenerationConfiguration {
|
||||
|
||||
@Bean
|
||||
public DependencyManagementBuildCustomizer dependencyManagementBuildCustomizer(
|
||||
ResolvedProjectDescription projectDescription, InitializrMetadata metadata) {
|
||||
ProjectDescription projectDescription, InitializrMetadata metadata) {
|
||||
return new DependencyManagementBuildCustomizer(projectDescription, metadata);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SimpleBuildCustomizer projectDescriptionBuildCustomizer(ResolvedProjectDescription projectDescription) {
|
||||
public SimpleBuildCustomizer projectDescriptionBuildCustomizer(ProjectDescription projectDescription) {
|
||||
return new SimpleBuildCustomizer(projectDescription);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringBootVersionRepositoriesBuildCustomizer repositoriesBuilderCustomizer(
|
||||
ResolvedProjectDescription description) {
|
||||
public SpringBootVersionRepositoriesBuildCustomizer repositoriesBuilderCustomizer(ProjectDescription description) {
|
||||
return new SpringBootVersionRepositoriesBuildCustomizer(description.getPlatformVersion());
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.Build;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
@@ -39,12 +39,11 @@ import org.springframework.core.Ordered;
|
||||
*/
|
||||
public class DependencyManagementBuildCustomizer implements BuildCustomizer<Build> {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final InitializrMetadata metadata;
|
||||
|
||||
public DependencyManagementBuildCustomizer(ResolvedProjectDescription projectDescription,
|
||||
InitializrMetadata metadata) {
|
||||
public DependencyManagementBuildCustomizer(ProjectDescription projectDescription, InitializrMetadata metadata) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@@ -17,22 +17,22 @@
|
||||
package io.spring.initializr.generator.spring.build;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.Build;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
|
||||
/**
|
||||
* Customize the {@link Build} as early as possible based on the information held in the
|
||||
* {@link ResolvedProjectDescription}.
|
||||
* {@link ProjectDescription}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SimpleBuildCustomizer implements BuildCustomizer<Build> {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
public SimpleBuildCustomizer(ResolvedProjectDescription projectDescription) {
|
||||
public SimpleBuildCustomizer(ProjectDescription projectDescription) {
|
||||
this.projectDescription = projectDescription;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.spring.build.gradle;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
/**
|
||||
* Strategy for resolving a dependency management plugin version from a platform version.
|
||||
@@ -33,6 +33,6 @@ public interface DependencyManagementPluginVersionResolver {
|
||||
* @return the corresponding version for the {@code io.spring.dependency-management}
|
||||
* plugin
|
||||
*/
|
||||
String resolveDependencyManagementPluginVersion(ResolvedProjectDescription description);
|
||||
String resolveDependencyManagementPluginVersion(ProjectDescription description);
|
||||
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion;
|
||||
import io.spring.initializr.generator.io.IndentingWriterFactory;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
||||
import io.spring.initializr.generator.spring.util.LambdaSafe;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
@@ -78,7 +78,7 @@ public class GradleProjectGenerationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BuildCustomizer<GradleBuild> defaultGradleBuildCustomizer(ResolvedProjectDescription projectDescription) {
|
||||
public BuildCustomizer<GradleBuild> defaultGradleBuildCustomizer(ProjectDescription projectDescription) {
|
||||
return (build) -> build.setSourceCompatibility(projectDescription.getLanguage().jvmVersion());
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class GradleProjectGenerationConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnPlatformVersion("2.0.0.M1")
|
||||
BuildCustomizer<GradleBuild> springBootPluginContributor(ResolvedProjectDescription projectDescription,
|
||||
BuildCustomizer<GradleBuild> springBootPluginContributor(ProjectDescription projectDescription,
|
||||
ObjectProvider<DependencyManagementPluginVersionResolver> versionResolver, InitializrMetadata metadata) {
|
||||
return new SpringBootPluginBuildCustomizer(projectDescription, versionResolver
|
||||
.getIfAvailable(() -> new InitializrDependencyManagementPluginVersionResolver(metadata)));
|
||||
@@ -145,7 +145,7 @@ public class GradleProjectGenerationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
BuildCustomizer<GradleBuild> springBootPluginContributor(ResolvedProjectDescription projectDescription) {
|
||||
BuildCustomizer<GradleBuild> springBootPluginContributor(ProjectDescription projectDescription) {
|
||||
return (build) -> {
|
||||
build.buildscript(
|
||||
(buildscript) -> buildscript.dependency("org.springframework.boot:spring-boot-gradle-plugin:"
|
||||
@@ -206,7 +206,7 @@ public class GradleProjectGenerationConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
BuildCustomizer<GradleBuild> springBootPluginContributor(ResolvedProjectDescription projectDescription) {
|
||||
BuildCustomizer<GradleBuild> springBootPluginContributor(ProjectDescription projectDescription) {
|
||||
return (build) -> build.plugins().add("org.springframework.boot",
|
||||
(plugin) -> plugin.setVersion(projectDescription.getPlatformVersion().toString()));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.spring.build.gradle;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ public class InitializrDependencyManagementPluginVersionResolver implements Depe
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveDependencyManagementPluginVersion(ResolvedProjectDescription description) {
|
||||
public String resolveDependencyManagementPluginVersion(ProjectDescription description) {
|
||||
return this.metadata.getConfiguration().getEnv().getGradle().getDependencyManagementPluginVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package io.spring.initializr.generator.spring.build.gradle;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.spring.initializr.generator.condition.ProjectGenerationCondition;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.generator.version.VersionParser;
|
||||
import io.spring.initializr.generator.version.VersionRange;
|
||||
@@ -43,7 +43,7 @@ public class OnGradleVersionCondition extends ProjectGenerationCondition {
|
||||
private static final VersionRange GRADLE_5_VERSION_RANGE = VersionParser.DEFAULT.parseRange("2.1.0.M1");
|
||||
|
||||
@Override
|
||||
protected boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String gradleGeneration = determineGradleGeneration(projectDescription.getPlatformVersion());
|
||||
if (gradleGeneration == null) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package io.spring.initializr.generator.spring.build.gradle;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.gradle.GradleBuild;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
||||
|
||||
/**
|
||||
@@ -34,11 +34,11 @@ public final class SpringBootPluginBuildCustomizer implements BuildCustomizer<Gr
|
||||
*/
|
||||
public static final int ORDER = -100;
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final DependencyManagementPluginVersionResolver versionResolver;
|
||||
|
||||
public SpringBootPluginBuildCustomizer(ResolvedProjectDescription projectDescription,
|
||||
public SpringBootPluginBuildCustomizer(ProjectDescription projectDescription,
|
||||
DependencyManagementPluginVersionResolver versionResolver) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.versionResolver = versionResolver;
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.spring.initializr.generator.spring.build.maven;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.BillOfMaterials;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
||||
import io.spring.initializr.metadata.InitializrConfiguration.Env.Maven;
|
||||
import io.spring.initializr.metadata.InitializrConfiguration.Env.Maven.ParentPom;
|
||||
@@ -32,11 +32,11 @@ import io.spring.initializr.metadata.support.MetadataBuildItemMapper;
|
||||
*/
|
||||
public class DefaultMavenBuildCustomizer implements BuildCustomizer<MavenBuild> {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final InitializrMetadata metadata;
|
||||
|
||||
public DefaultMavenBuildCustomizer(ResolvedProjectDescription projectDescription, InitializrMetadata metadata) {
|
||||
public DefaultMavenBuildCustomizer(ProjectDescription projectDescription, InitializrMetadata metadata) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.spring.initializr.generator.language.CompilationUnit;
|
||||
import io.spring.initializr.generator.language.SourceCode;
|
||||
import io.spring.initializr.generator.language.SourceCodeWriter;
|
||||
import io.spring.initializr.generator.language.TypeDeclaration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.contributor.ProjectContributor;
|
||||
import io.spring.initializr.generator.spring.util.LambdaSafe;
|
||||
|
||||
@@ -44,7 +44,7 @@ import org.springframework.beans.factory.ObjectProvider;
|
||||
public class MainSourceCodeProjectContributor<T extends TypeDeclaration, C extends CompilationUnit<T>, S extends SourceCode<T, C>>
|
||||
implements ProjectContributor {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final Supplier<S> sourceFactory;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class MainSourceCodeProjectContributor<T extends TypeDeclaration, C exten
|
||||
|
||||
private final ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers;
|
||||
|
||||
public MainSourceCodeProjectContributor(ResolvedProjectDescription projectDescription, Supplier<S> sourceFactory,
|
||||
public MainSourceCodeProjectContributor(ProjectDescription projectDescription, Supplier<S> sourceFactory,
|
||||
SourceCodeWriter<S> sourceWriter, ObjectProvider<MainApplicationTypeCustomizer<?>> mainTypeCustomizers,
|
||||
ObjectProvider<MainCompilationUnitCustomizer<?, ?>> mainCompilationUnitCustomizers,
|
||||
ObjectProvider<MainSourceCodeCustomizer<?, ?, ?>> mainSourceCodeCustomizers) {
|
||||
|
||||
@@ -21,8 +21,8 @@ import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion;
|
||||
import io.spring.initializr.generator.language.Annotation;
|
||||
import io.spring.initializr.generator.language.TypeDeclaration;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -66,9 +66,9 @@ public class SourceCodeProjectGenerationConfiguration {
|
||||
@ConditionalOnPackaging(WarPackaging.ID)
|
||||
static class WarPackagingConfiguration {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
WarPackagingConfiguration(ResolvedProjectDescription projectDescription) {
|
||||
WarPackagingConfiguration(ProjectDescription projectDescription) {
|
||||
this.projectDescription = projectDescription;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.spring.initializr.generator.language.CompilationUnit;
|
||||
import io.spring.initializr.generator.language.SourceCode;
|
||||
import io.spring.initializr.generator.language.SourceCodeWriter;
|
||||
import io.spring.initializr.generator.language.TypeDeclaration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.contributor.ProjectContributor;
|
||||
import io.spring.initializr.generator.spring.util.LambdaSafe;
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.springframework.beans.factory.ObjectProvider;
|
||||
public class TestSourceCodeProjectContributor<T extends TypeDeclaration, C extends CompilationUnit<T>, S extends SourceCode<T, C>>
|
||||
implements ProjectContributor {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final Supplier<S> sourceFactory;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TestSourceCodeProjectContributor<T extends TypeDeclaration, C exten
|
||||
|
||||
private final ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers;
|
||||
|
||||
public TestSourceCodeProjectContributor(ResolvedProjectDescription projectDescription, Supplier<S> sourceFactory,
|
||||
public TestSourceCodeProjectContributor(ProjectDescription projectDescription, Supplier<S> sourceFactory,
|
||||
SourceCodeWriter<S> sourceWriter,
|
||||
ObjectProvider<TestApplicationTypeCustomizer<?>> testApplicationTypeCustomizers,
|
||||
ObjectProvider<TestSourceCodeCustomizer<?, ?, ?>> testSourceCodeCustomizers) {
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.spring.initializr.generator.language.groovy.GroovyLanguage;
|
||||
import io.spring.initializr.generator.language.groovy.GroovySourceCode;
|
||||
import io.spring.initializr.generator.language.groovy.GroovySourceCodeWriter;
|
||||
import io.spring.initializr.generator.language.groovy.GroovyTypeDeclaration;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainCompilationUnitCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainSourceCodeCustomizer;
|
||||
@@ -48,11 +48,11 @@ import org.springframework.context.annotation.Import;
|
||||
@Import(GroovyProjectGenerationDefaultContributorsConfiguration.class)
|
||||
public class GroovyProjectGenerationConfiguration {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final IndentingWriterFactory indentingWriterFactory;
|
||||
|
||||
public GroovyProjectGenerationConfiguration(ResolvedProjectDescription projectDescription,
|
||||
public GroovyProjectGenerationConfiguration(ProjectDescription projectDescription,
|
||||
IndentingWriterFactory indentingWriterFactory) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.indentingWriterFactory = indentingWriterFactory;
|
||||
|
||||
@@ -32,7 +32,7 @@ import io.spring.initializr.generator.language.groovy.GroovyMethodInvocation;
|
||||
import io.spring.initializr.generator.language.groovy.GroovyReturnStatement;
|
||||
import io.spring.initializr.generator.language.groovy.GroovyTypeDeclaration;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.ServletInitializerCustomizer;
|
||||
@@ -95,7 +95,7 @@ class GroovyProjectGenerationDefaultContributorsConfiguration {
|
||||
|
||||
@Bean
|
||||
ServletInitializerCustomizer<GroovyTypeDeclaration> javaServletInitializerCustomizer(
|
||||
ResolvedProjectDescription projectDescription) {
|
||||
ProjectDescription projectDescription) {
|
||||
return (typeDeclaration) -> {
|
||||
GroovyMethodDeclaration configure = GroovyMethodDeclaration.method("configure")
|
||||
.modifiers(Modifier.PROTECTED)
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.language.java.JavaSourceCode;
|
||||
import io.spring.initializr.generator.language.java.JavaSourceCodeWriter;
|
||||
import io.spring.initializr.generator.language.java.JavaTypeDeclaration;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainCompilationUnitCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainSourceCodeCustomizer;
|
||||
@@ -48,11 +48,11 @@ import org.springframework.context.annotation.Import;
|
||||
@Import(JavaProjectGenerationDefaultContributorsConfiguration.class)
|
||||
public class JavaProjectGenerationConfiguration {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final IndentingWriterFactory indentingWriterFactory;
|
||||
|
||||
public JavaProjectGenerationConfiguration(ResolvedProjectDescription projectDescription,
|
||||
public JavaProjectGenerationConfiguration(ProjectDescription projectDescription,
|
||||
IndentingWriterFactory indentingWriterFactory) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.indentingWriterFactory = indentingWriterFactory;
|
||||
|
||||
@@ -28,7 +28,7 @@ import io.spring.initializr.generator.language.java.JavaMethodInvocation;
|
||||
import io.spring.initializr.generator.language.java.JavaReturnStatement;
|
||||
import io.spring.initializr.generator.language.java.JavaTypeDeclaration;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.ServletInitializerCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.TestApplicationTypeCustomizer;
|
||||
@@ -89,7 +89,7 @@ class JavaProjectGenerationDefaultContributorsConfiguration {
|
||||
|
||||
@Bean
|
||||
ServletInitializerCustomizer<JavaTypeDeclaration> javaServletInitializerCustomizer(
|
||||
ResolvedProjectDescription projectDescription) {
|
||||
ProjectDescription projectDescription) {
|
||||
return (typeDeclaration) -> {
|
||||
typeDeclaration.modifiers(Modifier.PUBLIC);
|
||||
JavaMethodDeclaration configure = JavaMethodDeclaration.method("configure")
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.spring.code.kotlin;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ public class InitializrMetadataKotlinVersionResolver implements KotlinVersionRes
|
||||
}
|
||||
|
||||
@Override
|
||||
public String resolveKotlinVersion(ResolvedProjectDescription description) {
|
||||
public String resolveKotlinVersion(ProjectDescription description) {
|
||||
return this.metadata.getConfiguration().getEnv().getKotlin()
|
||||
.resolveKotlinVersion(description.getPlatformVersion());
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package io.spring.initializr.generator.spring.code.kotlin;
|
||||
import io.spring.initializr.generator.buildsystem.Build;
|
||||
import io.spring.initializr.generator.buildsystem.DependencyScope;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinLanguage;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
||||
import io.spring.initializr.generator.spring.build.BuildMetadataResolver;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
@@ -37,9 +37,9 @@ public class KotlinJacksonBuildCustomizer implements BuildCustomizer<Build> {
|
||||
|
||||
private final BuildMetadataResolver buildMetadataResolver;
|
||||
|
||||
private final ResolvedProjectDescription description;
|
||||
private final ProjectDescription description;
|
||||
|
||||
public KotlinJacksonBuildCustomizer(InitializrMetadata metadata, ResolvedProjectDescription description) {
|
||||
public KotlinJacksonBuildCustomizer(InitializrMetadata metadata, ProjectDescription description) {
|
||||
this.buildMetadataResolver = new BuildMetadataResolver(metadata);
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.spring.initializr.generator.language.kotlin.KotlinLanguage;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinSourceCode;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinSourceCodeWriter;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinTypeDeclaration;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.spring.code.MainApplicationTypeCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainCompilationUnitCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainSourceCodeCustomizer;
|
||||
@@ -50,11 +50,11 @@ import org.springframework.context.annotation.Import;
|
||||
@Import(KotlinProjectGenerationDefaultContributorsConfiguration.class)
|
||||
public class KotlinProjectGenerationConfiguration {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final IndentingWriterFactory indentingWriterFactory;
|
||||
|
||||
public KotlinProjectGenerationConfiguration(ResolvedProjectDescription projectDescription,
|
||||
public KotlinProjectGenerationConfiguration(ProjectDescription projectDescription,
|
||||
IndentingWriterFactory indentingWriterFactory) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.indentingWriterFactory = indentingWriterFactory;
|
||||
|
||||
@@ -33,7 +33,7 @@ import io.spring.initializr.generator.language.kotlin.KotlinReifiedFunctionInvoc
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinReturnStatement;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinTypeDeclaration;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.MainCompilationUnitCustomizer;
|
||||
import io.spring.initializr.generator.spring.code.ServletInitializerCustomizer;
|
||||
@@ -74,7 +74,7 @@ class KotlinProjectGenerationDefaultContributorsConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
BuildCustomizer<Build> kotlinDependenciesConfigurer(ResolvedProjectDescription projectDescription) {
|
||||
BuildCustomizer<Build> kotlinDependenciesConfigurer(ProjectDescription projectDescription) {
|
||||
return new KotlinDependenciesConfigurer(projectDescription.getPlatformVersion());
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class KotlinProjectGenerationDefaultContributorsConfiguration {
|
||||
|
||||
@Bean
|
||||
MainCompilationUnitCustomizer<KotlinTypeDeclaration, KotlinCompilationUnit> boot15MainFunctionContributor(
|
||||
ResolvedProjectDescription projectDescription) {
|
||||
ProjectDescription projectDescription) {
|
||||
return (compilationUnit) -> compilationUnit.addTopLevelFunction(
|
||||
KotlinFunctionDeclaration.function("main").parameters(new Parameter("Array<String>", "args"))
|
||||
.body(new KotlinExpressionStatement(
|
||||
@@ -131,7 +131,7 @@ class KotlinProjectGenerationDefaultContributorsConfiguration {
|
||||
|
||||
@Bean
|
||||
MainCompilationUnitCustomizer<KotlinTypeDeclaration, KotlinCompilationUnit> mainFunctionContributor(
|
||||
ResolvedProjectDescription projectDescription) {
|
||||
ProjectDescription projectDescription) {
|
||||
return (compilationUnit) -> compilationUnit.addTopLevelFunction(
|
||||
KotlinFunctionDeclaration.function("main").parameters(new Parameter("Array<String>", "args"))
|
||||
.body(new KotlinExpressionStatement(
|
||||
@@ -150,7 +150,7 @@ class KotlinProjectGenerationDefaultContributorsConfiguration {
|
||||
|
||||
@Bean
|
||||
ServletInitializerCustomizer<KotlinTypeDeclaration> javaServletInitializerCustomizer(
|
||||
ResolvedProjectDescription projectDescription) {
|
||||
ProjectDescription projectDescription) {
|
||||
return (typeDeclaration) -> {
|
||||
KotlinFunctionDeclaration configure = KotlinFunctionDeclaration.function("configure")
|
||||
.modifiers(KotlinModifier.OVERRIDE)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.spring.code.kotlin;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
/**
|
||||
* Strategy for resolving a Kotlin version from a platform version.
|
||||
@@ -32,6 +32,6 @@ public interface KotlinVersionResolver {
|
||||
* @param description the description of the project being generated
|
||||
* @return the corresponding Kotlin version
|
||||
*/
|
||||
String resolveKotlinVersion(ResolvedProjectDescription description);
|
||||
String resolveKotlinVersion(ProjectDescription description);
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.spring.documentation;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.spring.scm.git.GitIgnoreCustomizer;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class HelpDocumentProjectGenerationDefaultContributorsConfiguration {
|
||||
|
||||
@Bean
|
||||
public RequestedDependenciesHelpDocumentCustomizer dependenciesHelpDocumentCustomizer(
|
||||
ResolvedProjectDescription description, InitializrMetadata metadata) {
|
||||
ProjectDescription description, InitializrMetadata metadata) {
|
||||
return new RequestedDependenciesHelpDocumentCustomizer(description, metadata);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.spring.initializr.generator.io.text.BulletedSection;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.Link;
|
||||
@@ -38,11 +38,11 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
public class RequestedDependenciesHelpDocumentCustomizer implements HelpDocumentCustomizer {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final InitializrMetadata metadata;
|
||||
|
||||
public RequestedDependenciesHelpDocumentCustomizer(ResolvedProjectDescription projectDescription,
|
||||
public RequestedDependenciesHelpDocumentCustomizer(ProjectDescription projectDescription,
|
||||
InitializrMetadata metadata) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.metadata = metadata;
|
||||
|
||||
@@ -24,9 +24,9 @@ import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
import io.spring.initializr.generator.io.IndentingWriterFactory;
|
||||
import io.spring.initializr.generator.io.SimpleIndentStrategy;
|
||||
import io.spring.initializr.generator.language.Language;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.test.project.ProjectGeneratorTester;
|
||||
import io.spring.initializr.generator.test.project.ProjectStructure;
|
||||
@@ -60,21 +60,22 @@ public abstract class AbstractComplianceTests {
|
||||
}
|
||||
|
||||
protected ProjectStructure generateProject(Language language, BuildSystem buildSystem, String version,
|
||||
Consumer<ProjectDescription> descriptionCustomizer) {
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer) {
|
||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("web", WEB)
|
||||
.build();
|
||||
return generateProject(language, buildSystem, version, descriptionCustomizer, metadata);
|
||||
}
|
||||
|
||||
protected ProjectStructure generateProject(Language language, BuildSystem buildSystem, String version,
|
||||
Consumer<ProjectDescription> descriptionCustomizer, Consumer<ProjectGenerationContext> contextCustomizer) {
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer,
|
||||
Consumer<ProjectGenerationContext> contextCustomizer) {
|
||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().addDependencyGroup("web", WEB)
|
||||
.build();
|
||||
return generateProject(language, buildSystem, version, descriptionCustomizer, metadata, contextCustomizer);
|
||||
}
|
||||
|
||||
protected ProjectStructure generateProject(Language language, BuildSystem buildSystem, String version,
|
||||
Consumer<ProjectDescription> descriptionCustomizer, InitializrMetadata metadata) {
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer, InitializrMetadata metadata) {
|
||||
return generateProject(language, buildSystem, version, descriptionCustomizer, metadata,
|
||||
(projectGenerationContext) -> {
|
||||
});
|
||||
@@ -82,7 +83,7 @@ public abstract class AbstractComplianceTests {
|
||||
}
|
||||
|
||||
private ProjectStructure generateProject(Language language, BuildSystem buildSystem, String version,
|
||||
Consumer<ProjectDescription> descriptionCustomizer, InitializrMetadata metadata,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer, InitializrMetadata metadata,
|
||||
Consumer<ProjectGenerationContext> contextCustomizer) {
|
||||
ProjectGeneratorTester projectTester = new ProjectGeneratorTester().withDirectory(this.tempDir)
|
||||
.withDescriptionCustomizer(
|
||||
@@ -90,19 +91,19 @@ public abstract class AbstractComplianceTests {
|
||||
.withDescriptionCustomizer(descriptionCustomizer)
|
||||
.withContextInitializer((context) -> setupProjectGenerationContext(metadata, context))
|
||||
.withContextInitializer(contextCustomizer);
|
||||
return projectTester.generate(new ProjectDescription());
|
||||
return projectTester.generate(new MutableProjectDescription());
|
||||
}
|
||||
|
||||
private void setupProjectGenerationContext(InitializrMetadata metadata, ProjectGenerationContext context) {
|
||||
context.registerBean(InitializrMetadata.class, () -> metadata);
|
||||
context.registerBean(BuildItemResolver.class, () -> new MetadataBuildItemResolver(metadata,
|
||||
context.getBean(ResolvedProjectDescription.class).getPlatformVersion()));
|
||||
context.getBean(ProjectDescription.class).getPlatformVersion()));
|
||||
context.registerBean(IndentingWriterFactory.class,
|
||||
() -> IndentingWriterFactory.create(new SimpleIndentStrategy("\t")));
|
||||
}
|
||||
|
||||
private void setupProjectDescription(Language language, String version, BuildSystem buildSystem,
|
||||
ProjectDescription description) {
|
||||
MutableProjectDescription description) {
|
||||
description.setLanguage(language);
|
||||
description.setBuildSystem(buildSystem);
|
||||
description.setPlatformVersion(Version.parse(version));
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.nio.file.Path;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.project.ProjectGenerator;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
@@ -52,7 +52,7 @@ class ProjectGeneratorIntegrationTests {
|
||||
|
||||
@Test
|
||||
void customBaseDirectoryIsUsedWhenGeneratingProject() {
|
||||
ProjectDescription description = initProjectDescription();
|
||||
MutableProjectDescription description = initProjectDescription();
|
||||
description.setBuildSystem(new MavenBuildSystem());
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
@@ -68,8 +68,8 @@ class ProjectGeneratorIntegrationTests {
|
||||
"test/demo-app/src/test/java/com/example/demo/DemoApplicationTests.java");
|
||||
}
|
||||
|
||||
private ProjectDescription initProjectDescription() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
private MutableProjectDescription initProjectDescription() {
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setApplicationName("DemoApplication");
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.spring.initializr.generator.spring.build;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.Build;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.metadata.BillOfMaterials;
|
||||
@@ -74,9 +74,9 @@ class DependencyManagementBuildCustomizerTests {
|
||||
}
|
||||
|
||||
private void customizeBuild(Build build, InitializrMetadata metadata) {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.0.0.RELEASE"));
|
||||
new DependencyManagementBuildCustomizer(projectDescription.resolve(), metadata).customize(build);
|
||||
new DependencyManagementBuildCustomizer(projectDescription, metadata).customize(build);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ import io.spring.initializr.generator.buildsystem.Dependency;
|
||||
import io.spring.initializr.generator.buildsystem.DependencyScope;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -37,7 +36,7 @@ class SimpleBuildCustomizerTests {
|
||||
|
||||
@Test
|
||||
void customizeProjectCoordinates() {
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
description.setGroupId("com.example.acme");
|
||||
description.setArtifactId("my-test-project");
|
||||
MavenBuild build = customizeBuild(description);
|
||||
@@ -47,7 +46,7 @@ class SimpleBuildCustomizerTests {
|
||||
|
||||
@Test
|
||||
void customizeVersion() {
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
description.setVersion("1.5.6.RELEASE");
|
||||
MavenBuild build = customizeBuild(description);
|
||||
assertThat(build.getVersion()).isEqualTo("1.5.6.RELEASE");
|
||||
@@ -55,7 +54,7 @@ class SimpleBuildCustomizerTests {
|
||||
|
||||
@Test
|
||||
void customizeWithNoDependency() {
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
MavenBuild build = customizeBuild(description);
|
||||
assertThat(build.dependencies().ids()).isEmpty();
|
||||
assertThat(build.dependencies().items()).isEmpty();
|
||||
@@ -63,7 +62,7 @@ class SimpleBuildCustomizerTests {
|
||||
|
||||
@Test
|
||||
void customizeDependencies() {
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
Dependency one = Dependency.withCoordinates("com.example", "one").scope(DependencyScope.COMPILE).build();
|
||||
Dependency two = Dependency.withCoordinates("com.example.acme", "two").scope(DependencyScope.COMPILE).build();
|
||||
description.addDependency("two", two);
|
||||
@@ -73,17 +72,16 @@ class SimpleBuildCustomizerTests {
|
||||
assertThat(build.dependencies().items()).containsExactly(two, one);
|
||||
}
|
||||
|
||||
private ProjectDescription initializeDescription() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
private MutableProjectDescription initializeDescription() {
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.0.0"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
return description;
|
||||
}
|
||||
|
||||
private MavenBuild customizeBuild(ProjectDescription description) {
|
||||
private MavenBuild customizeBuild(MutableProjectDescription description) {
|
||||
MavenBuild build = new MavenBuild();
|
||||
ResolvedProjectDescription resolvedProjectDescription = new ResolvedProjectDescription(description);
|
||||
SimpleBuildCustomizer customizer = new SimpleBuildCustomizer(resolvedProjectDescription);
|
||||
SimpleBuildCustomizer customizer = new SimpleBuildCustomizer(description);
|
||||
customizer.customize(build);
|
||||
return build;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.spring.initializr.generator.spring.build.gradle;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -40,7 +40,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSpringBoot15() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("1.5.18.RELEASE"));
|
||||
String bean = outcomeFor(projectDescription);
|
||||
assertThat(bean).isEqualTo("testGradle3");
|
||||
@@ -48,7 +48,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSpringBoot20() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.0.9.RELEASE"));
|
||||
String bean = outcomeFor(projectDescription);
|
||||
assertThat(bean).isEqualTo("testGradle4");
|
||||
@@ -56,7 +56,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSpringBoot21() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.1.3.RELEASE"));
|
||||
String bean = outcomeFor(projectDescription);
|
||||
assertThat(bean).isEqualTo("testGradle5");
|
||||
@@ -64,7 +64,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithNoMatch() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("1.0.0.RELEASE"));
|
||||
this.projectTester.generate(projectDescription, (projectGenerationContext) -> {
|
||||
assertThat(projectGenerationContext.getBeansOfType(String.class)).isEmpty();
|
||||
@@ -74,7 +74,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithNoAvailableSpringBootVersion() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
this.projectTester.generate(projectDescription, (projectGenerationContext) -> {
|
||||
assertThat(projectGenerationContext.getBeansOfType(String.class)).isEmpty();
|
||||
return null;
|
||||
@@ -83,7 +83,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSpringBoot15AndMultipleGenerations() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("1.5.18.RELEASE"));
|
||||
Map<String, String> candidates = candidatesFor(projectDescription, Gradle3Or4TestConfiguration.class);
|
||||
assertThat(candidates).containsOnlyKeys("gradle3", "gradle3AndLater");
|
||||
@@ -91,7 +91,7 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSpringBoot20AndMultipleGenerations() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.0.9.RELEASE"));
|
||||
Map<String, String> candidates = candidatesFor(projectDescription, Gradle3Or4TestConfiguration.class);
|
||||
assertThat(candidates).containsOnlyKeys("gradle4", "gradle3AndLater");
|
||||
@@ -99,20 +99,21 @@ public class ConditionalOnGradleVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSpringBoot21AndMultipleNonMatchingGenerations() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.1.3.RELEASE"));
|
||||
Map<String, String> candidates = candidatesFor(projectDescription, Gradle3Or4TestConfiguration.class);
|
||||
assertThat(candidates).containsOnlyKeys("gradle5");
|
||||
}
|
||||
|
||||
private String outcomeFor(ProjectDescription projectDescription) {
|
||||
private String outcomeFor(MutableProjectDescription projectDescription) {
|
||||
return this.projectTester.generate(projectDescription, (projectGenerationContext) -> {
|
||||
assertThat(projectGenerationContext.getBeansOfType(String.class)).hasSize(1);
|
||||
return projectGenerationContext.getBean(String.class);
|
||||
});
|
||||
}
|
||||
|
||||
private Map<String, String> candidatesFor(ProjectDescription projectDescription, Class<?>... extraConfigurations) {
|
||||
private Map<String, String> candidatesFor(MutableProjectDescription projectDescription,
|
||||
Class<?>... extraConfigurations) {
|
||||
return this.projectTester.withConfiguration(extraConfigurations).generate(projectDescription,
|
||||
(context) -> context.getBeansOfType(String.class));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import io.spring.initializr.generator.buildsystem.gradle.GradleBuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.gradle.KotlinDslGradleBuildWriter;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
@@ -73,7 +73,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
@ParameterizedTest(name = "Spring Boot {0}")
|
||||
@MethodSource("supportedPlatformVersions")
|
||||
void buildWriterIsContributed(String platformVersion) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse(platformVersion));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
BuildWriter buildWriter = this.projectTester.generate(description,
|
||||
@@ -91,7 +91,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
@MethodSource("gradleWrapperParameters")
|
||||
void gradleWrapperIsContributedWhenGeneratingGradleKtsProject(String platformVersion,
|
||||
String expectedGradleVersion) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse(platformVersion));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -103,7 +103,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void buildDotGradleDotKtsIsContributedWhenGeneratingGradleKtsProject() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage("11"));
|
||||
description.addDependency("acme",
|
||||
@@ -121,7 +121,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void dependencyManagementPluginFallbacksToMetadataIfNotPresent() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage("11"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -131,7 +131,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void dependencyManagementPluginVersionResolverIsUsedIfPresent() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage("11"));
|
||||
ProjectStructure project = this.projectTester
|
||||
@@ -143,7 +143,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void warPluginIsAppliedWhenBuildingProjectThatUsesWarPackaging() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
description.setPackaging(new WarPackaging());
|
||||
@@ -153,7 +153,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void junitPlatformIsConfiguredWithCompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.4.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -163,7 +163,7 @@ class GradleKtsProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void junitPlatformIsNotConfiguredWithIncompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.4.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.spring.initializr.generator.buildsystem.gradle.GradleBuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.gradle.GroovyDslGradleBuildWriter;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
@@ -73,7 +73,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
@ParameterizedTest(name = "Spring Boot {0}")
|
||||
@MethodSource("supportedPlatformVersions")
|
||||
void buildWriterIsContributed(String platformVersion) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse(platformVersion));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
BuildWriter buildWriter = this.projectTester.generate(description,
|
||||
@@ -91,7 +91,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
@ParameterizedTest(name = "Spring Boot {0}")
|
||||
@MethodSource("gradleWrapperParameters")
|
||||
void gradleWrapperIsContributedWhenGeneratingGradleProject(String platformVersion, String expectedGradleVersion) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse(platformVersion));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -103,7 +103,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void buildDotGradleIsContributedWhenGeneratingGradleProject() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage("11"));
|
||||
description.addDependency("acme",
|
||||
@@ -121,7 +121,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void warPluginIsAppliedWhenBuildingProjectThatUsesWarPackaging() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
description.setPackaging(new WarPackaging());
|
||||
@@ -131,7 +131,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void junitPlatformIsConfiguredWithCompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.4.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -140,7 +140,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void junitPlatformIsNotConfiguredWithIncompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.4.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -151,7 +151,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
@Test
|
||||
@Deprecated
|
||||
void testStarterExcludesVintageEngineAndJUnitWithAppropriateVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.M4"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -163,7 +163,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testStarterExcludesVintageEngineWithCompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.M5"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -174,7 +174,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testStarterDoesNotExcludesVintageEngineAndJUnitWithIncompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.6.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -190,7 +190,7 @@ class GradleProjectGenerationConfigurationTests {
|
||||
@MethodSource("annotationProcessorScopeBuildParameters")
|
||||
void gradleAnnotationProcessorScopeCustomizerIsContributedIfNecessary(String platformVersion,
|
||||
boolean contributorExpected) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse(platformVersion));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
Map<String, GradleAnnotationProcessorScopeBuildCustomizer> generate = this.projectTester.generate(description,
|
||||
|
||||
@@ -20,8 +20,7 @@ import io.spring.initializr.generator.buildsystem.BomContainer;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenParent;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.generator.version.VersionProperty;
|
||||
@@ -41,7 +40,7 @@ class DefaultMavenBuildCustomizerTests {
|
||||
@Test
|
||||
void customizeSetNameAndDescription() {
|
||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().build();
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
description.setName("my-demo");
|
||||
description.setDescription("Demonstration project");
|
||||
MavenBuild build = customizeBuild(metadata, description);
|
||||
@@ -63,7 +62,7 @@ class DefaultMavenBuildCustomizerTests {
|
||||
@Test
|
||||
void customizeSetJavaVersion() {
|
||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults().build();
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
description.setLanguage(new JavaLanguage("11"));
|
||||
MavenBuild build = customizeBuild(metadata, description);
|
||||
assertThat(build.getProperties()).contains(entry("java.version", "11"));
|
||||
@@ -103,22 +102,21 @@ class DefaultMavenBuildCustomizerTests {
|
||||
assertThat(boms.items()).hasSize(0);
|
||||
}
|
||||
|
||||
private ProjectDescription initializeDescription() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
private MutableProjectDescription initializeDescription() {
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.0.0"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
return description;
|
||||
}
|
||||
|
||||
private MavenBuild customizeBuild(InitializrMetadata metadata) {
|
||||
ProjectDescription description = initializeDescription();
|
||||
MutableProjectDescription description = initializeDescription();
|
||||
return customizeBuild(metadata, description);
|
||||
}
|
||||
|
||||
private MavenBuild customizeBuild(InitializrMetadata metadata, ProjectDescription description) {
|
||||
private MavenBuild customizeBuild(InitializrMetadata metadata, MutableProjectDescription description) {
|
||||
MavenBuild build = new MavenBuild();
|
||||
ResolvedProjectDescription resolvedProjectDescription = new ResolvedProjectDescription(description);
|
||||
DefaultMavenBuildCustomizer customizer = new DefaultMavenBuildCustomizer(resolvedProjectDescription, metadata);
|
||||
DefaultMavenBuildCustomizer customizer = new DefaultMavenBuildCustomizer(description, metadata);
|
||||
customizer.customize(build);
|
||||
return build;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.spring.initializr.generator.buildsystem.BuildWriter;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
@@ -57,7 +57,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void buildWriterIsContributed() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
BuildWriter buildWriter = this.projectTester.generate(description,
|
||||
(context) -> context.getBean(BuildWriter.class));
|
||||
@@ -66,7 +66,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void mavenWrapperIsContributedWhenGeneratingMavenProject() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).filePaths().contains("mvnw", "mvnw.cmd", ".mvn/wrapper/MavenWrapperDownloader.java",
|
||||
@@ -75,7 +75,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void mavenPomIsContributedWhenGeneratingMavenProject() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).filePaths().contains("pom.xml");
|
||||
@@ -83,7 +83,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void warPackagingIsUsedWhenBuildingProjectThatUsesWarPackaging() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
description.setPackaging(new WarPackaging());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -93,7 +93,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
@Test
|
||||
@Deprecated
|
||||
void testStarterExcludesVintageEngineAndJUnitWithAppropriateVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.M4"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -107,7 +107,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testStarterExcludesVintageEngineWithCompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.M5"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -119,7 +119,7 @@ class MavenProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testStarterDoesNotExcludesVintageEngineAndJUnitWithIncompatibleVersion() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.6.RELEASE"));
|
||||
description.setLanguage(new JavaLanguage());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
|
||||
@@ -19,7 +19,7 @@ import io.spring.initializr.generator.language.CompilationUnit;
|
||||
import io.spring.initializr.generator.language.SourceCode;
|
||||
import io.spring.initializr.generator.language.TypeDeclaration;
|
||||
import io.spring.initializr.generator.packaging.Packaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -43,7 +43,7 @@ class SourceCodeProjectGenerationConfigurationTests {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void addsACustomizerThatAppliesSpringBootApplicationAnnotationOnMainClass() {
|
||||
TypeDeclaration declaration = this.projectTester.generate(new ProjectDescription(), (context) -> {
|
||||
TypeDeclaration declaration = this.projectTester.generate(new MutableProjectDescription(), (context) -> {
|
||||
TypeDeclaration type = new TypeDeclaration("Test");
|
||||
MainApplicationTypeCustomizer<TypeDeclaration> bean = context.getBean(MainApplicationTypeCustomizer.class);
|
||||
bean.customize(type);
|
||||
@@ -76,7 +76,7 @@ class SourceCodeProjectGenerationConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private TypeDeclaration generateTestTypeDeclaration(String version) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse(version));
|
||||
return this.projectTester.generate(description, (context) -> {
|
||||
TypeDeclaration type = new TypeDeclaration("Test");
|
||||
@@ -98,7 +98,7 @@ class SourceCodeProjectGenerationConfigurationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void runWarTest(String version, String className) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPackaging(Packaging.forId("war"));
|
||||
description.setPackageName("com.foo");
|
||||
description.setPlatformVersion(Version.parse(version));
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.file.Path;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.language.groovy.GroovyLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.code.SourceCodeProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
import io.spring.initializr.generator.test.project.ProjectStructure;
|
||||
@@ -57,13 +57,13 @@ class GroovyProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void mainClassIsContributed() {
|
||||
ProjectStructure project = this.projectTester.generate(new ProjectDescription());
|
||||
ProjectStructure project = this.projectTester.generate(new MutableProjectDescription());
|
||||
assertThat(project).containsFiles("src/main/groovy/com/example/demo/DemoApplication.groovy");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassIsContributedWithJUnit4() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.4.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("src/test/groovy/com/example/demo/DemoApplicationTests.groovy").containsExactly(
|
||||
@@ -76,7 +76,7 @@ class GroovyProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testClassIsContributedWithJUnit5() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("src/test/groovy/com/example/demo/DemoApplicationTests.groovy").containsExactly(
|
||||
@@ -87,7 +87,7 @@ class GroovyProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void servletInitializerIsContributedWhenGeneratingProjectThatUsesWarPackaging() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPackaging(new WarPackaging());
|
||||
description.setApplicationName("Demo2Application");
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.nio.file.Path;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.code.SourceCodeProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
import io.spring.initializr.generator.test.project.ProjectStructure;
|
||||
@@ -57,14 +57,14 @@ class JavaProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void mainClassIsContributed() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).containsFiles("src/main/java/com/example/demo/DemoApplication.java");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassIsContributedWithJUnit4() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.4.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("src/test/java/com/example/demo/DemoApplicationTests.java").containsExactly(
|
||||
@@ -77,7 +77,7 @@ class JavaProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testClassIsContributedWithJUnit5() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("src/test/java/com/example/demo/DemoApplicationTests.java").containsExactly(
|
||||
@@ -88,7 +88,7 @@ class JavaProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void servletInitializerIsContributedWhenGeneratingProjectThatUsesWarPackaging() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPackaging(new WarPackaging());
|
||||
description.setApplicationName("MyDemoApplication");
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -102,7 +102,7 @@ class JavaProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void customPackageNameIsUsedWhenGeneratingProject() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPackageName("com.example.foo");
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).containsFiles("src/main/java/com/example/foo/DemoApplication.java",
|
||||
@@ -111,7 +111,7 @@ class JavaProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void customApplicationNameIsUsedWhenGeneratingProject() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setApplicationName("MyApplication");
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).containsFiles("src/main/java/com/example/demo/MyApplication.java",
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collections;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuild;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinLanguage;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
@@ -44,7 +44,7 @@ class KotlinJacksonBuildCustomizerTests {
|
||||
void customizeWhenJsonFacetPresentShouldAddJacksonKotlinModule() {
|
||||
Dependency dependency = Dependency.withId("foo");
|
||||
dependency.setFacets(Collections.singletonList("json"));
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setLanguage(new KotlinLanguage());
|
||||
MavenBuild build = getCustomizedBuild(dependency, description);
|
||||
io.spring.initializr.generator.buildsystem.Dependency jacksonKotlin = build.dependencies()
|
||||
@@ -57,7 +57,7 @@ class KotlinJacksonBuildCustomizerTests {
|
||||
void jacksonModuleKotlinIsNotAddedWithoutKotlin() {
|
||||
Dependency dependency = Dependency.withId("foo");
|
||||
dependency.setFacets(Collections.singletonList("json"));
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setLanguage(new JavaLanguage());
|
||||
MavenBuild build = getCustomizedBuild(dependency, description);
|
||||
io.spring.initializr.generator.buildsystem.Dependency jacksonKotlin = build.dependencies()
|
||||
@@ -68,7 +68,7 @@ class KotlinJacksonBuildCustomizerTests {
|
||||
@Test
|
||||
void jacksonModuleKotlinIsNotAddedWithoutJsonFacet() {
|
||||
Dependency dependency = Dependency.withId("foo");
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setLanguage(new KotlinLanguage());
|
||||
MavenBuild build = getCustomizedBuild(dependency, description);
|
||||
io.spring.initializr.generator.buildsystem.Dependency jacksonKotlin = build.dependencies()
|
||||
@@ -76,10 +76,10 @@ class KotlinJacksonBuildCustomizerTests {
|
||||
assertThat(jacksonKotlin).isNull();
|
||||
}
|
||||
|
||||
private MavenBuild getCustomizedBuild(Dependency dependency, ProjectDescription description) {
|
||||
private MavenBuild getCustomizedBuild(Dependency dependency, MutableProjectDescription description) {
|
||||
InitializrMetadata metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||
.addDependencyGroup("test", dependency).build();
|
||||
KotlinJacksonBuildCustomizer customizer = new KotlinJacksonBuildCustomizer(metadata, description.resolve());
|
||||
KotlinJacksonBuildCustomizer customizer = new KotlinJacksonBuildCustomizer(metadata, description);
|
||||
MavenBuild build = new MavenBuild(new MetadataBuildItemResolver(metadata, Version.parse("2.0.0.RELEASE")));
|
||||
build.dependencies().add("foo");
|
||||
customizer.customize(build);
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.spring.initializr.generator.buildsystem.Dependency;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinLanguage;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.build.BuildProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.spring.build.maven.MavenProjectGenerationConfiguration;
|
||||
import io.spring.initializr.generator.spring.code.SourceCodeProjectGenerationConfiguration;
|
||||
@@ -69,7 +69,7 @@ class KotlinProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void kotlinVersionFallbacksToMetadataIfNotPresent() {
|
||||
KotlinProjectSettings settings = this.projectTester.generate(new ProjectDescription(),
|
||||
KotlinProjectSettings settings = this.projectTester.generate(new MutableProjectDescription(),
|
||||
(context) -> context.getBean(KotlinProjectSettings.class));
|
||||
assertThat(settings.getVersion()).isEqualTo("1.1.1");
|
||||
}
|
||||
@@ -78,19 +78,19 @@ class KotlinProjectGenerationConfigurationTests {
|
||||
void kotlinVersionResolverIsUsedIfPresent() {
|
||||
KotlinProjectSettings settings = this.projectTester
|
||||
.withBean(KotlinProjectSettings.class, () -> new SimpleKotlinProjectSettings("0.9.12"))
|
||||
.generate(new ProjectDescription(), (context) -> context.getBean(KotlinProjectSettings.class));
|
||||
.generate(new MutableProjectDescription(), (context) -> context.getBean(KotlinProjectSettings.class));
|
||||
assertThat(settings.getVersion()).isEqualTo("0.9.12");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mainClassIsContributedWhenGeneratingProject() {
|
||||
ProjectStructure project = this.projectTester.generate(new ProjectDescription());
|
||||
ProjectStructure project = this.projectTester.generate(new MutableProjectDescription());
|
||||
assertThat(project).containsFiles("src/main/kotlin/com/example/demo/DemoApplication.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassIsContributedWithJunit4() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.1.4.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("src/test/kotlin/com/example/demo/DemoApplicationTests.kt").containsExactly(
|
||||
@@ -103,7 +103,7 @@ class KotlinProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void testClassIsContributedWithJunit5() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPlatformVersion(Version.parse("2.2.0.RELEASE"));
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("src/test/kotlin/com/example/demo/DemoApplicationTests.kt").containsExactly(
|
||||
@@ -114,7 +114,7 @@ class KotlinProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void servletInitializerIsContributedWhenGeneratingProjectThatUsesWarPackaging() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setPackaging(new WarPackaging());
|
||||
description.setApplicationName("KotlinDemoApplication");
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
@@ -128,7 +128,7 @@ class KotlinProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void jacksonKotlinModuleShouldBeAddedWhenJsonFacetPresent() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.addDependency("foo", Dependency.withCoordinates("com.example", "foo").build());
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).textFile("pom.xml").contains(" <dependency>",
|
||||
|
||||
@@ -19,7 +19,7 @@ package io.spring.initializr.generator.spring.documentation;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import io.spring.initializr.generator.io.template.MustacheTemplateRenderer;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.spring.scm.git.GitIgnoreCustomizer;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
@@ -54,7 +54,7 @@ class HelpDocumentProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void helpDocumentIsNotContributedWithoutLinks() {
|
||||
ProjectStructure project = this.projectTester.generate(new ProjectDescription());
|
||||
ProjectStructure project = this.projectTester.generate(new MutableProjectDescription());
|
||||
assertThat(project).filePaths().isEmpty();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class HelpDocumentProjectGenerationConfigurationTests {
|
||||
dependency.getLinks().add(Link.create("guide", "https://example.com/how-to", "How-to example"));
|
||||
dependency.getLinks().add(Link.create("reference", "https://example.com/doc", "Reference doc example"));
|
||||
this.metadataBuilder.addDependencyGroup("test", dependency);
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.addDependency("example", null);
|
||||
ProjectStructure project = this.projectTester.generate(description);
|
||||
assertThat(project).filePaths().containsOnly("HELP.md");
|
||||
@@ -72,7 +72,7 @@ class HelpDocumentProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void helpDocumentIsAddedToGitIgnore() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
GitIgnoreCustomizer gitIgnoreCustomizer = this.projectTester.generate(description,
|
||||
(context) -> context.getBean(GitIgnoreCustomizer.class));
|
||||
assertThat(gitIgnoreCustomizer).isInstanceOf(HelpDocumentGitIgnoreCustomizer.class);
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.util.Arrays;
|
||||
|
||||
import io.spring.initializr.generator.io.template.MustacheTemplateRenderer;
|
||||
import io.spring.initializr.generator.io.text.BulletedSection;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.InitializrMetadataTestBuilder;
|
||||
import io.spring.initializr.metadata.Dependency;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
@@ -135,14 +134,13 @@ class RequestedDependenciesHelpDocumentCustomizerTests {
|
||||
}
|
||||
|
||||
private HelpDocument customizeHelp(String... requestedDependencies) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
for (String requestedDependency : requestedDependencies) {
|
||||
description.addDependency(requestedDependency, null);
|
||||
}
|
||||
InitializrMetadata metadata = this.metadataBuilder.build();
|
||||
HelpDocument document = new HelpDocument(new MustacheTemplateRenderer("classpath:/templates"));
|
||||
new RequestedDependenciesHelpDocumentCustomizer(new ResolvedProjectDescription(description), metadata)
|
||||
.customize(document);
|
||||
new RequestedDependenciesHelpDocumentCustomizer(description, metadata).customize(document);
|
||||
return document;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.List;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.gradle.GradleBuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.test.io.TextTestUtils;
|
||||
import io.spring.initializr.generator.test.project.ProjectAssetTester;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
@@ -44,7 +44,7 @@ class GitProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void gitIgnoreIsContributedToProject(@TempDir Path directory) {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBuildSystem(new GradleBuildSystem());
|
||||
Path projectDirectory = this.projectTester.withDirectory(directory).generate(description, (context) -> {
|
||||
GitIgnoreContributor contributor = context.getBean(GitIgnoreContributor.class);
|
||||
@@ -56,7 +56,7 @@ class GitProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void gitIgnore() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBuildSystem(new GradleBuildSystem());
|
||||
assertThat(generateGitIgnore(description)).contains("### STS ###", "### IntelliJ IDEA ###", "### NetBeans ###",
|
||||
"### VS Code ###");
|
||||
@@ -64,7 +64,7 @@ class GitProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void gitIgnoreGradle() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBuildSystem(new GradleBuildSystem());
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
assertThat(generateGitIgnore(description)).contains(".gradle", "build/", "!gradle/wrapper/gradle-wrapper.jar",
|
||||
@@ -74,7 +74,7 @@ class GitProjectGenerationConfigurationTests {
|
||||
|
||||
@Test
|
||||
void gitIgnoreMaven() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBuildSystem(new MavenBuildSystem());
|
||||
description.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
assertThat(generateGitIgnore(description))
|
||||
@@ -82,7 +82,7 @@ class GitProjectGenerationConfigurationTests {
|
||||
.doesNotContain(".gradle", "!gradle/wrapper/gradle-wrapper.jar", "/out/");
|
||||
}
|
||||
|
||||
private List<String> generateGitIgnore(ProjectDescription description) {
|
||||
private List<String> generateGitIgnore(MutableProjectDescription description) {
|
||||
return this.projectTester.generate(description, (context) -> {
|
||||
GitIgnore gitIgnore = context.getBean(GitIgnore.class);
|
||||
StringWriter out = new StringWriter();
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.function.Supplier;
|
||||
|
||||
import io.spring.initializr.generator.io.IndentingWriterFactory;
|
||||
import io.spring.initializr.generator.io.SimpleIndentStrategy;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDirectoryFactory;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationException;
|
||||
@@ -43,21 +43,23 @@ public abstract class AbstractProjectGenerationTester<SELF extends AbstractProje
|
||||
|
||||
private final Consumer<ProjectGenerationContext> contextInitializer;
|
||||
|
||||
private final Consumer<ProjectDescription> descriptionCustomizer;
|
||||
private final Consumer<MutableProjectDescription> descriptionCustomizer;
|
||||
|
||||
protected AbstractProjectGenerationTester(Map<Class<?>, Supplier<?>> beanDefinitions) {
|
||||
this(beanDefinitions, defaultContextInitializer(), defaultDescriptionCustomizer());
|
||||
}
|
||||
|
||||
protected AbstractProjectGenerationTester(Map<Class<?>, Supplier<?>> beanDefinitions,
|
||||
Consumer<ProjectGenerationContext> contextInitializer, Consumer<ProjectDescription> descriptionCustomizer) {
|
||||
Consumer<ProjectGenerationContext> contextInitializer,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer) {
|
||||
this.beanDefinitions = new LinkedHashMap<>(beanDefinitions);
|
||||
this.descriptionCustomizer = descriptionCustomizer;
|
||||
this.contextInitializer = contextInitializer;
|
||||
}
|
||||
|
||||
protected abstract SELF newInstance(Map<Class<?>, Supplier<?>> beanDefinitions,
|
||||
Consumer<ProjectGenerationContext> contextInitializer, Consumer<ProjectDescription> descriptionCustomizer);
|
||||
Consumer<ProjectGenerationContext> contextInitializer,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer);
|
||||
|
||||
public <T> SELF withBean(Class<T> beanType, Supplier<T> beanDefinition) {
|
||||
LinkedHashMap<Class<?>, Supplier<?>> beans = new LinkedHashMap<>(this.beanDefinitions);
|
||||
@@ -79,7 +81,7 @@ public abstract class AbstractProjectGenerationTester<SELF extends AbstractProje
|
||||
return newInstance(this.beanDefinitions, this.contextInitializer.andThen(context), this.descriptionCustomizer);
|
||||
}
|
||||
|
||||
public SELF withDescriptionCustomizer(Consumer<ProjectDescription> description) {
|
||||
public SELF withDescriptionCustomizer(Consumer<MutableProjectDescription> description) {
|
||||
return newInstance(this.beanDefinitions, this.contextInitializer,
|
||||
this.descriptionCustomizer.andThen(description));
|
||||
}
|
||||
@@ -89,7 +91,7 @@ public abstract class AbstractProjectGenerationTester<SELF extends AbstractProje
|
||||
};
|
||||
}
|
||||
|
||||
protected static Consumer<ProjectDescription> defaultDescriptionCustomizer() {
|
||||
protected static Consumer<MutableProjectDescription> defaultDescriptionCustomizer() {
|
||||
return (projectDescription) -> {
|
||||
if (projectDescription.getGroupId() == null) {
|
||||
projectDescription.setGroupId("com.example");
|
||||
@@ -106,7 +108,8 @@ public abstract class AbstractProjectGenerationTester<SELF extends AbstractProje
|
||||
};
|
||||
}
|
||||
|
||||
protected <T> T invokeProjectGeneration(ProjectDescription description, ProjectGenerationInvoker<T> invoker) {
|
||||
protected <T> T invokeProjectGeneration(MutableProjectDescription description,
|
||||
ProjectGenerationInvoker<T> invoker) {
|
||||
this.descriptionCustomizer.accept(description);
|
||||
try {
|
||||
return invoker.generate(beansConfigurer().andThen(this.contextInitializer));
|
||||
|
||||
@@ -24,11 +24,11 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectAssetGenerator;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDirectoryFactory;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.contributor.ProjectContributor;
|
||||
|
||||
/**
|
||||
@@ -47,13 +47,15 @@ public class ProjectAssetTester extends AbstractProjectGenerationTester<ProjectA
|
||||
}
|
||||
|
||||
private ProjectAssetTester(Map<Class<?>, Supplier<?>> beanDefinitions,
|
||||
Consumer<ProjectGenerationContext> contextInitializer, Consumer<ProjectDescription> descriptionCustomizer) {
|
||||
Consumer<ProjectGenerationContext> contextInitializer,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer) {
|
||||
super(beanDefinitions, contextInitializer, descriptionCustomizer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectAssetTester newInstance(Map<Class<?>, Supplier<?>> beanDefinitions,
|
||||
Consumer<ProjectGenerationContext> contextInitializer, Consumer<ProjectDescription> descriptionCustomizer) {
|
||||
Consumer<ProjectGenerationContext> contextInitializer,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer) {
|
||||
return new ProjectAssetTester(beanDefinitions, contextInitializer, descriptionCustomizer);
|
||||
}
|
||||
|
||||
@@ -69,11 +71,10 @@ public class ProjectAssetTester extends AbstractProjectGenerationTester<ProjectA
|
||||
* @return the project asset
|
||||
* @see #withConfiguration(Class[])
|
||||
*/
|
||||
public <T> T generate(ProjectDescription description, ProjectAssetGenerator<T> projectAssetGenerator) {
|
||||
public <T> T generate(MutableProjectDescription description, ProjectAssetGenerator<T> projectAssetGenerator) {
|
||||
return invokeProjectGeneration(description, (contextInitializer) -> {
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
ResolvedProjectDescription resolvedProjectDescription = new ResolvedProjectDescription(description);
|
||||
context.registerBean(ResolvedProjectDescription.class, () -> resolvedProjectDescription);
|
||||
context.registerBean(ProjectDescription.class, () -> description);
|
||||
contextInitializer.accept(context);
|
||||
context.refresh();
|
||||
return projectAssetGenerator.generate(context);
|
||||
@@ -88,14 +89,14 @@ public class ProjectAssetTester extends AbstractProjectGenerationTester<ProjectA
|
||||
* @return the {@link ProjectStructure} of the generated project
|
||||
* @see #withConfiguration(Class[])
|
||||
*/
|
||||
public ProjectStructure generate(ProjectDescription description) {
|
||||
public ProjectStructure generate(MutableProjectDescription description) {
|
||||
return generate(description, runAllAvailableContributors());
|
||||
}
|
||||
|
||||
private ProjectAssetGenerator<ProjectStructure> runAllAvailableContributors() {
|
||||
return (context) -> {
|
||||
Path projectDirectory = context.getBean(ProjectDirectoryFactory.class)
|
||||
.createProjectDirectory(context.getBean(ResolvedProjectDescription.class));
|
||||
.createProjectDirectory(context.getBean(ProjectDescription.class));
|
||||
List<ProjectContributor> projectContributors = context.getBeanProvider(ProjectContributor.class)
|
||||
.orderedStream().collect(Collectors.toList());
|
||||
for (ProjectContributor projectContributor : projectContributors) {
|
||||
|
||||
@@ -26,8 +26,8 @@ import io.spring.initializr.generator.io.IndentingWriterFactory;
|
||||
import io.spring.initializr.generator.io.SimpleIndentStrategy;
|
||||
import io.spring.initializr.generator.io.template.MustacheTemplateRenderer;
|
||||
import io.spring.initializr.generator.project.DefaultProjectAssetGenerator;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectAssetGenerator;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ProjectGenerator;
|
||||
|
||||
@@ -39,7 +39,8 @@ import io.spring.initializr.generator.project.ProjectGenerator;
|
||||
public class ProjectGeneratorTester extends AbstractProjectGenerationTester<ProjectGeneratorTester> {
|
||||
|
||||
private ProjectGeneratorTester(Map<Class<?>, Supplier<?>> beanDefinitions,
|
||||
Consumer<ProjectGenerationContext> contextInitializer, Consumer<ProjectDescription> descriptionCustomizer) {
|
||||
Consumer<ProjectGenerationContext> contextInitializer,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer) {
|
||||
super(beanDefinitions, contextInitializer, descriptionCustomizer);
|
||||
}
|
||||
|
||||
@@ -56,11 +57,12 @@ public class ProjectGeneratorTester extends AbstractProjectGenerationTester<Proj
|
||||
|
||||
@Override
|
||||
protected ProjectGeneratorTester newInstance(Map<Class<?>, Supplier<?>> beanDefinitions,
|
||||
Consumer<ProjectGenerationContext> contextInitializer, Consumer<ProjectDescription> descriptionCustomizer) {
|
||||
Consumer<ProjectGenerationContext> contextInitializer,
|
||||
Consumer<MutableProjectDescription> descriptionCustomizer) {
|
||||
return new ProjectGeneratorTester(beanDefinitions, contextInitializer, descriptionCustomizer);
|
||||
}
|
||||
|
||||
public ProjectStructure generate(ProjectDescription description) {
|
||||
public ProjectStructure generate(MutableProjectDescription description) {
|
||||
return invokeProjectGeneration(description, (contextInitializer) -> {
|
||||
Path directory = new ProjectGenerator(contextInitializer).generate(description,
|
||||
new DefaultProjectAssetGenerator());
|
||||
@@ -68,7 +70,7 @@ public class ProjectGeneratorTester extends AbstractProjectGenerationTester<Proj
|
||||
});
|
||||
}
|
||||
|
||||
public <T> T generate(ProjectDescription description, ProjectAssetGenerator<T> projectAssetGenerator) {
|
||||
public <T> T generate(MutableProjectDescription description, ProjectAssetGenerator<T> projectAssetGenerator) {
|
||||
return invokeProjectGeneration(description, (contextInitializer) -> new ProjectGenerator(contextInitializer)
|
||||
.generate(description, projectAssetGenerator));
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescriptionCustomizer;
|
||||
import io.spring.initializr.generator.project.ProjectGenerator;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.contributor.ProjectContributor;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -48,14 +48,14 @@ class ProjectGeneratorTests {
|
||||
|
||||
@Test
|
||||
void generateInvokedProcessor() {
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBuildSystem(new MavenBuildSystem());
|
||||
Version platformVersion = Version.parse("2.1.0.RELEASE");
|
||||
description.setPackageName("com.example.test");
|
||||
ResolvedProjectDescription resolvedProjectDescription = this.projectTester.generate(description,
|
||||
(projectGenerationContext) -> projectGenerationContext.getBean(ResolvedProjectDescription.class));
|
||||
assertThat(resolvedProjectDescription.getPlatformVersion()).isEqualTo(platformVersion);
|
||||
assertThat(resolvedProjectDescription.getPackageName()).isEqualTo("com.example.test");
|
||||
ProjectDescription ProjectDescription = this.projectTester.generate(description,
|
||||
(projectGenerationContext) -> projectGenerationContext.getBean(ProjectDescription.class));
|
||||
assertThat(ProjectDescription.getPlatformVersion()).isEqualTo(platformVersion);
|
||||
assertThat(ProjectDescription.getPackageName()).isEqualTo("com.example.test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,14 +69,14 @@ class ProjectGeneratorTests {
|
||||
description.setGroupId("com.acme");
|
||||
}));
|
||||
});
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setGroupId("com.example.demo");
|
||||
description.setName("Original");
|
||||
|
||||
ResolvedProjectDescription resolvedProjectDescription = tester.generate(description,
|
||||
(projectGenerationContext) -> projectGenerationContext.getBean(ResolvedProjectDescription.class));
|
||||
assertThat(resolvedProjectDescription.getGroupId()).isEqualTo("com.acme");
|
||||
assertThat(resolvedProjectDescription.getName()).isEqualTo("Test");
|
||||
ProjectDescription ProjectDescription = tester.generate(description,
|
||||
(projectGenerationContext) -> projectGenerationContext.getBean(ProjectDescription.class));
|
||||
assertThat(ProjectDescription.getGroupId()).isEqualTo("com.acme");
|
||||
assertThat(ProjectDescription.getName()).isEqualTo("Test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,7 +91,7 @@ class ProjectGeneratorTests {
|
||||
Files.createFile(subDir.resolve("Test.src"));
|
||||
});
|
||||
});
|
||||
ProjectStructure project = tester.generate(new ProjectDescription());
|
||||
ProjectStructure project = tester.generate(new MutableProjectDescription());
|
||||
assertThat(project).filePaths().containsOnly("test.text", "src/main/test/Test.src");
|
||||
}
|
||||
|
||||
@@ -99,15 +99,15 @@ class ProjectGeneratorTests {
|
||||
|
||||
private final Integer order;
|
||||
|
||||
private final Consumer<ProjectDescription> projectDescription;
|
||||
private final Consumer<MutableProjectDescription> projectDescription;
|
||||
|
||||
TestProjectDescriptionCustomizer(Integer order, Consumer<ProjectDescription> projectDescription) {
|
||||
TestProjectDescriptionCustomizer(Integer order, Consumer<MutableProjectDescription> projectDescription) {
|
||||
this.order = order;
|
||||
this.projectDescription = projectDescription;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customize(ProjectDescription description) {
|
||||
public void customize(MutableProjectDescription description) {
|
||||
this.projectDescription.accept(description);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,12 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
|
||||
/**
|
||||
* Condition that matches when a {@link ResolvedProjectDescription} defines a particular
|
||||
* Condition that matches when a {@link ProjectDescription} defines a particular
|
||||
* dependency. A generated project may ultimately define a different set of dependencies
|
||||
* according to the contributors that have been executed. To contribute to the project
|
||||
* according to the real set, prefer querying the model itself rather than using this
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package io.spring.initializr.generator.condition;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
class OnBuildSystemCondition extends ProjectGenerationCondition {
|
||||
|
||||
@Override
|
||||
protected boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
MultiValueMap<String, Object> attributes = metadata
|
||||
.getAllAnnotationAttributes(ConditionalOnBuildSystem.class.getName());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package io.spring.initializr.generator.condition;
|
||||
|
||||
import io.spring.initializr.generator.language.Language;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
class OnLanguageCondition extends ProjectGenerationCondition {
|
||||
|
||||
@Override
|
||||
protected boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
if (projectDescription.getLanguage() == null) {
|
||||
return false;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package io.spring.initializr.generator.condition;
|
||||
|
||||
import io.spring.initializr.generator.packaging.Packaging;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
class OnPackagingCondition extends ProjectGenerationCondition {
|
||||
|
||||
@Override
|
||||
protected boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
if (projectDescription.getPackaging() == null) {
|
||||
return false;
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.spring.initializr.generator.condition;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.generator.version.VersionParser;
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
class OnPlatformVersionCondition extends ProjectGenerationCondition {
|
||||
|
||||
@Override
|
||||
protected boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
Version platformVersion = projectDescription.getPlatformVersion();
|
||||
if (platformVersion == null) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.condition;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
@@ -30,7 +30,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
class OnRequestedDependencyCondition extends ProjectGenerationCondition {
|
||||
|
||||
@Override
|
||||
protected boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata) {
|
||||
String id = (String) metadata.getAnnotationAttributes(ConditionalOnRequestedDependency.class.getName())
|
||||
.get("value");
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package io.spring.initializr.generator.condition;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
@@ -31,12 +31,11 @@ public abstract class ProjectGenerationCondition implements Condition {
|
||||
|
||||
@Override
|
||||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
ResolvedProjectDescription projectDescription = context.getBeanFactory()
|
||||
.getBean(ResolvedProjectDescription.class);
|
||||
ProjectDescription projectDescription = context.getBeanFactory().getBean(ProjectDescription.class);
|
||||
return matches(projectDescription, context, metadata);
|
||||
}
|
||||
|
||||
protected abstract boolean matches(ResolvedProjectDescription projectDescription, ConditionContext context,
|
||||
protected abstract boolean matches(ProjectDescription projectDescription, ConditionContext context,
|
||||
AnnotatedTypeMetadata metadata);
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import io.spring.initializr.generator.project.contributor.ProjectContributor;
|
||||
* A default {@link ProjectAssetGenerator} implementation that generates a directory
|
||||
* structure with all available {@link ProjectContributor project contributors}. Uses a
|
||||
* {@link ProjectDirectoryFactory} to determine the root directory to use based on a
|
||||
* {@link ResolvedProjectDescription}.
|
||||
* {@link ProjectDescription}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@@ -54,9 +54,9 @@ public class DefaultProjectAssetGenerator implements ProjectAssetGenerator<Path>
|
||||
|
||||
@Override
|
||||
public Path generate(ProjectGenerationContext context) throws IOException {
|
||||
ResolvedProjectDescription resolvedProjectDescription = context.getBean(ResolvedProjectDescription.class);
|
||||
Path projectRoot = resolveProjectDirectoryFactory(context).createProjectDirectory(resolvedProjectDescription);
|
||||
Path projectDirectory = initializerProjectDirectory(projectRoot, resolvedProjectDescription);
|
||||
ProjectDescription projectDescription = context.getBean(ProjectDescription.class);
|
||||
Path projectRoot = resolveProjectDirectoryFactory(context).createProjectDirectory(projectDescription);
|
||||
Path projectDirectory = initializerProjectDirectory(projectRoot, projectDescription);
|
||||
List<ProjectContributor> contributors = context.getBeanProvider(ProjectContributor.class).orderedStream()
|
||||
.collect(Collectors.toList());
|
||||
for (ProjectContributor contributor : contributors) {
|
||||
@@ -70,13 +70,13 @@ public class DefaultProjectAssetGenerator implements ProjectAssetGenerator<Path>
|
||||
: context.getBean(ProjectDirectoryFactory.class);
|
||||
}
|
||||
|
||||
private Path initializerProjectDirectory(Path rootDir, ResolvedProjectDescription description) throws IOException {
|
||||
private Path initializerProjectDirectory(Path rootDir, ProjectDescription description) throws IOException {
|
||||
Path projectDirectory = resolveProjectDirectory(rootDir, description);
|
||||
Files.createDirectories(projectDirectory);
|
||||
return projectDirectory;
|
||||
}
|
||||
|
||||
private Path resolveProjectDirectory(Path rootDir, ResolvedProjectDescription description) {
|
||||
private Path resolveProjectDirectory(Path rootDir, ProjectDescription description) {
|
||||
if (description.getBaseDirectory() != null) {
|
||||
return rootDir.resolve(description.getBaseDirectory());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.generator.project;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.Dependency;
|
||||
import io.spring.initializr.generator.language.Language;
|
||||
import io.spring.initializr.generator.packaging.Packaging;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A mutable implementation of {@link ProjectDescription}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class MutableProjectDescription implements ProjectDescription {
|
||||
|
||||
private Version platformVersion;
|
||||
|
||||
private BuildSystem buildSystem;
|
||||
|
||||
private Packaging packaging;
|
||||
|
||||
private Language language;
|
||||
|
||||
private final Map<String, Dependency> requestedDependencies = new LinkedHashMap<>();
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private String applicationName;
|
||||
|
||||
private String packageName;
|
||||
|
||||
private String baseDirectory;
|
||||
|
||||
public Version getPlatformVersion() {
|
||||
return this.platformVersion;
|
||||
}
|
||||
|
||||
public void setPlatformVersion(Version platformVersion) {
|
||||
this.platformVersion = platformVersion;
|
||||
}
|
||||
|
||||
public BuildSystem getBuildSystem() {
|
||||
return this.buildSystem;
|
||||
}
|
||||
|
||||
public void setBuildSystem(BuildSystem buildSystem) {
|
||||
this.buildSystem = buildSystem;
|
||||
}
|
||||
|
||||
public Packaging getPackaging() {
|
||||
return this.packaging;
|
||||
}
|
||||
|
||||
public void setPackaging(Packaging packaging) {
|
||||
this.packaging = packaging;
|
||||
}
|
||||
|
||||
public Language getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public void setLanguage(Language language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public Dependency addDependency(String id, Dependency dependency) {
|
||||
return this.requestedDependencies.put(id, dependency);
|
||||
}
|
||||
|
||||
public Map<String, Dependency> getRequestedDependencies() {
|
||||
return Collections.unmodifiableMap(this.requestedDependencies);
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId() {
|
||||
return this.artifactId;
|
||||
}
|
||||
|
||||
public void setArtifactId(String artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return this.applicationName;
|
||||
}
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
if (StringUtils.hasText(this.packageName)) {
|
||||
return this.packageName;
|
||||
}
|
||||
if (StringUtils.hasText(this.groupId) && StringUtils.hasText(this.artifactId)) {
|
||||
return this.groupId + "." + this.artifactId;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getBaseDirectory() {
|
||||
return this.baseDirectory;
|
||||
}
|
||||
|
||||
public void setBaseDirectory(String baseDirectory) {
|
||||
this.baseDirectory = baseDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package io.spring.initializr.generator.project;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
@@ -30,145 +28,86 @@ import io.spring.initializr.generator.version.Version;
|
||||
* Description of a project to generate.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class ProjectDescription {
|
||||
|
||||
private Version platformVersion;
|
||||
|
||||
private BuildSystem buildSystem;
|
||||
|
||||
private Packaging packaging;
|
||||
|
||||
private Language language;
|
||||
|
||||
private final Map<String, Dependency> requestedDependencies = new LinkedHashMap<>();
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String version;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private String applicationName;
|
||||
|
||||
private String packageName;
|
||||
|
||||
private String baseDirectory;
|
||||
public interface ProjectDescription {
|
||||
|
||||
/**
|
||||
* Resolve the state of this instance to a {@link ResolvedProjectDescription}.
|
||||
* @return an immutable description.
|
||||
* Return a immutable mapping of requested {@link Dependency dependencies}.
|
||||
* @return the requested dependencies
|
||||
*/
|
||||
public ResolvedProjectDescription resolve() {
|
||||
return new ResolvedProjectDescription(this);
|
||||
}
|
||||
Map<String, Dependency> getRequestedDependencies();
|
||||
|
||||
public Version getPlatformVersion() {
|
||||
return this.platformVersion;
|
||||
}
|
||||
/**
|
||||
* Return the requested platform {@link Version}.
|
||||
* @return the requested platform version or {@code null}
|
||||
*/
|
||||
Version getPlatformVersion();
|
||||
|
||||
public void setPlatformVersion(Version platformVersion) {
|
||||
this.platformVersion = platformVersion;
|
||||
}
|
||||
/**
|
||||
* Return the {@link BuildSystem} to use.
|
||||
* @return the build system or {@code null}
|
||||
*/
|
||||
BuildSystem getBuildSystem();
|
||||
|
||||
public BuildSystem getBuildSystem() {
|
||||
return this.buildSystem;
|
||||
}
|
||||
/**
|
||||
* Return the build {@link Packaging} to use.
|
||||
* @return the build packaging or {@code null}
|
||||
*/
|
||||
Packaging getPackaging();
|
||||
|
||||
public void setBuildSystem(BuildSystem buildSystem) {
|
||||
this.buildSystem = buildSystem;
|
||||
}
|
||||
/**
|
||||
* Return the primary {@link Language} of the project.
|
||||
* @return the primary language or {@code null}
|
||||
*/
|
||||
Language getLanguage();
|
||||
|
||||
public Packaging getPackaging() {
|
||||
return this.packaging;
|
||||
}
|
||||
/**
|
||||
* Return the build {@code groupId}.
|
||||
* @return the groupId or {@code null}
|
||||
*/
|
||||
String getGroupId();
|
||||
|
||||
public void setPackaging(Packaging packaging) {
|
||||
this.packaging = packaging;
|
||||
}
|
||||
/**
|
||||
* Return the build {@code artifactId}.
|
||||
* @return the artifactId or {@code null}
|
||||
*/
|
||||
String getArtifactId();
|
||||
|
||||
public Language getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
/**
|
||||
* Return the version of the project.
|
||||
* @return the version of {@code null}
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
public void setLanguage(Language language) {
|
||||
this.language = language;
|
||||
}
|
||||
/**
|
||||
* Return a simple name for the project.
|
||||
* @return the name of the project or {@code null}
|
||||
*/
|
||||
String getName();
|
||||
|
||||
public Dependency addDependency(String id, Dependency dependency) {
|
||||
return this.requestedDependencies.put(id, dependency);
|
||||
}
|
||||
/**
|
||||
* Return a human readable description of the project.
|
||||
* @return the description of the project or {@code null}
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
public Map<String, Dependency> getRequestedDependencies() {
|
||||
return Collections.unmodifiableMap(this.requestedDependencies);
|
||||
}
|
||||
/**
|
||||
* Return the name of the application as a standard Java identifier.
|
||||
* @return the name of the application or {@code null}
|
||||
*/
|
||||
String getApplicationName();
|
||||
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
/**
|
||||
* Return the root package name of the project.
|
||||
* @return the package name or {@code null}
|
||||
*/
|
||||
String getPackageName();
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId() {
|
||||
return this.artifactId;
|
||||
}
|
||||
|
||||
public void setArtifactId(String artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return this.applicationName;
|
||||
}
|
||||
|
||||
public void setApplicationName(String applicationName) {
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
|
||||
public String getBaseDirectory() {
|
||||
return this.baseDirectory;
|
||||
}
|
||||
|
||||
public void setBaseDirectory(String baseDirectory) {
|
||||
this.baseDirectory = baseDirectory;
|
||||
}
|
||||
/**
|
||||
* Return the base directory of the project or {@code null} to use the root directory.
|
||||
* @return the base directory
|
||||
*/
|
||||
String getBaseDirectory();
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.core.Ordered;
|
||||
@FunctionalInterface
|
||||
public interface ProjectDescriptionCustomizer extends Ordered {
|
||||
|
||||
void customize(ProjectDescription description);
|
||||
void customize(MutableProjectDescription description);
|
||||
|
||||
@Override
|
||||
default int getOrder() {
|
||||
|
||||
@@ -28,12 +28,11 @@ import java.nio.file.Path;
|
||||
public interface ProjectDirectoryFactory {
|
||||
|
||||
/**
|
||||
* Create a dedicated project directory for the specified
|
||||
* {@link ResolvedProjectDescription}.
|
||||
* Create a dedicated project directory for the specified {@link ProjectDescription}.
|
||||
* @param description the description of a project to generate
|
||||
* @return a dedicated existing directory
|
||||
* @throws IOException if creating the directory failed
|
||||
*/
|
||||
Path createProjectDirectory(ResolvedProjectDescription description) throws IOException;
|
||||
Path createProjectDirectory(ProjectDescription description) throws IOException;
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ public class ProjectGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate project assets using the specified {@link ProjectAssetGenerator}.
|
||||
* Generate project assets using the specified {@link ProjectAssetGenerator}. Invokes
|
||||
* known {@link ProjectDescriptionCustomizer} if applicable prior to asset generation.
|
||||
* @param description the description of the project to generate
|
||||
* @param projectAssetGenerator the {@link ProjectAssetGenerator} to invoke
|
||||
* @param <T> the type that gathers the project assets
|
||||
@@ -57,7 +58,7 @@ public class ProjectGenerator {
|
||||
public <T> T generate(ProjectDescription description, ProjectAssetGenerator<T> projectAssetGenerator)
|
||||
throws ProjectGenerationException {
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, resolve(description, context));
|
||||
context.registerBean(ProjectDescription.class, resolve(description, context));
|
||||
context.register(CoreConfiguration.class);
|
||||
this.projectGenerationContext.accept(context);
|
||||
context.refresh();
|
||||
@@ -70,12 +71,13 @@ public class ProjectGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private Supplier<ResolvedProjectDescription> resolve(ProjectDescription description,
|
||||
ProjectGenerationContext context) {
|
||||
private Supplier<ProjectDescription> resolve(ProjectDescription description, ProjectGenerationContext context) {
|
||||
return () -> {
|
||||
context.getBeanProvider(ProjectDescriptionCustomizer.class).orderedStream()
|
||||
.forEach((customizer) -> customizer.customize(description));
|
||||
return new ResolvedProjectDescription(description);
|
||||
if (description instanceof MutableProjectDescription) {
|
||||
context.getBeanProvider(ProjectDescriptionCustomizer.class).orderedStream()
|
||||
.forEach((customizer) -> customizer.customize((MutableProjectDescription) description));
|
||||
}
|
||||
return description;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.spring.initializr.generator.project;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.Dependency;
|
||||
import io.spring.initializr.generator.language.Language;
|
||||
import io.spring.initializr.generator.packaging.Packaging;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* An immutable description of a project that is being generated.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
public final class ResolvedProjectDescription {
|
||||
|
||||
private final Map<String, Dependency> requestedDependencies;
|
||||
|
||||
private final Version platformVersion;
|
||||
|
||||
private final BuildSystem buildSystem;
|
||||
|
||||
private final Packaging packaging;
|
||||
|
||||
private final Language language;
|
||||
|
||||
private final String groupId;
|
||||
|
||||
private final String artifactId;
|
||||
|
||||
private final String version;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String description;
|
||||
|
||||
private final String applicationName;
|
||||
|
||||
private final String packageName;
|
||||
|
||||
private final String baseDirectory;
|
||||
|
||||
public ResolvedProjectDescription(ProjectDescription description) {
|
||||
this.platformVersion = description.getPlatformVersion();
|
||||
this.buildSystem = description.getBuildSystem();
|
||||
this.packaging = description.getPackaging();
|
||||
this.language = description.getLanguage();
|
||||
this.groupId = description.getGroupId();
|
||||
this.artifactId = description.getArtifactId();
|
||||
this.version = description.getVersion();
|
||||
this.name = description.getName();
|
||||
this.description = description.getDescription();
|
||||
this.applicationName = description.getApplicationName();
|
||||
this.packageName = getPackageName(description);
|
||||
this.baseDirectory = description.getBaseDirectory();
|
||||
Map<String, Dependency> requestedDependencies = new LinkedHashMap<>(description.getRequestedDependencies());
|
||||
this.requestedDependencies = Collections.unmodifiableMap(requestedDependencies);
|
||||
}
|
||||
|
||||
private String getPackageName(ProjectDescription description) {
|
||||
if (StringUtils.hasText(description.getPackageName())) {
|
||||
return description.getPackageName();
|
||||
}
|
||||
if (StringUtils.hasText(description.getGroupId()) && StringUtils.hasText(description.getArtifactId())) {
|
||||
return description.getGroupId() + "." + description.getArtifactId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Dependency> getRequestedDependencies() {
|
||||
return this.requestedDependencies;
|
||||
}
|
||||
|
||||
public Version getPlatformVersion() {
|
||||
return this.platformVersion;
|
||||
}
|
||||
|
||||
public BuildSystem getBuildSystem() {
|
||||
return this.buildSystem;
|
||||
}
|
||||
|
||||
public Packaging getPackaging() {
|
||||
return this.packaging;
|
||||
}
|
||||
|
||||
public Language getLanguage() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId() {
|
||||
return this.artifactId;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public String getApplicationName() {
|
||||
return this.applicationName;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return this.packageName;
|
||||
}
|
||||
|
||||
public String getBaseDirectory() {
|
||||
return this.baseDirectory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,9 +20,9 @@ import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.gradle.GradleBuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -39,29 +39,30 @@ class ConditionalOnBuildSystemTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithMavenBuildSystem() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setBuildSystem(new MavenBuildSystem());
|
||||
assertThat(candidatesFor(projectDescription, BuildSystemTestConfiguration.class)).containsOnlyKeys("maven");
|
||||
}
|
||||
|
||||
@Test
|
||||
void outcomeWithGradleBuildSystem() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setBuildSystem(new GradleBuildSystem());
|
||||
assertThat(candidatesFor(projectDescription, BuildSystemTestConfiguration.class)).containsOnlyKeys("gradle");
|
||||
}
|
||||
|
||||
@Test
|
||||
void conditionalOnGradleWithKotlinDialectMatchesWhenGradleBuildSystemUsesKotlinDialect() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setBuildSystem(new GradleBuildSystem("kotlin"));
|
||||
assertThat(candidatesFor(projectDescription, BuildSystemTestConfiguration.class)).containsOnlyKeys("gradle",
|
||||
"gradleKotlin");
|
||||
}
|
||||
|
||||
private Map<String, String> candidatesFor(ProjectDescription projectDescription, Class<?>... extraConfigurations) {
|
||||
private Map<String, String> candidatesFor(MutableProjectDescription projectDescription,
|
||||
Class<?>... extraConfigurations) {
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, projectDescription::resolve);
|
||||
context.registerBean(ProjectDescription.class, () -> projectDescription);
|
||||
context.register(extraConfigurations);
|
||||
context.refresh();
|
||||
return context.getBeansOfType(String.class);
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.function.Consumer;
|
||||
import io.spring.initializr.generator.language.groovy.GroovyLanguage;
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.language.kotlin.KotlinLanguage;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -40,7 +40,7 @@ class ConditionalOnLanguageTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithJavaLanguage() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setLanguage(new JavaLanguage());
|
||||
assertCondition(projectDescription, (context) -> {
|
||||
assertThat(context.getBeansOfType(String.class)).hasSize(1);
|
||||
@@ -50,7 +50,7 @@ class ConditionalOnLanguageTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithGroovyBuildSystem() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setLanguage(new GroovyLanguage());
|
||||
assertCondition(projectDescription, (context) -> {
|
||||
assertThat(context.getBeansOfType(String.class)).hasSize(1);
|
||||
@@ -60,20 +60,21 @@ class ConditionalOnLanguageTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithNoMatch() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setLanguage(new KotlinLanguage());
|
||||
assertCondition(projectDescription, (context) -> assertThat(context.getBeansOfType(String.class)).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void outcomeWithNoAvailableLanguage() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
assertCondition(projectDescription, (context) -> assertThat(context.getBeansOfType(String.class)).isEmpty());
|
||||
}
|
||||
|
||||
private void assertCondition(ProjectDescription projectDescription, Consumer<ProjectGenerationContext> context) {
|
||||
private void assertCondition(MutableProjectDescription projectDescription,
|
||||
Consumer<ProjectGenerationContext> context) {
|
||||
try (ProjectGenerationContext projectContext = new ProjectGenerationContext()) {
|
||||
projectContext.registerBean(ResolvedProjectDescription.class, projectDescription::resolve);
|
||||
projectContext.registerBean(ProjectDescription.class, () -> projectDescription);
|
||||
projectContext.register(LanguageTestConfiguration.class);
|
||||
projectContext.refresh();
|
||||
context.accept(projectContext);
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.util.function.Consumer;
|
||||
|
||||
import io.spring.initializr.generator.packaging.jar.JarPackaging;
|
||||
import io.spring.initializr.generator.packaging.war.WarPackaging;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -39,7 +39,7 @@ class ConditionalOnPackagingTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithJarPackaging() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPackaging(new JarPackaging());
|
||||
assertCondition(projectDescription, (context) -> {
|
||||
assertThat(context.getBeansOfType(String.class)).hasSize(1);
|
||||
@@ -49,7 +49,7 @@ class ConditionalOnPackagingTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithWarPackaging() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPackaging(new WarPackaging());
|
||||
assertCondition(projectDescription, (context) -> {
|
||||
assertThat(context.getBeansOfType(String.class)).hasSize(1);
|
||||
@@ -59,13 +59,14 @@ class ConditionalOnPackagingTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithNoAvailablePackaging() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
assertCondition(projectDescription, (context) -> assertThat(context.getBeansOfType(String.class)).isEmpty());
|
||||
}
|
||||
|
||||
private void assertCondition(ProjectDescription projectDescription, Consumer<ProjectGenerationContext> context) {
|
||||
private void assertCondition(MutableProjectDescription projectDescription,
|
||||
Consumer<ProjectGenerationContext> context) {
|
||||
try (ProjectGenerationContext projectContext = new ProjectGenerationContext()) {
|
||||
projectContext.registerBean(ResolvedProjectDescription.class, projectDescription::resolve);
|
||||
projectContext.registerBean(ProjectDescription.class, () -> projectDescription);
|
||||
projectContext.register(PackagingTestConfiguration.class);
|
||||
projectContext.refresh();
|
||||
context.accept(projectContext);
|
||||
|
||||
@@ -18,9 +18,9 @@ package io.spring.initializr.generator.condition;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -38,14 +38,14 @@ class ConditionalOnPlatformVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithMatchingRange() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("1.2.0.RELEASE"));
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class)).containsOnlyKeys("first");
|
||||
}
|
||||
|
||||
@Test
|
||||
void outcomeWithMatchingOpenRange() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.0.1.RELEASE"));
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class))
|
||||
.containsOnlyKeys("second");
|
||||
@@ -53,7 +53,7 @@ class ConditionalOnPlatformVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithMatchingStartOfOpenRange() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.0.0.M1"));
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class))
|
||||
.containsOnlyKeys("second");
|
||||
@@ -61,20 +61,20 @@ class ConditionalOnPlatformVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithNoMatch() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("0.1.0"));
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void outcomeWithNoAvailablePlatformVersion() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void outcomeWithSeveralRangesAndMatchingVersion() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.1.0.RELEASE"));
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class,
|
||||
OneOrTwoPlatformVersionTestConfiguration.class)).containsOnlyKeys("second", "firstOrSecond");
|
||||
@@ -82,15 +82,16 @@ class ConditionalOnPlatformVersionTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithSeveralRangesAndNonMatchingVersion() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.setPlatformVersion(Version.parse("2.0.0.M2"));
|
||||
assertThat(candidatesFor(projectDescription, PlatformVersionTestConfiguration.class,
|
||||
OneOrTwoPlatformVersionTestConfiguration.class)).containsOnlyKeys("second");
|
||||
}
|
||||
|
||||
private Map<String, String> candidatesFor(ProjectDescription projectDescription, Class<?>... extraConfigurations) {
|
||||
private Map<String, String> candidatesFor(MutableProjectDescription projectDescription,
|
||||
Class<?>... extraConfigurations) {
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, projectDescription::resolve);
|
||||
context.registerBean(ProjectDescription.class, () -> projectDescription);
|
||||
context.register(PlatformVersionTestConfiguration.class);
|
||||
context.register(extraConfigurations);
|
||||
context.refresh();
|
||||
|
||||
@@ -19,9 +19,9 @@ package io.spring.initializr.generator.condition;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import io.spring.initializr.generator.buildsystem.Dependency;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -39,7 +39,7 @@ class ConditionalOnRequestedDependencyTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithMatchingDependency() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.addDependency("web", mock(Dependency.class));
|
||||
assertCondition(projectDescription, (context) -> {
|
||||
assertThat(context.getBeansOfType(String.class)).hasSize(1);
|
||||
@@ -49,14 +49,15 @@ class ConditionalOnRequestedDependencyTests {
|
||||
|
||||
@Test
|
||||
void outcomeWithNoMatch() {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
MutableProjectDescription projectDescription = new MutableProjectDescription();
|
||||
projectDescription.addDependency("another", mock(Dependency.class));
|
||||
assertCondition(projectDescription, (context) -> assertThat(context.getBeansOfType(String.class)).isEmpty());
|
||||
}
|
||||
|
||||
private void assertCondition(ProjectDescription projectDescription, Consumer<ProjectGenerationContext> context) {
|
||||
private void assertCondition(MutableProjectDescription projectDescription,
|
||||
Consumer<ProjectGenerationContext> context) {
|
||||
try (ProjectGenerationContext projectContext = new ProjectGenerationContext()) {
|
||||
projectContext.registerBean(ResolvedProjectDescription.class, projectDescription::resolve);
|
||||
projectContext.registerBean(ProjectDescription.class, () -> projectDescription);
|
||||
projectContext.register(RequestedDependencyTestConfiguration.class);
|
||||
projectContext.refresh();
|
||||
context.accept(projectContext);
|
||||
|
||||
@@ -39,13 +39,13 @@ class DefaultProjectAssetGeneratorTests {
|
||||
|
||||
@Test
|
||||
void generationWithExplicitFactoryDoesNotLookupBean(@TempDir Path tempDir) throws IOException {
|
||||
ResolvedProjectDescription description = new ProjectDescription().resolve();
|
||||
ProjectDescription description = new MutableProjectDescription();
|
||||
ProjectDirectoryFactory factory = mock(ProjectDirectoryFactory.class);
|
||||
Path expected = tempDir.resolve("does-not-exist");
|
||||
assertThat(expected).doesNotExist();
|
||||
given(factory.createProjectDirectory(description)).willReturn(expected);
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, () -> description);
|
||||
context.registerBean(ProjectDescription.class, () -> description);
|
||||
context.refresh();
|
||||
Path rootDir = new DefaultProjectAssetGenerator(factory).generate(context);
|
||||
assertThat(rootDir).isSameAs(expected);
|
||||
@@ -56,13 +56,13 @@ class DefaultProjectAssetGeneratorTests {
|
||||
|
||||
@Test
|
||||
void generationWithoutExplicitFactoryLookupsBean(@TempDir Path tempDir) throws IOException {
|
||||
ResolvedProjectDescription description = new ProjectDescription().resolve();
|
||||
ProjectDescription description = new MutableProjectDescription();
|
||||
ProjectDirectoryFactory factory = mock(ProjectDirectoryFactory.class);
|
||||
Path expected = tempDir.resolve("does-not-exist");
|
||||
assertThat(expected).doesNotExist();
|
||||
given(factory.createProjectDirectory(description)).willReturn(expected);
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, () -> description);
|
||||
context.registerBean(ProjectDescription.class, () -> description);
|
||||
context.registerBean(ProjectDirectoryFactory.class, () -> factory);
|
||||
context.refresh();
|
||||
Path rootDir = new DefaultProjectAssetGenerator().generate(context);
|
||||
@@ -74,10 +74,10 @@ class DefaultProjectAssetGeneratorTests {
|
||||
|
||||
@Test
|
||||
void generationWithoutExplicitFactoryFailIfBeanIsNotPresent() {
|
||||
ResolvedProjectDescription description = new ProjectDescription().resolve();
|
||||
ProjectDescription description = new MutableProjectDescription();
|
||||
assertThatThrownBy(() -> {
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, () -> description);
|
||||
context.registerBean(ProjectDescription.class, () -> description);
|
||||
context.refresh();
|
||||
new DefaultProjectAssetGenerator().generate(context);
|
||||
}
|
||||
@@ -87,15 +87,14 @@ class DefaultProjectAssetGeneratorTests {
|
||||
|
||||
@Test
|
||||
void generationWithBaseDirCreatesBaseDirStructure(@TempDir Path tempDir) throws IOException {
|
||||
ProjectDescription projectDescription = new ProjectDescription();
|
||||
projectDescription.setBaseDirectory("my-project");
|
||||
ResolvedProjectDescription description = projectDescription.resolve();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setBaseDirectory("my-project");
|
||||
ProjectDirectoryFactory factory = mock(ProjectDirectoryFactory.class);
|
||||
Path expected = tempDir.resolve("does-not-exist");
|
||||
assertThat(expected).doesNotExist();
|
||||
given(factory.createProjectDirectory(description)).willReturn(expected);
|
||||
try (ProjectGenerationContext context = new ProjectGenerationContext()) {
|
||||
context.registerBean(ResolvedProjectDescription.class, () -> description);
|
||||
context.registerBean(ProjectDescription.class, () -> description);
|
||||
context.refresh();
|
||||
Path rootDir = new DefaultProjectAssetGenerator(factory).generate(context);
|
||||
assertThat(rootDir).isSameAs(expected);
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.function.Function;
|
||||
import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
import io.spring.initializr.generator.buildsystem.maven.MavenBuildSystem;
|
||||
import io.spring.initializr.generator.io.template.TemplateRenderer;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.metadata.DependencyMetadata;
|
||||
import io.spring.initializr.metadata.DependencyMetadataProvider;
|
||||
@@ -306,7 +306,7 @@ public class MainController extends AbstractInitializrController {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getWrapperScript(ResolvedProjectDescription description) {
|
||||
private static String getWrapperScript(ProjectDescription description) {
|
||||
BuildSystem buildSystem = description.getBuildSystem();
|
||||
String script = buildSystem.id().equals(MavenBuildSystem.ID) ? "mvnw" : "gradlew";
|
||||
return (description.getBaseDirectory() != null) ? description.getBaseDirectory() + "/" + script : script;
|
||||
|
||||
@@ -32,7 +32,6 @@ import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationContext;
|
||||
import io.spring.initializr.generator.project.ProjectGenerationException;
|
||||
import io.spring.initializr.generator.project.ProjectGenerator;
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.metadata.InitializrMetadata;
|
||||
import io.spring.initializr.metadata.InitializrMetadataProvider;
|
||||
import io.spring.initializr.metadata.support.MetadataBuildItemResolver;
|
||||
@@ -91,7 +90,7 @@ public class ProjectGenerationInvoker {
|
||||
return (context) -> {
|
||||
Path projectDir = new DefaultProjectAssetGenerator().generate(context);
|
||||
publishProjectGeneratedEvent(request, context);
|
||||
return new ProjectGenerationResult(context.getBean(ResolvedProjectDescription.class), projectDir);
|
||||
return new ProjectGenerationResult(context.getBean(ProjectDescription.class), projectDir);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -161,7 +160,7 @@ public class ProjectGenerationInvoker {
|
||||
}
|
||||
|
||||
private byte[] generateBuild(ProjectGenerationContext context) throws IOException {
|
||||
ResolvedProjectDescription projectDescription = context.getBean(ResolvedProjectDescription.class);
|
||||
ProjectDescription projectDescription = context.getBean(ProjectDescription.class);
|
||||
StringWriter out = new StringWriter();
|
||||
BuildWriter buildWriter = context.getBeanProvider(BuildWriter.class).getIfAvailable();
|
||||
if (buildWriter != null) {
|
||||
@@ -179,7 +178,7 @@ public class ProjectGenerationInvoker {
|
||||
context.setParent(this.parentApplicationContext);
|
||||
context.registerBean(InitializrMetadata.class, () -> metadata);
|
||||
context.registerBean(BuildItemResolver.class, () -> new MetadataBuildItemResolver(metadata,
|
||||
context.getBean(ResolvedProjectDescription.class).getPlatformVersion()));
|
||||
context.getBean(ProjectDescription.class).getPlatformVersion()));
|
||||
}
|
||||
|
||||
private void publishProjectGeneratedEvent(ProjectRequest request, ProjectGenerationContext context) {
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.spring.initializr.web.project;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
|
||||
/**
|
||||
* Result of project generation.
|
||||
@@ -27,28 +27,27 @@ import io.spring.initializr.generator.project.ResolvedProjectDescription;
|
||||
*/
|
||||
public class ProjectGenerationResult {
|
||||
|
||||
private final ResolvedProjectDescription projectDescription;
|
||||
private final ProjectDescription projectDescription;
|
||||
|
||||
private final Path rootDirectory;
|
||||
|
||||
ProjectGenerationResult(ResolvedProjectDescription projectDescription, Path rootDirectory) {
|
||||
ProjectGenerationResult(ProjectDescription projectDescription, Path rootDirectory) {
|
||||
this.projectDescription = projectDescription;
|
||||
this.rootDirectory = rootDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link ResolvedProjectDescription} that was used to generate the
|
||||
* project.
|
||||
* Return the {@link ProjectDescription} that was used to generate the project.
|
||||
* @return the project description
|
||||
*/
|
||||
public ResolvedProjectDescription getProjectDescription() {
|
||||
public ProjectDescription getProjectDescription() {
|
||||
return this.projectDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the root directory.
|
||||
* @return the root directory
|
||||
* @see ResolvedProjectDescription#getBaseDirectory()
|
||||
* @see ProjectDescription#getBaseDirectory()
|
||||
*/
|
||||
public Path getRootDirectory() {
|
||||
return this.rootDirectory;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
|
||||
import io.spring.initializr.generator.buildsystem.BuildSystem;
|
||||
import io.spring.initializr.generator.language.Language;
|
||||
import io.spring.initializr.generator.packaging.Packaging;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
import io.spring.initializr.metadata.DefaultMetadataElement;
|
||||
@@ -50,7 +51,7 @@ public class ProjectRequestToDescriptionConverter {
|
||||
String springBootVersion = getSpringBootVersion(request, metadata);
|
||||
List<Dependency> resolvedDependencies = getResolvedDependencies(request, springBootVersion, metadata);
|
||||
validateDependencyRange(springBootVersion, resolvedDependencies);
|
||||
ProjectDescription description = new ProjectDescription();
|
||||
MutableProjectDescription description = new MutableProjectDescription();
|
||||
description.setApplicationName(getApplicationName(request, metadata));
|
||||
description.setArtifactId(getArtifactId(request, metadata));
|
||||
description.setBaseDirectory(getBaseDirectory(request.getBaseDir(), request.getArtifactId()));
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package io.spring.initializr.web.project;
|
||||
|
||||
import io.spring.initializr.generator.language.java.JavaLanguage;
|
||||
import io.spring.initializr.generator.project.ProjectDescription;
|
||||
import io.spring.initializr.generator.project.MutableProjectDescription;
|
||||
import io.spring.initializr.generator.project.ProjectDescriptionCustomizer;
|
||||
import io.spring.initializr.generator.test.project.ProjectStructure;
|
||||
import io.spring.initializr.generator.version.Version;
|
||||
@@ -52,7 +52,7 @@ class ProjectGenerationDescriptionCustomizerTests extends AbstractInitializrCont
|
||||
ProjectDescriptionCustomizer secondPostProcessor() {
|
||||
return new ProjectDescriptionCustomizer() {
|
||||
@Override
|
||||
public void customize(ProjectDescription description) {
|
||||
public void customize(MutableProjectDescription description) {
|
||||
description.setLanguage(new JavaLanguage("1.7"));
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ class ProjectGenerationDescriptionCustomizerTests extends AbstractInitializrCont
|
||||
ProjectDescriptionCustomizer firstPostProcessor() {
|
||||
return new ProjectDescriptionCustomizer() {
|
||||
@Override
|
||||
public void customize(ProjectDescription description) {
|
||||
public void customize(MutableProjectDescription description) {
|
||||
description.setLanguage(new JavaLanguage("1.2"));
|
||||
description.setPlatformVersion(Version.parse("2.2.3.RELEASE"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user