mirror of
https://gitee.com/dcren/initializr.git
synced 2026-06-29 02:21:54 +08:00
Model that a Maven dependency is optional
Closes gh-913
This commit is contained in:
@@ -287,6 +287,28 @@ class MavenBuildWriterTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void pomWithOptionalDependency() throws Exception {
|
||||
MavenBuild build = new MavenBuild();
|
||||
build.setGroup("com.example.demo");
|
||||
build.setArtifact("demo");
|
||||
build.dependencies().add("annotation-processor",
|
||||
MavenDependency
|
||||
.withCoordinates("org.springframework.boot",
|
||||
"spring-boot-configuration-processor")
|
||||
.scope(DependencyScope.COMPILE).optional(true));
|
||||
generatePom(build, (pom) -> {
|
||||
NodeAssert dependency = pom.nodeAtPath("/project/dependencies/dependency");
|
||||
assertThat(dependency).textAtPath("groupId")
|
||||
.isEqualTo("org.springframework.boot");
|
||||
assertThat(dependency).textAtPath("artifactId")
|
||||
.isEqualTo("spring-boot-configuration-processor");
|
||||
assertThat(dependency).textAtPath("version").isNullOrEmpty();
|
||||
assertThat(dependency).textAtPath("scope").isNullOrEmpty();
|
||||
assertThat(dependency).textAtPath("optional").isEqualTo("true");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void pomWithNonNullArtifactTypeDependency() throws Exception {
|
||||
MavenBuild build = new MavenBuild();
|
||||
|
||||
Reference in New Issue
Block a user