private Dependency determineWebDependency(InitializrMetadata metadata) { Dependency web = metadata.getDependencies().get("web"); if (web != null) { return web; } return Dependency.withId("web").asSpringBootStarter("web"); }
public boolean isForceSsl() { if (this.forceSsl == null) { this.forceSsl = this.metadataProvider.get().getConfiguration().getEnv() .isForceSsl(); } return this.forceSsl; }
/** * Create an URL suitable to download Spring Boot cli for the specified version and * extension. * @param extension the required extension * @return the download URL */ public String createCliDistributionURl(String extension) { String bootVersion = defaultId(this.bootVersions); return this.configuration.getEnv().getArtifactRepository() + "org/springframework/boot/spring-boot-cli/" + bootVersion + "/spring-boot-cli-" + bootVersion + "-bin." + extension; }
@Override public void customize(InitializrMetadata metadata) { metadata.getDependencies().merge(this.properties.getDependencies()); metadata.getTypes().merge(this.properties.getTypes()); metadata.getBootVersions().merge(this.properties.getBootVersions()); metadata.getPackagings().merge(this.properties.getPackagings()); metadata.getJavaVersions().merge(this.properties.getJavaVersions()); metadata.getLanguages().merge(this.properties.getLanguages()); this.properties.getGroupId().apply(metadata.getGroupId()); this.properties.getArtifactId().apply(metadata.getArtifactId()); this.properties.getVersion().apply(metadata.getVersion()); this.properties.getName().apply(metadata.getName()); this.properties.getDescription().apply(metadata.getDescription()); this.properties.getPackageName().apply(metadata.getPackageName()); }
public InitializrMetadataTestBuilder addPackaging(String id, boolean defaultValue) { this.builder.withCustomizer((it) -> { DefaultMetadataElement packaging = new DefaultMetadataElement(); packaging.setId(id); packaging.setName(id); packaging.setDefault(defaultValue); it.getPackagings().getContent().add(packaging); }); return this; }
public InitializrMetadataTestBuilder addJavaVersion(String version, boolean defaultValue) { this.builder.withCustomizer((it) -> { DefaultMetadataElement element = new DefaultMetadataElement(); element.setId(version); element.setName(version); element.setDefault(defaultValue); it.getJavaVersions().getContent().add(element); }); return this; }
public InitializrMetadataTestBuilder addLanguage(String id, boolean defaultValue) { this.builder.withCustomizer((it) -> { DefaultMetadataElement element = new DefaultMetadataElement(); element.setId(id); element.setName(id); element.setDefault(defaultValue); it.getLanguages().getContent().add(element); }); return this; }
public InitializrMetadataTestBuilder addDependencyGroup(String name, String... ids) { this.builder.withCustomizer((it) -> { DependencyGroup group = new DependencyGroup(); group.setName(name); for (String id : ids) { Dependency dependency = new Dependency(); dependency.setId(id); group.getContent().add(dependency); } it.getDependencies().getContent().add(group); }); return this; }
public InitializrMetadataTestBuilder setMavenParent(String groupId, String artifactId, String version, boolean includeSpringBootBom) { this.builder.withCustomizer((it) -> { ParentPom parent = it.getConfiguration().getEnv().getMaven().getParent(); parent.setGroupId(groupId); parent.setArtifactId(artifactId); parent.setVersion(version); parent.setIncludeSpringBootBom(includeSpringBootBom); }); return this; }
public InitializrMetadataTestBuilder addBootVersion(String id, boolean defaultValue) { this.builder.withCustomizer((it) -> { DefaultMetadataElement element = new DefaultMetadataElement(); element.setId(id); element.setName(id); element.setDefault(defaultValue); it.getBootVersions().getContent().add(element); }); return this; }
public InitializrMetadataTestBuilder setKotlinEnv(String defaultKotlinVersion, Kotlin.Mapping... mappings) { this.builder.withCustomizer((it) -> { it.getConfiguration().getEnv().getKotlin() .setDefaultVersion(defaultKotlinVersion); for (Kotlin.Mapping mapping : mappings) { it.getConfiguration().getEnv().getKotlin().getMappings().add(mapping); } }); return this; }
public InitializrMetadataTestBuilder addBom(String id, BillOfMaterials bom) { this.builder.withCustomizer( (it) -> it.getConfiguration().getEnv().getBoms().put(id, bom)); return this; }
public InitializrMetadataTestBuilder addDependencyGroup(String name, Dependency... dependencies) { this.builder.withCustomizer((it) -> { DependencyGroup group = new DependencyGroup(); group.setName(name); group.getContent().addAll(Arrays.asList(dependencies)); it.getDependencies().getContent().add(group); }); return this; }
public InitializrMetadataTestBuilder setGradleEnv( String dependencyManagementPluginVersion) { this.builder.withCustomizer((it) -> it.getConfiguration().getEnv().getGradle() .setDependencyManagementPluginVersion(dependencyManagementPluginVersion)); return this; }
@Test void invalidParentMissingVersion() { InitializrMetadata metadata = initializeMetadata(); ParentPom parent = metadata.getConfiguration().getEnv().getMaven().getParent(); parent.setGroupId("org.foo"); parent.setArtifactId("foo-parent"); assertThatExceptionOfType(InvalidInitializrMetadataException.class) .isThrownBy(metadata::validate).withMessageContaining( "Custom maven pom requires groupId, artifactId and version"); }
private static String defaultId( Defaultable<? extends DefaultMetadataElement> element) { DefaultMetadataElement defaultValue = element.getDefault(); return (defaultValue != null) ? defaultValue.getId() : null; }
/** * Add a {@link InitializrProperties} to be merged with other content. * @param properties the settings to merge onto this instance * @param mergeConfiguration specify if service configuration should be merged as well * @return this instance */ public InitializrMetadataBuilder withInitializrProperties( InitializrProperties properties, boolean mergeConfiguration) { if (mergeConfiguration) { this.configuration.merge(properties); } return withCustomizer(new InitializerPropertiesCustomizer(properties)); }
/** * Add a {@link InitializrMetadata} to be merged with other content. * @param resource a resource to a json document describing the metadata to include * @return this instance */ public InitializrMetadataBuilder withInitializrMetadata(Resource resource) { return withCustomizer(new ResourceInitializrMetadataCustomizer(resource)); }
/** * Create an empty builder instance with a default {@link InitializrConfiguration}. * @return a new {@link InitializrMetadataBuilder} instance */ public static InitializrMetadataBuilder create() { return new InitializrMetadataBuilder(new InitializrConfiguration()); }