/** * Resolve the parent pom to use. If no custom parent pom is set, the standard * spring boot parent pom with the specified {@code bootVersion} is used. * @param bootVersion the Spring Boot version * @return the parent POM */ public ParentPom resolveParentPom(String bootVersion) { return (StringUtils.hasText(this.parent.groupId) ? this.parent : new ParentPom(DEFAULT_PARENT_GROUP_ID, DEFAULT_PARENT_ARTIFACT_ID, bootVersion)); }
Maven maven = metadata.getConfiguration().getEnv().getMaven(); ParentPom parentPom = maven.resolveParentPom(request.getBootVersion()); if (parentPom.isIncludeSpringBootBom() && !request.getBoms().containsKey("spring-boot")) { request.getBoms().put("spring-boot", metadata.createSpringBootBom( .put("project.reporting.outputEncoding", () -> "UTF-8"); model.put("mavenParentGroupId", parentPom.getGroupId()); model.put("mavenParentArtifactId", parentPom.getArtifactId()); model.put("mavenParentVersion", parentPom.getVersion()); model.put("includeSpringBootBom", parentPom.isIncludeSpringBootBom()); model.put("defaultPackaging", "jar".equals(request.getPackaging()));
public void validate() { this.maven.parent.validate(); this.boms.forEach((k, v) -> v.validate()); this.kotlin.validate(); }
private ParentPom parseParent() { ParentPom parent = new ParentPom(); try { parent.setGroupId(this.eng.evaluate(createRootNodeXPath("parent/pom:groupId"), this.doc)); parent.setArtifactId(this.eng .evaluate(createRootNodeXPath("parent/pom:artifactId"), this.doc)); parent.setVersion(this.eng.evaluate(createRootNodeXPath("parent/pom:version"), this.doc)); return parent; } catch (XpathException ex) { throw new IllegalStateException("Cannot find path", ex); } }
/** * Check if the specified {@link ParentPom} is the default spring boot starter * parent. * @param parentPom the parent pom to check * @return {@code true} if the {@code parentPom} is the spring boot starter * parent */ public boolean isSpringBootStarterParent(ParentPom parentPom) { return DEFAULT_PARENT_GROUP_ID.equals(parentPom.getGroupId()) && DEFAULT_PARENT_ARTIFACT_ID.equals(parentPom.getArtifactId()); }
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; }
@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"); }
public PomAssert hasParent(String groupId, String artifactId, String version) { assertThat(this.parentPom.getGroupId()).isEqualTo(groupId); assertThat(this.parentPom.getArtifactId()).isEqualTo(artifactId); assertThat(this.parentPom.getVersion()).isEqualTo(version); return this; }