Add dependency builder

This commit adds a builder for Dependency to allow it to be further
tuned without having to add an extra constructor.
This commit is contained in:
Stephane Nicoll
2019-05-22 15:44:30 +02:00
parent 7a30f771f2
commit b8cac0407b
14 changed files with 178 additions and 137 deletions

View File

@@ -45,9 +45,10 @@ public final class MetadataBuildItemMapper {
}
VersionReference versionReference = (dependency.getVersion() != null)
? VersionReference.ofValue(dependency.getVersion()) : null;
return new io.spring.initializr.generator.buildsystem.Dependency(
dependency.getGroupId(), dependency.getArtifactId(), versionReference,
toDependencyScope(dependency.getScope()), dependency.getType());
return io.spring.initializr.generator.buildsystem.Dependency
.withCoordinates(dependency.getGroupId(), dependency.getArtifactId())
.version(versionReference).scope(toDependencyScope(dependency.getScope()))
.type(dependency.getType()).build();
}
private static DependencyScope toDependencyScope(String scope) {