/** * Define this dependency as a standard spring boot starter with the specified name. * If no name is specified, the root "spring-boot-starter" is assumed. * @param name the starter name or {@code null} * @return this instance */ public Dependency asSpringBootStarter(String name) { this.groupId = "org.springframework.boot"; this.artifactId = (StringUtils.hasText(name) ? "spring-boot-starter-" + name : "spring-boot-starter"); if (StringUtils.hasText(name)) { setId(name); } return this; }
/** * Generate an id using the groupId and artifactId. * @return the generated ID */ public String generateId() { if (this.groupId == null || this.artifactId == null) { throw new IllegalArgumentException("Could not generate id for " + this + ": at least groupId and artifactId must be set."); } setId(this.groupId + ":" + this.artifactId); return getId(); }
public static Dependency withId(String id, String groupId, String artifactId, String version, String scope) { Dependency dependency = new Dependency(); dependency.setId(id); dependency.groupId = groupId; dependency.artifactId = artifactId; dependency.version = version; dependency.scope = (scope != null) ? scope : SCOPE_COMPILE; return dependency; }
/** * Add a default dependency if the project does not define any dependency. */ protected void addDefaultDependency() { Dependency root = new Dependency(); root.setId(DEFAULT_STARTER); root.asSpringBootStarter(""); this.resolvedDependencies.add(root); }
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; }