/** * 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)); }
/** * 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)); }
public InitializrMetadataTestBuilder addType(Type type) { this.builder.withCustomizer((it) -> it.getTypes().getContent().add(type)); 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; }
@Test void addDependencyInCustomizer() { DependencyGroup group = DependencyGroup.create("Extra"); Dependency dependency = Dependency.withId("com.foo:foo:1.0.0"); group.getContent().add(dependency); InitializrMetadata metadata = InitializrMetadataBuilder.create() .withCustomizer((m) -> m.getDependencies().getContent().add(group)) .build(); assertThat(metadata.getDependencies().getContent()).hasSize(1); assertThat(metadata.getDependencies().getContent().get(0)).isEqualTo(group); }
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 setGradleEnv( String dependencyManagementPluginVersion) { this.builder.withCustomizer((it) -> it.getConfiguration().getEnv().getGradle() .setDependencyManagementPluginVersion(dependencyManagementPluginVersion)); return this; }
public InitializrMetadataTestBuilder addRepository(String id, String name, String url, boolean snapshotsEnabled) { this.builder.withCustomizer((it) -> { Repository repo = new Repository(); repo.setName(name); try { repo.setUrl(new URL(url)); } catch (MalformedURLException ex) { throw new IllegalArgumentException("Cannot create URL", ex); } repo.setSnapshotsEnabled(snapshotsEnabled); it.getConfiguration().getEnv().getRepositories().put(id, repo); }); return this; }
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 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 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; }