mirror of
https://gitee.com/dcren/initializr.git
synced 2026-09-03 00:26:29 +08:00
Customize the parent pom to use
See gh-223
This commit is contained in:
committed by
Stephane Nicoll
parent
bd323680ea
commit
625d5bee15
@@ -309,6 +309,24 @@ class ProjectGeneratorTests extends AbstractProjectGeneratorTests {
|
||||
.hasSpringBootStarterDependency('web')
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultMavenPomHasSpringBootParent() {
|
||||
def metadata = InitializrMetadataTestBuilder.withDefaults().build()
|
||||
applyMetadata(metadata)
|
||||
def request = createProjectRequest('whatever', 'web')
|
||||
generateMavenPom(request).hasParent("org.springframework.boot", "spring-boot-starter-parent", request.bootVersion)
|
||||
}
|
||||
|
||||
@Test
|
||||
void mavenPomWithCustomParentPom() {
|
||||
def customGAV = "com.foo:foo-parent:1.0.0-SNAPSHOT"
|
||||
def metadata = InitializrMetadataTestBuilder.withDefaults()
|
||||
.addCustomParentPomGAV(customGAV).build()
|
||||
applyMetadata(metadata)
|
||||
def request = createProjectRequest('whatever', 'web')
|
||||
generateMavenPom(request).hasParent("com.foo", "foo-parent", "1.0.0-SNAPSHOT")
|
||||
}
|
||||
|
||||
@Test
|
||||
void gradleBuildWithBootSnapshot() {
|
||||
def request = createProjectRequest('web')
|
||||
|
||||
@@ -97,7 +97,12 @@ class PomAssert {
|
||||
}
|
||||
|
||||
PomAssert hasBootVersion(String bootVersion) {
|
||||
assertEquals bootVersion, eng.evaluate(createRootNodeXPath('parent/pom:version'), doc)
|
||||
// when using a custom parent, the bootVersion comes from a bom entry and not the parent pom version
|
||||
if (!eng.evaluate(createRootNodeXPath('parent/pom:artifactId'), doc).equals("spring-boot-starter-parent")) {
|
||||
hasBom("org.springframework.boot", "spring-boot-dependencies", bootVersion)
|
||||
} else {
|
||||
assertEquals bootVersion, eng.evaluate(createRootNodeXPath('parent/pom:version'), doc)
|
||||
}
|
||||
this
|
||||
}
|
||||
|
||||
@@ -136,6 +141,13 @@ class PomAssert {
|
||||
hasDependency(new Dependency(groupId: groupId, artifactId: artifactId, version: version))
|
||||
}
|
||||
|
||||
PomAssert hasParent(String groupId, String artifactId, String version) {
|
||||
assertEquals version, eng.evaluate(createRootNodeXPath('parent/pom:version'), doc)
|
||||
assertEquals groupId, eng.evaluate(createRootNodeXPath('parent/pom:groupId'), doc)
|
||||
assertEquals artifactId, eng.evaluate(createRootNodeXPath('parent/pom:artifactId'), doc)
|
||||
this
|
||||
}
|
||||
|
||||
PomAssert hasDependency(Dependency expected) {
|
||||
def id = generateDependencyId(expected.groupId, expected.artifactId)
|
||||
def dependency = dependencies[id]
|
||||
|
||||
@@ -152,6 +152,13 @@ class InitializrMetadataTestBuilder {
|
||||
this
|
||||
}
|
||||
|
||||
InitializrMetadataTestBuilder addCustomParentPomGAV(String customGAV) {
|
||||
builder.withCustomizer {
|
||||
it.configuration.env.customParentPomGAV = customGAV
|
||||
}
|
||||
this
|
||||
}
|
||||
|
||||
InitializrMetadataTestBuilder addRepository(String id, String name, String url, boolean snapshotsEnabled) {
|
||||
builder.withCustomizer {
|
||||
Repository repo = new Repository(
|
||||
|
||||
Reference in New Issue
Block a user