mirror of
https://gitee.com/dcren/initializr.git
synced 2025-12-19 19:47:08 +08:00
Format source code
Closes gh-923
This commit is contained in:
@@ -158,8 +158,7 @@ public class BillOfMaterials {
|
||||
|
||||
public void validate() {
|
||||
if (this.version == null && this.mappings.isEmpty()) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"No version available for " + this);
|
||||
throw new InvalidInitializrMetadataException("No version available for " + this);
|
||||
}
|
||||
updateVersionRange(VersionParser.DEFAULT);
|
||||
}
|
||||
@@ -192,44 +191,35 @@ public class BillOfMaterials {
|
||||
if (mapping.range.match(bootVersion)) {
|
||||
BillOfMaterials resolvedBom = new BillOfMaterials(
|
||||
(mapping.groupId != null) ? mapping.groupId : this.groupId,
|
||||
(mapping.artifactId != null) ? mapping.artifactId
|
||||
: this.artifactId,
|
||||
mapping.version);
|
||||
(mapping.artifactId != null) ? mapping.artifactId : this.artifactId, mapping.version);
|
||||
resolvedBom.setVersionProperty(this.versionProperty);
|
||||
resolvedBom.setOrder(this.order);
|
||||
resolvedBom.repositories.addAll(!mapping.repositories.isEmpty()
|
||||
? mapping.repositories : this.repositories);
|
||||
resolvedBom.additionalBoms.addAll(!mapping.additionalBoms.isEmpty()
|
||||
? mapping.additionalBoms : this.additionalBoms);
|
||||
resolvedBom.repositories
|
||||
.addAll(!mapping.repositories.isEmpty() ? mapping.repositories : this.repositories);
|
||||
resolvedBom.additionalBoms
|
||||
.addAll(!mapping.additionalBoms.isEmpty() ? mapping.additionalBoms : this.additionalBoms);
|
||||
return resolvedBom;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No suitable mapping was found for " + this
|
||||
+ " and version " + bootVersion);
|
||||
throw new IllegalStateException("No suitable mapping was found for " + this + " and version " + bootVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BillOfMaterials ["
|
||||
+ ((this.groupId != null) ? "groupId=" + this.groupId + ", " : "")
|
||||
+ ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", "
|
||||
: "")
|
||||
return "BillOfMaterials [" + ((this.groupId != null) ? "groupId=" + this.groupId + ", " : "")
|
||||
+ ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", " : "")
|
||||
+ ((this.version != null) ? "version=" + this.version + ", " : "")
|
||||
+ ((this.versionProperty != null)
|
||||
? "versionProperty=" + this.versionProperty + ", " : "")
|
||||
+ ((this.versionProperty != null) ? "versionProperty=" + this.versionProperty + ", " : "")
|
||||
+ ((this.order != null) ? "order=" + this.order + ", " : "")
|
||||
+ ((this.additionalBoms != null)
|
||||
? "additionalBoms=" + this.additionalBoms + ", " : "")
|
||||
+ ((this.repositories != null) ? "repositories=" + this.repositories : "")
|
||||
+ "]";
|
||||
+ ((this.additionalBoms != null) ? "additionalBoms=" + this.additionalBoms + ", " : "")
|
||||
+ ((this.repositories != null) ? "repositories=" + this.repositories : "") + "]";
|
||||
}
|
||||
|
||||
public static BillOfMaterials create(String groupId, String artifactId) {
|
||||
return new BillOfMaterials(groupId, artifactId);
|
||||
}
|
||||
|
||||
public static BillOfMaterials create(String groupId, String artifactId,
|
||||
String version) {
|
||||
public static BillOfMaterials create(String groupId, String artifactId, String version) {
|
||||
return new BillOfMaterials(groupId, artifactId, version);
|
||||
}
|
||||
|
||||
@@ -277,8 +267,7 @@ public class BillOfMaterials {
|
||||
return new Mapping(range, version);
|
||||
}
|
||||
|
||||
public static Mapping create(String range, String version,
|
||||
String... repositories) {
|
||||
public static Mapping create(String range, String version, String... repositories) {
|
||||
return new Mapping(range, version, repositories);
|
||||
}
|
||||
|
||||
@@ -340,17 +329,12 @@ public class BillOfMaterials {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Mapping ["
|
||||
+ ((this.versionRange != null)
|
||||
? "versionRange=" + this.versionRange + ", " : "")
|
||||
return "Mapping [" + ((this.versionRange != null) ? "versionRange=" + this.versionRange + ", " : "")
|
||||
+ ((this.groupId != null) ? "groupId=" + this.groupId + ", " : "")
|
||||
+ ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", "
|
||||
: "")
|
||||
+ ((this.artifactId != null) ? "artifactId=" + this.artifactId + ", " : "")
|
||||
+ ((this.version != null) ? "version=" + this.version + ", " : "")
|
||||
+ ((this.repositories != null)
|
||||
? "repositories=" + this.repositories + ", " : "")
|
||||
+ ((this.additionalBoms != null)
|
||||
? "additionalBoms=" + this.additionalBoms + ", " : "")
|
||||
+ ((this.repositories != null) ? "repositories=" + this.repositories + ", " : "")
|
||||
+ ((this.additionalBoms != null) ? "additionalBoms=" + this.additionalBoms + ", " : "")
|
||||
+ ((this.range != null) ? "range=" + this.range : "") + "]";
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ public class DefaultMetadataElement extends MetadataElement {
|
||||
return new DefaultMetadataElement(id, defaultValue);
|
||||
}
|
||||
|
||||
public static DefaultMetadataElement create(String id, String name,
|
||||
boolean defaultValue) {
|
||||
public static DefaultMetadataElement create(String id, String name, boolean defaultValue) {
|
||||
return new DefaultMetadataElement(id, name, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ public class DependenciesCapability extends ServiceCapability<List<DependencyGro
|
||||
private final Map<String, Dependency> indexedDependencies = new LinkedHashMap<>();
|
||||
|
||||
public DependenciesCapability() {
|
||||
super("dependencies", ServiceCapabilityType.HIERARCHICAL_MULTI_SELECT,
|
||||
"Project dependencies", "dependency identifiers (comma-separated)");
|
||||
super("dependencies", ServiceCapabilityType.HIERARCHICAL_MULTI_SELECT, "Project dependencies",
|
||||
"dependency identifiers (comma-separated)");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,8 +65,8 @@ public class DependenciesCapability extends ServiceCapability<List<DependencyGro
|
||||
* @return all dependencies
|
||||
*/
|
||||
public Collection<Dependency> getAll() {
|
||||
return Collections.unmodifiableCollection(this.indexedDependencies.values()
|
||||
.stream().distinct().collect(Collectors.toList()));
|
||||
return Collections.unmodifiableCollection(
|
||||
this.indexedDependencies.values().stream().distinct().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
@@ -74,15 +74,14 @@ public class DependenciesCapability extends ServiceCapability<List<DependencyGro
|
||||
}
|
||||
|
||||
public void updateVersionRange(VersionParser versionParser) {
|
||||
this.indexedDependencies.values()
|
||||
.forEach((it) -> it.updateVersionRanges(versionParser));
|
||||
this.indexedDependencies.values().forEach((it) -> it.updateVersionRanges(versionParser));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void merge(List<DependencyGroup> otherContent) {
|
||||
otherContent.forEach((group) -> {
|
||||
if (this.content.stream().noneMatch((it) -> group.getName() != null
|
||||
&& group.getName().equals(it.getName()))) {
|
||||
if (this.content.stream()
|
||||
.noneMatch((it) -> group.getName() != null && group.getName().equals(it.getName()))) {
|
||||
this.content.add(group);
|
||||
}
|
||||
});
|
||||
@@ -114,9 +113,8 @@ public class DependenciesCapability extends ServiceCapability<List<DependencyGro
|
||||
private void indexDependency(String id, Dependency dependency) {
|
||||
Dependency existing = this.indexedDependencies.get(id);
|
||||
if (existing != null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not register " + dependency + " another dependency "
|
||||
+ "has also the '" + id + "' id " + existing);
|
||||
throw new IllegalArgumentException("Could not register " + dependency + " another dependency "
|
||||
+ "has also the '" + id + "' id " + existing);
|
||||
}
|
||||
this.indexedDependencies.put(id, dependency);
|
||||
}
|
||||
|
||||
@@ -73,9 +73,8 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
/**
|
||||
* All scope types.
|
||||
*/
|
||||
public static final List<String> SCOPE_ALL = Collections.unmodifiableList(
|
||||
Arrays.asList(SCOPE_COMPILE, SCOPE_RUNTIME, SCOPE_COMPILE_ONLY,
|
||||
SCOPE_ANNOTATION_PROCESSOR, SCOPE_PROVIDED, SCOPE_TEST));
|
||||
public static final List<String> SCOPE_ALL = Collections.unmodifiableList(Arrays.asList(SCOPE_COMPILE,
|
||||
SCOPE_RUNTIME, SCOPE_COMPILE_ONLY, SCOPE_ANNOTATION_PROCESSOR, SCOPE_PROVIDED, SCOPE_TEST));
|
||||
|
||||
private List<String> aliases = new ArrayList<>();
|
||||
|
||||
@@ -147,15 +146,13 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
|
||||
public void setScope(String scope) {
|
||||
if (!SCOPE_ALL.contains(scope)) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid scope " + scope + " must be one of " + SCOPE_ALL);
|
||||
throw new InvalidInitializrMetadataException("Invalid scope " + scope + " must be one of " + SCOPE_ALL);
|
||||
}
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public void setVersionRange(String versionRange) {
|
||||
this.versionRange = (StringUtils.hasText(versionRange) ? versionRange.trim()
|
||||
: null);
|
||||
this.versionRange = (StringUtils.hasText(versionRange) ? versionRange.trim() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,8 +172,7 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
*/
|
||||
public Dependency asSpringBootStarter(String name) {
|
||||
this.groupId = "org.springframework.boot";
|
||||
this.artifactId = (StringUtils.hasText(name) ? "spring-boot-starter-" + name
|
||||
: "spring-boot-starter");
|
||||
this.artifactId = (StringUtils.hasText(name) ? "spring-boot-starter-" + name : "spring-boot-starter");
|
||||
if (StringUtils.hasText(name)) {
|
||||
setId(name);
|
||||
}
|
||||
@@ -209,8 +205,7 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
}
|
||||
else {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid dependency, id should have the form groupId:artifactId[:version] but got "
|
||||
+ getId());
|
||||
"Invalid dependency, id should have the form groupId:artifactId[:version] but got " + getId());
|
||||
}
|
||||
}
|
||||
this.links.forEach(Link::resolve);
|
||||
@@ -225,10 +220,8 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
this.versionRequirement = this.range.toString();
|
||||
}
|
||||
catch (InvalidVersionException ex) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid version range '" + this.versionRange + " for "
|
||||
+ "dependency with id '" + getId() + "'",
|
||||
ex);
|
||||
throw new InvalidInitializrMetadataException("Invalid version range '" + this.versionRange + " for "
|
||||
+ "dependency with id '" + getId() + "'", ex);
|
||||
}
|
||||
}
|
||||
this.mappings.forEach((it) -> {
|
||||
@@ -253,12 +246,9 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
for (Mapping mapping : this.mappings) {
|
||||
if (mapping.range.match(bootVersion)) {
|
||||
Dependency dependency = new Dependency(this);
|
||||
dependency.groupId = (mapping.groupId != null) ? mapping.groupId
|
||||
: this.groupId;
|
||||
dependency.artifactId = (mapping.artifactId != null) ? mapping.artifactId
|
||||
: this.artifactId;
|
||||
dependency.version = (mapping.version != null) ? mapping.version
|
||||
: this.version;
|
||||
dependency.groupId = (mapping.groupId != null) ? mapping.groupId : this.groupId;
|
||||
dependency.artifactId = (mapping.artifactId != null) ? mapping.artifactId : this.artifactId;
|
||||
dependency.version = (mapping.version != null) ? mapping.version : this.version;
|
||||
dependency.versionRequirement = mapping.range.toString();
|
||||
dependency.mappings = null;
|
||||
return dependency;
|
||||
@@ -285,8 +275,8 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
*/
|
||||
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.");
|
||||
throw new IllegalArgumentException(
|
||||
"Could not generate id for " + this + ": at least groupId and artifactId must be set.");
|
||||
}
|
||||
setId(this.groupId + ":" + this.artifactId);
|
||||
return getId();
|
||||
@@ -446,20 +436,17 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Dependency{" + "id='" + getId() + '\'' + ", groupId='" + this.groupId
|
||||
+ '\'' + ", artifactId='" + this.artifactId + '\'' + ", version='"
|
||||
+ this.version + '\'' + '}';
|
||||
return "Dependency{" + "id='" + getId() + '\'' + ", groupId='" + this.groupId + '\'' + ", artifactId='"
|
||||
+ this.artifactId + '\'' + ", version='" + this.version + '\'' + '}';
|
||||
}
|
||||
|
||||
public static Dependency create(String groupId, String artifactId, String version,
|
||||
String scope) {
|
||||
public static Dependency create(String groupId, String artifactId, String version, String scope) {
|
||||
Dependency dependency = withId(null, groupId, artifactId, version);
|
||||
dependency.setScope(scope);
|
||||
return dependency;
|
||||
}
|
||||
|
||||
public static Dependency withId(String id, String groupId, String artifactId,
|
||||
String version, String scope) {
|
||||
public static Dependency withId(String id, String groupId, String artifactId, String version, String scope) {
|
||||
Dependency dependency = new Dependency();
|
||||
dependency.setId(id);
|
||||
dependency.groupId = groupId;
|
||||
@@ -469,8 +456,7 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
return dependency;
|
||||
}
|
||||
|
||||
public static Dependency withId(String id, String groupId, String artifactId,
|
||||
String version) {
|
||||
public static Dependency withId(String id, String groupId, String artifactId, String version) {
|
||||
return withId(id, groupId, artifactId, version, null);
|
||||
}
|
||||
|
||||
@@ -552,8 +538,7 @@ public class Dependency extends MetadataElement implements Describable {
|
||||
this.versionRange = versionRange;
|
||||
}
|
||||
|
||||
public static Mapping create(String range, String groupId, String artifactId,
|
||||
String version) {
|
||||
public static Mapping create(String range, String groupId, String artifactId, String version) {
|
||||
Mapping mapping = new Mapping();
|
||||
mapping.versionRange = range;
|
||||
mapping.groupId = groupId;
|
||||
|
||||
@@ -82,8 +82,7 @@ public class InitializrConfiguration {
|
||||
result = result + "Application";
|
||||
}
|
||||
String candidate = StringUtils.capitalize(result);
|
||||
if (hasInvalidChar(candidate)
|
||||
|| this.env.invalidApplicationNames.contains(candidate)) {
|
||||
if (hasInvalidChar(candidate) || this.env.invalidApplicationNames.contains(candidate)) {
|
||||
return this.env.fallbackApplicationName;
|
||||
}
|
||||
else {
|
||||
@@ -111,8 +110,7 @@ public class InitializrConfiguration {
|
||||
if (!StringUtils.hasText(candidate)) {
|
||||
return defaultPackageName;
|
||||
}
|
||||
if (hasInvalidChar(candidate.replace(".", ""))
|
||||
|| this.env.invalidPackageNames.contains(candidate)) {
|
||||
if (hasInvalidChar(candidate.replace(".", "")) || this.env.invalidPackageNames.contains(candidate)) {
|
||||
return defaultPackageName;
|
||||
}
|
||||
else {
|
||||
@@ -134,15 +132,13 @@ public class InitializrConfiguration {
|
||||
}
|
||||
|
||||
private static String unsplitWords(String text) {
|
||||
return String.join("", Arrays.stream(text.split("(_|-| |:)+"))
|
||||
.map(StringUtils::capitalize).toArray(String[]::new));
|
||||
return String.join("",
|
||||
Arrays.stream(text.split("(_|-| |:)+")).map(StringUtils::capitalize).toArray(String[]::new));
|
||||
}
|
||||
|
||||
private static String splitCamelCase(String text) {
|
||||
return String.join("",
|
||||
Arrays.stream(text.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])"))
|
||||
.map((it) -> StringUtils.capitalize(it.toLowerCase()))
|
||||
.toArray(String[]::new));
|
||||
return String.join("", Arrays.stream(text.split("(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])"))
|
||||
.map((it) -> StringUtils.capitalize(it.toLowerCase())).toArray(String[]::new));
|
||||
}
|
||||
|
||||
private static boolean hasInvalidChar(String text) {
|
||||
@@ -196,8 +192,7 @@ public class InitializrConfiguration {
|
||||
* The list of invalid package names. If such name is chosen or generated, the the
|
||||
* default package name should be used instead.
|
||||
*/
|
||||
private List<String> invalidPackageNames = new ArrayList<>(
|
||||
Collections.singletonList("org.springframework"));
|
||||
private List<String> invalidPackageNames = new ArrayList<>(Collections.singletonList("org.springframework"));
|
||||
|
||||
/**
|
||||
* Force SSL support. When enabled, any access using http generate https links and
|
||||
@@ -238,11 +233,9 @@ public class InitializrConfiguration {
|
||||
public Env() {
|
||||
try {
|
||||
this.repositories.put("spring-snapshots",
|
||||
new Repository("Spring Snapshots",
|
||||
new URL("https://repo.spring.io/snapshot"), true));
|
||||
new Repository("Spring Snapshots", new URL("https://repo.spring.io/snapshot"), true));
|
||||
this.repositories.put("spring-milestones",
|
||||
new Repository("Spring Milestones",
|
||||
new URL("https://repo.spring.io/milestone"), false));
|
||||
new Repository("Spring Milestones", new URL("https://repo.spring.io/milestone"), false));
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
throw new IllegalStateException("Cannot parse URL", ex);
|
||||
@@ -366,8 +359,7 @@ public class InitializrConfiguration {
|
||||
return this.dependencyManagementPluginVersion;
|
||||
}
|
||||
|
||||
public void setDependencyManagementPluginVersion(
|
||||
String dependencyManagementPluginVersion) {
|
||||
public void setDependencyManagementPluginVersion(String dependencyManagementPluginVersion) {
|
||||
this.dependencyManagementPluginVersion = dependencyManagementPluginVersion;
|
||||
}
|
||||
|
||||
@@ -423,14 +415,12 @@ public class InitializrConfiguration {
|
||||
this.mappings.forEach((m) -> {
|
||||
if (m.versionRange == null) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"VersionRange is mandatory, invalid version mapping for "
|
||||
+ this);
|
||||
"VersionRange is mandatory, invalid version mapping for " + this);
|
||||
}
|
||||
m.range = simpleParser.parseRange(m.versionRange);
|
||||
if (m.version == null) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Version is mandatory, invalid version mapping for "
|
||||
+ this);
|
||||
"Version is mandatory, invalid version mapping for " + this);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -442,9 +432,7 @@ public class InitializrConfiguration {
|
||||
}
|
||||
catch (InvalidVersionException ex) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid version range " + it.versionRange + " for "
|
||||
+ this,
|
||||
ex);
|
||||
"Invalid version range " + it.versionRange + " for " + this, ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -526,8 +514,7 @@ public class InitializrConfiguration {
|
||||
*/
|
||||
public ParentPom resolveParentPom(String bootVersion) {
|
||||
return (StringUtils.hasText(this.parent.groupId) ? this.parent
|
||||
: new ParentPom(DEFAULT_PARENT_GROUP_ID,
|
||||
DEFAULT_PARENT_ARTIFACT_ID, bootVersion));
|
||||
: new ParentPom(DEFAULT_PARENT_GROUP_ID, DEFAULT_PARENT_ARTIFACT_ID, bootVersion));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -609,14 +596,12 @@ public class InitializrConfiguration {
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
if (!((!StringUtils.hasText(this.groupId)
|
||||
&& !StringUtils.hasText(this.artifactId)
|
||||
if (!((!StringUtils.hasText(this.groupId) && !StringUtils.hasText(this.artifactId)
|
||||
&& !StringUtils.hasText(this.version))
|
||||
|| (StringUtils.hasText(this.groupId)
|
||||
&& StringUtils.hasText(this.artifactId)
|
||||
|| (StringUtils.hasText(this.groupId) && StringUtils.hasText(this.artifactId)
|
||||
&& StringUtils.hasText(this.version)))) {
|
||||
throw new InvalidInitializrMetadataException("Custom maven pom "
|
||||
+ "requires groupId, artifactId and version");
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Custom maven pom " + "requires groupId, artifactId and version");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,34 +39,29 @@ public class InitializrMetadata {
|
||||
|
||||
private final TypeCapability types = new TypeCapability();
|
||||
|
||||
private final SingleSelectCapability bootVersions = new SingleSelectCapability(
|
||||
"bootVersion", "Spring Boot Version", "spring boot version");
|
||||
private final SingleSelectCapability bootVersions = new SingleSelectCapability("bootVersion", "Spring Boot Version",
|
||||
"spring boot version");
|
||||
|
||||
private final SingleSelectCapability packagings = new SingleSelectCapability(
|
||||
"packaging", "Packaging", "project packaging");
|
||||
private final SingleSelectCapability packagings = new SingleSelectCapability("packaging", "Packaging",
|
||||
"project packaging");
|
||||
|
||||
private final SingleSelectCapability javaVersions = new SingleSelectCapability(
|
||||
"javaVersion", "Java Version", "language level");
|
||||
private final SingleSelectCapability javaVersions = new SingleSelectCapability("javaVersion", "Java Version",
|
||||
"language level");
|
||||
|
||||
private final SingleSelectCapability languages = new SingleSelectCapability(
|
||||
"language", "Language", "programming language");
|
||||
private final SingleSelectCapability languages = new SingleSelectCapability("language", "Language",
|
||||
"programming language");
|
||||
|
||||
private final TextCapability name = new TextCapability("name", "Name",
|
||||
"project name (infer application name)");
|
||||
private final TextCapability name = new TextCapability("name", "Name", "project name (infer application name)");
|
||||
|
||||
private final TextCapability description = new TextCapability("description",
|
||||
"Description", "project description");
|
||||
private final TextCapability description = new TextCapability("description", "Description", "project description");
|
||||
|
||||
private final TextCapability groupId = new TextCapability("groupId", "Group",
|
||||
"project coordinates");
|
||||
private final TextCapability groupId = new TextCapability("groupId", "Group", "project coordinates");
|
||||
|
||||
private final TextCapability artifactId = new ArtifactIdCapability(this.name);
|
||||
|
||||
private final TextCapability version = new TextCapability("version", "Version",
|
||||
"project version");
|
||||
private final TextCapability version = new TextCapability("version", "Version", "project version");
|
||||
|
||||
private final TextCapability packageName = new PackageCapability(this.groupId,
|
||||
this.artifactId);
|
||||
private final TextCapability packageName = new PackageCapability(this.groupId, this.artifactId);
|
||||
|
||||
public InitializrMetadata() {
|
||||
this(new InitializrConfiguration());
|
||||
@@ -155,52 +150,45 @@ public class InitializrMetadata {
|
||||
this.configuration.validate();
|
||||
this.dependencies.validate();
|
||||
|
||||
Map<String, Repository> repositories = this.configuration.getEnv()
|
||||
.getRepositories();
|
||||
Map<String, Repository> repositories = this.configuration.getEnv().getRepositories();
|
||||
Map<String, BillOfMaterials> boms = this.configuration.getEnv().getBoms();
|
||||
for (Dependency dependency : this.dependencies.getAll()) {
|
||||
if (dependency.getBom() != null && !boms.containsKey(dependency.getBom())) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Dependency " + dependency + "defines an invalid BOM id "
|
||||
+ dependency.getBom() + ", available boms " + boms);
|
||||
throw new InvalidInitializrMetadataException("Dependency " + dependency + "defines an invalid BOM id "
|
||||
+ dependency.getBom() + ", available boms " + boms);
|
||||
}
|
||||
|
||||
if (dependency.getRepository() != null
|
||||
&& !repositories.containsKey(dependency.getRepository())) {
|
||||
throw new InvalidInitializrMetadataException("Dependency " + dependency
|
||||
+ "defines an invalid repository id " + dependency.getRepository()
|
||||
+ ", available repositories " + repositories);
|
||||
if (dependency.getRepository() != null && !repositories.containsKey(dependency.getRepository())) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Dependency " + dependency + "defines an invalid repository id " + dependency.getRepository()
|
||||
+ ", available repositories " + repositories);
|
||||
}
|
||||
}
|
||||
for (BillOfMaterials bom : boms.values()) {
|
||||
for (String r : bom.getRepositories()) {
|
||||
if (!repositories.containsKey(r)) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
bom + "defines an invalid repository id " + r
|
||||
+ ", available repositories " + repositories);
|
||||
bom + "defines an invalid repository id " + r + ", available repositories " + repositories);
|
||||
}
|
||||
}
|
||||
for (String b : bom.getAdditionalBoms()) {
|
||||
if (!boms.containsKey(b)) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
bom + " defines an invalid " + "additional bom id " + b
|
||||
+ ", available boms " + boms);
|
||||
bom + " defines an invalid " + "additional bom id " + b + ", available boms " + boms);
|
||||
}
|
||||
}
|
||||
for (BillOfMaterials.Mapping m : bom.getMappings()) {
|
||||
for (String r : m.getRepositories()) {
|
||||
if (!repositories.containsKey(r)) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
m + " of " + bom + "defines an invalid repository id " + r
|
||||
+ ", available repositories " + repositories);
|
||||
throw new InvalidInitializrMetadataException(m + " of " + bom
|
||||
+ "defines an invalid repository id " + r + ", available repositories " + repositories);
|
||||
}
|
||||
|
||||
}
|
||||
for (String b : m.getAdditionalBoms()) {
|
||||
if (!boms.containsKey(b)) {
|
||||
throw new InvalidInitializrMetadataException(m + " of " + bom
|
||||
+ " defines " + "an invalid additional bom id " + b
|
||||
+ ", available boms " + boms);
|
||||
throw new InvalidInitializrMetadataException(m + " of " + bom + " defines "
|
||||
+ "an invalid additional bom id " + b + ", available boms " + boms);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -214,12 +202,11 @@ public class InitializrMetadata {
|
||||
public void updateSpringBootVersions(List<DefaultMetadataElement> versionsMetadata) {
|
||||
this.bootVersions.getContent().clear();
|
||||
this.bootVersions.getContent().addAll(versionsMetadata);
|
||||
List<Version> bootVersions = this.bootVersions.getContent().stream()
|
||||
.map((it) -> Version.parse(it.getId())).collect(Collectors.toList());
|
||||
List<Version> bootVersions = this.bootVersions.getContent().stream().map((it) -> Version.parse(it.getId()))
|
||||
.collect(Collectors.toList());
|
||||
VersionParser parser = new VersionParser(bootVersions);
|
||||
this.dependencies.updateVersionRange(parser);
|
||||
this.configuration.getEnv().getBoms().values()
|
||||
.forEach((it) -> it.updateVersionRange(parser));
|
||||
this.configuration.getEnv().getBoms().values().forEach((it) -> it.updateVersionRange(parser));
|
||||
this.configuration.getEnv().getKotlin().updateVersionRange(parser);
|
||||
}
|
||||
|
||||
@@ -231,9 +218,8 @@ public class InitializrMetadata {
|
||||
*/
|
||||
public String createCliDistributionURl(String extension) {
|
||||
String bootVersion = defaultId(this.bootVersions);
|
||||
return this.configuration.getEnv().getArtifactRepository()
|
||||
+ "org/springframework/boot/spring-boot-cli/" + bootVersion
|
||||
+ "/spring-boot-cli-" + bootVersion + "-bin." + extension;
|
||||
return this.configuration.getEnv().getArtifactRepository() + "org/springframework/boot/spring-boot-cli/"
|
||||
+ bootVersion + "/spring-boot-cli-" + bootVersion + "-bin." + extension;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,10 +228,9 @@ public class InitializrMetadata {
|
||||
* @param versionProperty the property that contains the version
|
||||
* @return a new {@link BillOfMaterials} instance
|
||||
*/
|
||||
public BillOfMaterials createSpringBootBom(String bootVersion,
|
||||
String versionProperty) {
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.springframework.boot",
|
||||
"spring-boot-dependencies", bootVersion);
|
||||
public BillOfMaterials createSpringBootBom(String bootVersion, String versionProperty) {
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.springframework.boot", "spring-boot-dependencies",
|
||||
bootVersion);
|
||||
bom.setVersionProperty(VersionProperty.of(versionProperty));
|
||||
bom.setOrder(100);
|
||||
return bom;
|
||||
@@ -271,8 +256,7 @@ public class InitializrMetadata {
|
||||
return defaults;
|
||||
}
|
||||
|
||||
private static String defaultId(
|
||||
Defaultable<? extends DefaultMetadataElement> element) {
|
||||
private static String defaultId(Defaultable<? extends DefaultMetadataElement> element) {
|
||||
DefaultMetadataElement defaultValue = element.getDefault();
|
||||
return (defaultValue != null) ? defaultValue.getId() : null;
|
||||
}
|
||||
@@ -312,10 +296,9 @@ public class InitializrMetadata {
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
else if (this.groupId.getContent() != null
|
||||
&& this.artifactId.getContent() != null) {
|
||||
return InitializrConfiguration.cleanPackageName(
|
||||
this.groupId.getContent() + "." + this.artifactId.getContent());
|
||||
else if (this.groupId.getContent() != null && this.artifactId.getContent() != null) {
|
||||
return InitializrConfiguration
|
||||
.cleanPackageName(this.groupId.getContent() + "." + this.artifactId.getContent());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ public final class InitializrMetadataBuilder {
|
||||
* @return this instance
|
||||
* @see #withInitializrProperties(InitializrProperties, boolean)
|
||||
*/
|
||||
public InitializrMetadataBuilder withInitializrProperties(
|
||||
InitializrProperties properties) {
|
||||
public InitializrMetadataBuilder withInitializrProperties(InitializrProperties properties) {
|
||||
return withInitializrProperties(properties, false);
|
||||
}
|
||||
|
||||
@@ -64,8 +63,8 @@ public final class InitializrMetadataBuilder {
|
||||
* @param mergeConfiguration specify if service configuration should be merged as well
|
||||
* @return this instance
|
||||
*/
|
||||
public InitializrMetadataBuilder withInitializrProperties(
|
||||
InitializrProperties properties, boolean mergeConfiguration) {
|
||||
public InitializrMetadataBuilder withInitializrProperties(InitializrProperties properties,
|
||||
boolean mergeConfiguration) {
|
||||
if (mergeConfiguration) {
|
||||
this.configuration.merge(properties);
|
||||
}
|
||||
@@ -88,8 +87,7 @@ public final class InitializrMetadataBuilder {
|
||||
* @return this instance
|
||||
* @see InitializrMetadataCustomizer
|
||||
*/
|
||||
public InitializrMetadataBuilder withCustomizer(
|
||||
InitializrMetadataCustomizer customizer) {
|
||||
public InitializrMetadataBuilder withCustomizer(InitializrMetadataCustomizer customizer) {
|
||||
this.customizers.add(customizer);
|
||||
return this;
|
||||
}
|
||||
@@ -145,10 +143,8 @@ public final class InitializrMetadataBuilder {
|
||||
* @return a new {@link InitializrMetadataBuilder} instance
|
||||
* @see #withInitializrProperties(InitializrProperties)
|
||||
*/
|
||||
public static InitializrMetadataBuilder fromInitializrProperties(
|
||||
InitializrProperties configuration) {
|
||||
return new InitializrMetadataBuilder(configuration)
|
||||
.withInitializrProperties(configuration);
|
||||
public static InitializrMetadataBuilder fromInitializrProperties(InitializrProperties configuration) {
|
||||
return new InitializrMetadataBuilder(configuration).withInitializrProperties(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,8 +155,7 @@ public final class InitializrMetadataBuilder {
|
||||
return new InitializrMetadataBuilder(new InitializrConfiguration());
|
||||
}
|
||||
|
||||
private static class InitializerPropertiesCustomizer
|
||||
implements InitializrMetadataCustomizer {
|
||||
private static class InitializerPropertiesCustomizer implements InitializrMetadataCustomizer {
|
||||
|
||||
private final InitializrProperties properties;
|
||||
|
||||
@@ -186,11 +181,9 @@ public final class InitializrMetadataBuilder {
|
||||
|
||||
}
|
||||
|
||||
private static class ResourceInitializrMetadataCustomizer
|
||||
implements InitializrMetadataCustomizer {
|
||||
private static class ResourceInitializrMetadataCustomizer implements InitializrMetadataCustomizer {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(ResourceInitializrMetadataCustomizer.class);
|
||||
private static final Log logger = LogFactory.getLog(ResourceInitializrMetadataCustomizer.class);
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
@@ -206,8 +199,7 @@ public final class InitializrMetadataBuilder {
|
||||
try (InputStream in = this.resource.getInputStream()) {
|
||||
String content = StreamUtils.copyToString(in, UTF_8);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
InitializrMetadata anotherMetadata = objectMapper.readValue(content,
|
||||
InitializrMetadata.class);
|
||||
InitializrMetadata anotherMetadata = objectMapper.readValue(content, InitializrMetadata.class);
|
||||
metadata.merge(anotherMetadata);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
@@ -96,8 +96,7 @@ public class InitializrProperties extends InitializrConfiguration {
|
||||
* Description metadata.
|
||||
*/
|
||||
@JsonIgnore
|
||||
private final SimpleElement description = new SimpleElement(
|
||||
"Demo project for Spring Boot");
|
||||
private final SimpleElement description = new SimpleElement("Demo project for Spring Boot");
|
||||
|
||||
/**
|
||||
* Package name metadata.
|
||||
|
||||
@@ -125,12 +125,10 @@ public class Link {
|
||||
|
||||
public void resolve() {
|
||||
if (this.rel == null) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid link " + this + ": rel attribute is mandatory");
|
||||
throw new InvalidInitializrMetadataException("Invalid link " + this + ": rel attribute is mandatory");
|
||||
}
|
||||
if (this.href == null) {
|
||||
throw new InvalidInitializrMetadataException(
|
||||
"Invalid link " + this + ": href attribute is mandatory");
|
||||
throw new InvalidInitializrMetadataException("Invalid link " + this + ": href attribute is mandatory");
|
||||
}
|
||||
Matcher matcher = VARIABLE_REGEX.matcher(this.href);
|
||||
while (matcher.find()) {
|
||||
@@ -150,8 +148,8 @@ public class Link {
|
||||
this.templateVariables.forEach((var) -> {
|
||||
Object value = parameters.get(var);
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Could not expand " + this.href
|
||||
+ ", missing value for '" + var + "'");
|
||||
throw new IllegalArgumentException(
|
||||
"Could not expand " + this.href + ", missing value for '" + var + "'");
|
||||
}
|
||||
result.set(result.get().replace("{" + var + "}", value.toString()));
|
||||
});
|
||||
|
||||
@@ -112,8 +112,8 @@ public class Repository {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Repository [" + ((this.name != null) ? "name=" + this.name + ", " : "")
|
||||
+ ((this.url != null) ? "url=" + this.url + ", " : "")
|
||||
+ "snapshotsEnabled=" + this.snapshotsEnabled + "]";
|
||||
+ ((this.url != null) ? "url=" + this.url + ", " : "") + "snapshotsEnabled=" + this.snapshotsEnabled
|
||||
+ "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -47,8 +47,7 @@ public abstract class ServiceCapability<T> implements Cloneable {
|
||||
*/
|
||||
private String description;
|
||||
|
||||
protected ServiceCapability(String id, ServiceCapabilityType type, String title,
|
||||
String description) {
|
||||
protected ServiceCapability(String id, ServiceCapabilityType type, String title, String description) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.title = title;
|
||||
|
||||
@@ -27,8 +27,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SingleSelectCapability
|
||||
extends ServiceCapability<List<DefaultMetadataElement>>
|
||||
public class SingleSelectCapability extends ServiceCapability<List<DefaultMetadataElement>>
|
||||
implements Defaultable<DefaultMetadataElement> {
|
||||
|
||||
private final List<DefaultMetadataElement> content = new CopyOnWriteArrayList<>();
|
||||
@@ -52,8 +51,7 @@ public class SingleSelectCapability
|
||||
*/
|
||||
@Override
|
||||
public DefaultMetadataElement getDefault() {
|
||||
return this.content.stream().filter(DefaultMetadataElement::isDefault).findFirst()
|
||||
.orElse(null);
|
||||
return this.content.stream().filter(DefaultMetadataElement::isDefault).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,8 +60,7 @@ public class SingleSelectCapability
|
||||
* @return the element or {@code null}
|
||||
*/
|
||||
public DefaultMetadataElement get(String id) {
|
||||
return this.content.stream().filter((it) -> id.equals(it.getId())).findFirst()
|
||||
.orElse(null);
|
||||
return this.content.stream().filter((it) -> id.equals(it.getId())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,8 +24,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class TypeCapability extends ServiceCapability<List<Type>>
|
||||
implements Defaultable<Type> {
|
||||
public class TypeCapability extends ServiceCapability<List<Type>> implements Defaultable<Type> {
|
||||
|
||||
private final List<Type> content = new ArrayList<>();
|
||||
|
||||
@@ -45,8 +44,7 @@ public class TypeCapability extends ServiceCapability<List<Type>>
|
||||
* @return the Type or {@code null}
|
||||
*/
|
||||
public Type get(String id) {
|
||||
return this.content.stream().filter((it) -> id.equals(it.getId())).findFirst()
|
||||
.orElse(null);
|
||||
return this.content.stream().filter((it) -> id.equals(it.getId())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,8 +52,7 @@ public class TypeCapability extends ServiceCapability<List<Type>>
|
||||
*/
|
||||
@Override
|
||||
public Type getDefault() {
|
||||
return this.content.stream().filter(DefaultMetadataElement::isDefault).findFirst()
|
||||
.orElse(null);
|
||||
return this.content.stream().filter(DefaultMetadataElement::isDefault).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,17 +38,15 @@ public final class MetadataBuildItemMapper {
|
||||
* @param dependency a dependency metadata
|
||||
* @return an equivalent build dependency
|
||||
*/
|
||||
public static io.spring.initializr.generator.buildsystem.Dependency toDependency(
|
||||
Dependency dependency) {
|
||||
public static io.spring.initializr.generator.buildsystem.Dependency toDependency(Dependency dependency) {
|
||||
if (dependency == null) {
|
||||
return null;
|
||||
}
|
||||
VersionReference versionReference = (dependency.getVersion() != null)
|
||||
? VersionReference.ofValue(dependency.getVersion()) : null;
|
||||
return io.spring.initializr.generator.buildsystem.Dependency
|
||||
.withCoordinates(dependency.getGroupId(), dependency.getArtifactId())
|
||||
.version(versionReference).scope(toDependencyScope(dependency.getScope()))
|
||||
.type(dependency.getType()).build();
|
||||
.withCoordinates(dependency.getGroupId(), dependency.getArtifactId()).version(versionReference)
|
||||
.scope(toDependencyScope(dependency.getScope())).type(dependency.getType()).build();
|
||||
}
|
||||
|
||||
private static DependencyScope toDependencyScope(String scope) {
|
||||
@@ -74,16 +72,14 @@ public final class MetadataBuildItemMapper {
|
||||
* @param bom a metadata bom
|
||||
* @return an equivalent build bom
|
||||
*/
|
||||
public static io.spring.initializr.generator.buildsystem.BillOfMaterials toBom(
|
||||
BillOfMaterials bom) {
|
||||
public static io.spring.initializr.generator.buildsystem.BillOfMaterials toBom(BillOfMaterials bom) {
|
||||
if (bom == null) {
|
||||
return null;
|
||||
}
|
||||
VersionReference version = (bom.getVersionProperty() != null)
|
||||
? VersionReference.ofProperty(bom.getVersionProperty())
|
||||
: VersionReference.ofValue(bom.getVersion());
|
||||
return new io.spring.initializr.generator.buildsystem.BillOfMaterials(
|
||||
bom.getGroupId(), bom.getArtifactId(), version, bom.getOrder());
|
||||
? VersionReference.ofProperty(bom.getVersionProperty()) : VersionReference.ofValue(bom.getVersion());
|
||||
return new io.spring.initializr.generator.buildsystem.BillOfMaterials(bom.getGroupId(), bom.getArtifactId(),
|
||||
version, bom.getOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,14 +88,13 @@ public final class MetadataBuildItemMapper {
|
||||
* @param repository a repository metadata
|
||||
* @return an equivalent build repository
|
||||
*/
|
||||
public static io.spring.initializr.generator.buildsystem.MavenRepository toRepository(
|
||||
String id, Repository repository) {
|
||||
public static io.spring.initializr.generator.buildsystem.MavenRepository toRepository(String id,
|
||||
Repository repository) {
|
||||
if (repository == null) {
|
||||
return null;
|
||||
}
|
||||
return new io.spring.initializr.generator.buildsystem.MavenRepository(id,
|
||||
repository.getName(), repository.getUrl().toExternalForm(),
|
||||
repository.isSnapshotsEnabled());
|
||||
return new io.spring.initializr.generator.buildsystem.MavenRepository(id, repository.getName(),
|
||||
repository.getUrl().toExternalForm(), repository.isSnapshotsEnabled());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,27 +41,23 @@ public final class MetadataBuildItemResolver implements BuildItemResolver {
|
||||
* @param metadata the metadata to use
|
||||
* @param platformVersion the platform version to consider
|
||||
*/
|
||||
public MetadataBuildItemResolver(InitializrMetadata metadata,
|
||||
Version platformVersion) {
|
||||
public MetadataBuildItemResolver(InitializrMetadata metadata, Version platformVersion) {
|
||||
this.metadata = metadata;
|
||||
this.platformVersion = platformVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dependency resolveDependency(String id) {
|
||||
io.spring.initializr.metadata.Dependency dependency = this.metadata
|
||||
.getDependencies().get(id);
|
||||
io.spring.initializr.metadata.Dependency dependency = this.metadata.getDependencies().get(id);
|
||||
if (dependency != null) {
|
||||
return MetadataBuildItemMapper
|
||||
.toDependency(dependency.resolve(this.platformVersion));
|
||||
return MetadataBuildItemMapper.toDependency(dependency.resolve(this.platformVersion));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BillOfMaterials resolveBom(String id) {
|
||||
io.spring.initializr.metadata.BillOfMaterials bom = this.metadata
|
||||
.getConfiguration().getEnv().getBoms().get(id);
|
||||
io.spring.initializr.metadata.BillOfMaterials bom = this.metadata.getConfiguration().getEnv().getBoms().get(id);
|
||||
if (bom != null) {
|
||||
return MetadataBuildItemMapper.toBom(bom.resolve(this.platformVersion));
|
||||
}
|
||||
|
||||
@@ -51,8 +51,7 @@ class BillOfMaterialsTests {
|
||||
assertThat(resolved.getGroupId()).isEqualTo("com.example");
|
||||
assertThat(resolved.getArtifactId()).isEqualTo("bom");
|
||||
assertThat(resolved.getVersion()).isEqualTo("1.1.0");
|
||||
assertThat(resolved.getVersionProperty().toStandardFormat())
|
||||
.isEqualTo("bom.version");
|
||||
assertThat(resolved.getVersionProperty().toStandardFormat()).isEqualTo("bom.version");
|
||||
assertThat(resolved.getRepositories()).hasSize(1);
|
||||
assertThat(resolved.getRepositories().get(0)).isEqualTo("repo-main");
|
||||
assertThat(resolved.getAdditionalBoms()).hasSize(1);
|
||||
@@ -74,8 +73,7 @@ class BillOfMaterialsTests {
|
||||
assertThat(resolved.getGroupId()).isEqualTo("com.example.override");
|
||||
assertThat(resolved.getArtifactId()).isEqualTo("bom-override");
|
||||
assertThat(resolved.getVersion()).isEqualTo("1.1.0");
|
||||
assertThat(resolved.getVersionProperty().toStandardFormat())
|
||||
.isEqualTo("bom.version");
|
||||
assertThat(resolved.getVersionProperty().toStandardFormat()).isEqualTo("bom.version");
|
||||
assertThat(resolved.getRepositories()).hasSize(1);
|
||||
assertThat(resolved.getRepositories().get(0)).isEqualTo("repo-main");
|
||||
assertThat(resolved.getAdditionalBoms()).hasSize(1);
|
||||
@@ -112,8 +110,7 @@ class BillOfMaterialsTests {
|
||||
assertThat(resolved.getGroupId()).isEqualTo("com.example");
|
||||
assertThat(resolved.getArtifactId()).isEqualTo("bom");
|
||||
assertThat(resolved.getVersion()).isEqualTo("1.1.0");
|
||||
assertThat(resolved.getVersionProperty().toStandardFormat())
|
||||
.isEqualTo("example.version");
|
||||
assertThat(resolved.getVersionProperty().toStandardFormat()).isEqualTo("example.version");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,8 +119,7 @@ class BillOfMaterialsTests {
|
||||
bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.1.0"));
|
||||
bom.getMappings().add(Mapping.create("[1.3.0.M1, 1.4.0.M1)", "1.2.0"));
|
||||
bom.validate();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> bom.resolve(Version.parse("1.4.1.RELEASE")))
|
||||
assertThatIllegalStateException().isThrownBy(() -> bom.resolve(Version.parse("1.4.1.RELEASE")))
|
||||
.withMessageContaining("1.4.1.RELEASE");
|
||||
}
|
||||
|
||||
@@ -131,23 +127,18 @@ class BillOfMaterialsTests {
|
||||
void resolveRangeWithVariablePatch() {
|
||||
BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "1.0.0");
|
||||
bom.getMappings().add(Mapping.create("[1.3.0.RELEASE,1.3.x.RELEASE]", "1.1.0"));
|
||||
bom.getMappings().add(BillOfMaterials.Mapping
|
||||
.create("[1.3.x.BUILD-SNAPSHOT,1.4.0.RELEASE)", "1.1.1-SNAPSHOT"));
|
||||
bom.getMappings().add(BillOfMaterials.Mapping.create("[1.3.x.BUILD-SNAPSHOT,1.4.0.RELEASE)", "1.1.1-SNAPSHOT"));
|
||||
bom.validate();
|
||||
|
||||
bom.updateVersionRange(new VersionParser(Arrays.asList(
|
||||
Version.parse("1.3.8.RELEASE"), Version.parse("1.3.9.BUILD-SNAPSHOT"))));
|
||||
assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion())
|
||||
.isEqualTo("1.1.0");
|
||||
assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion())
|
||||
.isEqualTo("1.1.1-SNAPSHOT");
|
||||
bom.updateVersionRange(new VersionParser(
|
||||
Arrays.asList(Version.parse("1.3.8.RELEASE"), Version.parse("1.3.9.BUILD-SNAPSHOT"))));
|
||||
assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion()).isEqualTo("1.1.0");
|
||||
assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion()).isEqualTo("1.1.1-SNAPSHOT");
|
||||
|
||||
bom.updateVersionRange(new VersionParser(Arrays.asList(
|
||||
Version.parse("1.3.9.RELEASE"), Version.parse("1.3.10.BUILD-SNAPSHOT"))));
|
||||
assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion())
|
||||
.isEqualTo("1.1.0");
|
||||
assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion())
|
||||
.isEqualTo("1.1.0");
|
||||
bom.updateVersionRange(new VersionParser(
|
||||
Arrays.asList(Version.parse("1.3.9.RELEASE"), Version.parse("1.3.10.BUILD-SNAPSHOT"))));
|
||||
assertThat(bom.resolve(Version.parse("1.3.8.RELEASE")).getVersion()).isEqualTo("1.1.0");
|
||||
assertThat(bom.resolve(Version.parse("1.3.9.RELEASE")).getVersion()).isEqualTo("1.1.0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,8 +32,7 @@ class DependenciesCapabilityTests {
|
||||
void indexedDependencies() {
|
||||
Dependency dependency = Dependency.withId("first");
|
||||
Dependency dependency2 = Dependency.withId("second");
|
||||
DependenciesCapability capability = createDependenciesCapability("foo",
|
||||
dependency, dependency2);
|
||||
DependenciesCapability capability = createDependenciesCapability("foo", dependency, dependency2);
|
||||
capability.validate();
|
||||
|
||||
assertThat(capability.get("first")).isSameAs(dependency);
|
||||
@@ -45,10 +44,8 @@ class DependenciesCapabilityTests {
|
||||
void addTwoDependenciesWithSameId() {
|
||||
Dependency dependency = Dependency.withId("conflict");
|
||||
Dependency dependency2 = Dependency.withId("conflict");
|
||||
DependenciesCapability capability = createDependenciesCapability("foo",
|
||||
dependency, dependency2);
|
||||
assertThatIllegalArgumentException().isThrownBy(capability::validate)
|
||||
.withMessageContaining("conflict");
|
||||
DependenciesCapability capability = createDependenciesCapability("foo", dependency, dependency2);
|
||||
assertThatIllegalArgumentException().isThrownBy(capability::validate).withMessageContaining("conflict");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -56,8 +53,7 @@ class DependenciesCapabilityTests {
|
||||
Dependency dependency = Dependency.withId("first");
|
||||
dependency.getAliases().add("alias1");
|
||||
dependency.getAliases().add("alias2");
|
||||
DependenciesCapability capability = createDependenciesCapability("foo",
|
||||
dependency);
|
||||
DependenciesCapability capability = createDependenciesCapability("foo", dependency);
|
||||
capability.validate();
|
||||
assertThat(capability.get("first")).isSameAs(dependency);
|
||||
assertThat(capability.get("alias1")).isSameAs(dependency);
|
||||
@@ -74,19 +70,17 @@ class DependenciesCapabilityTests {
|
||||
DependenciesCapability capability = new DependenciesCapability();
|
||||
capability.getContent().add(createDependencyGroup("foo", dependency));
|
||||
capability.getContent().add(createDependencyGroup("bar", dependency2));
|
||||
assertThatIllegalArgumentException().isThrownBy(capability::validate)
|
||||
.withMessageContaining("alias2");
|
||||
assertThatIllegalArgumentException().isThrownBy(capability::validate).withMessageContaining("alias2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mergeAddEntry() {
|
||||
DependenciesCapability capability = createDependenciesCapability("foo",
|
||||
Dependency.withId("first"), Dependency.withId("second"));
|
||||
DependenciesCapability capability = createDependenciesCapability("foo", Dependency.withId("first"),
|
||||
Dependency.withId("second"));
|
||||
|
||||
DependenciesCapability anotherCapability = createDependenciesCapability("foo",
|
||||
Dependency.withId("bar"), Dependency.withId("biz"));
|
||||
anotherCapability.getContent()
|
||||
.add(createDependencyGroup("bar", Dependency.withId("third")));
|
||||
DependenciesCapability anotherCapability = createDependenciesCapability("foo", Dependency.withId("bar"),
|
||||
Dependency.withId("biz"));
|
||||
anotherCapability.getContent().add(createDependencyGroup("bar", Dependency.withId("third")));
|
||||
|
||||
capability.merge(anotherCapability);
|
||||
assertThat(capability.getContent()).hasSize(2);
|
||||
@@ -143,16 +137,14 @@ class DependenciesCapabilityTests {
|
||||
assertThat(capability.get("second").getRepository()).isEqualTo("da-repo");
|
||||
}
|
||||
|
||||
private static DependenciesCapability createDependenciesCapability(String groupName,
|
||||
Dependency... dependencies) {
|
||||
private static DependenciesCapability createDependenciesCapability(String groupName, Dependency... dependencies) {
|
||||
DependenciesCapability capability = new DependenciesCapability();
|
||||
DependencyGroup group = createDependencyGroup(groupName, dependencies);
|
||||
capability.getContent().add(group);
|
||||
return capability;
|
||||
}
|
||||
|
||||
private static DependencyGroup createDependencyGroup(String groupName,
|
||||
Dependency... dependencies) {
|
||||
private static DependencyGroup createDependencyGroup(String groupName, Dependency... dependencies) {
|
||||
DependencyGroup group = DependencyGroup.create(groupName);
|
||||
for (Dependency dependency : dependencies) {
|
||||
group.getContent().add(dependency);
|
||||
|
||||
@@ -108,23 +108,21 @@ class DependencyTests {
|
||||
void invalidSpringBootRange() {
|
||||
Dependency dependency = Dependency.withId("web");
|
||||
dependency.setVersionRange("A.B.C");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(dependency::resolve).withMessageContaining("A.B.C");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(dependency::resolve)
|
||||
.withMessageContaining("A.B.C");
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidIdFormatTooManyColons() {
|
||||
Dependency dependency = Dependency.withId("org.foo:bar:1.0:test:external");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(dependency::resolve);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(dependency::resolve);
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidLink() {
|
||||
Dependency dependency = Dependency.withId("foo");
|
||||
dependency.getLinks().add(Link.create(null, "https://example.com"));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(dependency::resolve);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(dependency::resolve);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,28 +143,25 @@ class DependencyTests {
|
||||
void resolveNoMapping() {
|
||||
Dependency dependency = Dependency.withId("web");
|
||||
dependency.resolve();
|
||||
assertThat(dependency.resolve(Version.parse("1.2.0.RELEASE")))
|
||||
.isSameAs(dependency);
|
||||
assertThat(dependency.resolve(Version.parse("1.2.0.RELEASE"))).isSameAs(dependency);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveInvalidMapping() {
|
||||
Dependency dependency = Dependency.withId("web");
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("foo-bar", null, null, "0.1.0.RELEASE"));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(dependency::resolve).withMessageContaining("foo-bar");
|
||||
dependency.getMappings().add(Dependency.Mapping.create("foo-bar", null, null, "0.1.0.RELEASE"));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(dependency::resolve)
|
||||
.withMessageContaining("foo-bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveVersionRequirement() {
|
||||
Dependency dependency = Dependency.withId("web");
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
|
||||
dependency.resolve();
|
||||
Dependency resolved = dependency.resolve(Version.parse("1.1.5.RELEASE"));
|
||||
assertThat(resolved.getVersionRequirement())
|
||||
.isEqualTo(">=1.1.0.RELEASE and <1.2.0.RELEASE");
|
||||
assertThat(resolved.getVersionRequirement()).isEqualTo(">=1.1.0.RELEASE and <1.2.0.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,18 +171,18 @@ class DependencyTests {
|
||||
dependency.getKeywords().addAll(Arrays.asList("foo", "bar"));
|
||||
dependency.getAliases().add("the-web");
|
||||
dependency.getFacets().add("web");
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, null, "0.2.0.RELEASE"));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, null, "0.2.0.RELEASE"));
|
||||
dependency.resolve();
|
||||
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.2.0.RELEASE")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.2.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.2.0.RELEASE")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.2.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -197,18 +192,18 @@ class DependencyTests {
|
||||
dependency.getKeywords().addAll(Arrays.asList("foo", "bar"));
|
||||
dependency.getAliases().add("the-web");
|
||||
dependency.getFacets().add("web");
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", "org.spring.boot", null, null));
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, "starter-web", null));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", "org.spring.boot", null, null));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, "starter-web", null));
|
||||
dependency.resolve();
|
||||
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")),
|
||||
"org.spring.boot", "spring-boot-starter-web", "0.3.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.2.0.RELEASE")),
|
||||
"org.springframework.boot", "starter-web", "0.3.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.spring.boot",
|
||||
"spring-boot-starter-web", "0.3.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.2.0.RELEASE")), "org.springframework.boot",
|
||||
"starter-web", "0.3.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,54 +213,49 @@ class DependencyTests {
|
||||
dependency.getKeywords().addAll(Arrays.asList("foo", "bar"));
|
||||
dependency.getAliases().add("the-web");
|
||||
dependency.getFacets().add("web");
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.1.0.RELEASE, 1.1.x.RELEASE]", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings().add(Dependency.Mapping.create(
|
||||
"[1.1.x.BUILD-SNAPSHOT, 1.2.0.RELEASE)", null, null, "0.2.0.RELEASE"));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.1.x.RELEASE]", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.1.x.BUILD-SNAPSHOT, 1.2.0.RELEASE)", null, null, "0.2.0.RELEASE"));
|
||||
dependency.resolve();
|
||||
|
||||
dependency.updateVersionRanges(new VersionParser(Arrays.asList(
|
||||
Version.parse("1.1.5.RELEASE"), Version.parse("1.1.6.BUILD-SNAPSHOT"))));
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(
|
||||
dependency.resolve(Version.parse("1.1.6.BUILD-SNAPSHOT")),
|
||||
dependency.updateVersionRanges(new VersionParser(
|
||||
Arrays.asList(Version.parse("1.1.5.RELEASE"), Version.parse("1.1.6.BUILD-SNAPSHOT"))));
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.6.BUILD-SNAPSHOT")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.2.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
|
||||
dependency.updateVersionRanges(new VersionParser(Arrays.asList(
|
||||
Version.parse("1.1.6.RELEASE"), Version.parse("1.1.7.BUILD-SNAPSHOT"))));
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.6.RELEASE")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(
|
||||
dependency.resolve(Version.parse("1.1.7.BUILD-SNAPSHOT")),
|
||||
dependency.updateVersionRanges(new VersionParser(
|
||||
Arrays.asList(Version.parse("1.1.6.RELEASE"), Version.parse("1.1.7.BUILD-SNAPSHOT"))));
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.6.RELEASE")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.1.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("1.1.7.BUILD-SNAPSHOT")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.2.0.RELEASE");
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")),
|
||||
"org.springframework.boot", "spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
validateResolvedWebDependency(dependency.resolve(Version.parse("2.1.3.M1")), "org.springframework.boot",
|
||||
"spring-boot-starter-web", "0.3.0.RELEASE"); // default
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveMatchingWithCustomGroupId() {
|
||||
Dependency dependency = Dependency.withId("foo", "com.acme", "foo",
|
||||
"0.3.0.RELEASE");
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "1.0.0.RELEASE"));
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, "bar", null));
|
||||
Dependency dependency = Dependency.withId("foo", "com.acme", "foo", "0.3.0.RELEASE");
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.1.0.RELEASE, 1.2.0.RELEASE)", null, null, "1.0.0.RELEASE"));
|
||||
dependency.getMappings().add(Dependency.Mapping.create("[1.2.0.RELEASE, 1.3.0.RELEASE)", null, "bar", null));
|
||||
dependency.resolve();
|
||||
validateResolvedDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")),
|
||||
"foo", "com.acme", "foo", "1.0.0.RELEASE");
|
||||
validateResolvedDependency(dependency.resolve(Version.parse("1.2.5.RELEASE")),
|
||||
"foo", "com.acme", "bar", "0.3.0.RELEASE");
|
||||
validateResolvedDependency(dependency.resolve(Version.parse("1.1.5.RELEASE")), "foo", "com.acme", "foo",
|
||||
"1.0.0.RELEASE");
|
||||
validateResolvedDependency(dependency.resolve(Version.parse("1.2.5.RELEASE")), "foo", "com.acme", "bar",
|
||||
"0.3.0.RELEASE");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveVersionWithX() {
|
||||
Dependency dependency1 = Dependency.withId("foo1", "com.acme", "foo1",
|
||||
"0.3.0.RELEASE");
|
||||
Dependency dependency1 = Dependency.withId("foo1", "com.acme", "foo1", "0.3.0.RELEASE");
|
||||
dependency1.setVersionRange("1.2.x.RELEASE");
|
||||
dependency1.resolve();
|
||||
assertThat(dependency1.getVersionRange()).isEqualTo("1.2.999.RELEASE");
|
||||
@@ -273,25 +263,22 @@ class DependencyTests {
|
||||
|
||||
@Test
|
||||
void resolveVersionRangeWithX() {
|
||||
Dependency dependency = Dependency.withId("foo1", "com.acme", "foo1",
|
||||
"0.3.0.RELEASE");
|
||||
Dependency dependency = Dependency.withId("foo1", "com.acme", "foo1", "0.3.0.RELEASE");
|
||||
dependency.setVersionRange("[1.1.0.RELEASE, 1.2.x.RELEASE)");
|
||||
dependency.resolve();
|
||||
assertThat(dependency.getVersionRange())
|
||||
.isEqualTo("[1.1.0.RELEASE,1.2.999.RELEASE)");
|
||||
assertThat(dependency.getVersionRange()).isEqualTo("[1.1.0.RELEASE,1.2.999.RELEASE)");
|
||||
}
|
||||
|
||||
private static void validateResolvedWebDependency(Dependency dependency,
|
||||
String expectedGroupId, String expectedArtifactId, String expectedVersion) {
|
||||
validateResolvedDependency(dependency, "web", expectedGroupId, expectedArtifactId,
|
||||
expectedVersion);
|
||||
private static void validateResolvedWebDependency(Dependency dependency, String expectedGroupId,
|
||||
String expectedArtifactId, String expectedVersion) {
|
||||
validateResolvedDependency(dependency, "web", expectedGroupId, expectedArtifactId, expectedVersion);
|
||||
assertThat(dependency.getKeywords()).hasSize(2);
|
||||
assertThat(dependency.getAliases()).hasSize(1);
|
||||
assertThat(dependency.getFacets()).hasSize(1);
|
||||
}
|
||||
|
||||
private static void validateResolvedDependency(Dependency dependency, String id,
|
||||
String expectedGroupId, String expectedArtifactId, String expectedVersion) {
|
||||
private static void validateResolvedDependency(Dependency dependency, String id, String expectedGroupId,
|
||||
String expectedArtifactId, String expectedVersion) {
|
||||
assertThat(dependency.getId()).isEqualTo(id);
|
||||
assertThat(dependency.getGroupId()).isEqualTo(expectedGroupId);
|
||||
assertThat(dependency.getArtifactId()).isEqualTo(expectedArtifactId);
|
||||
|
||||
@@ -33,68 +33,57 @@ class InitializrConfigurationTests {
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimple() {
|
||||
assertThat(this.properties.generateApplicationName("demo"))
|
||||
.isEqualTo("DemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("demo")).isEqualTo("DemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimpleApplication() {
|
||||
assertThat(this.properties.generateApplicationName("demoApplication"))
|
||||
.isEqualTo("DemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("demoApplication")).isEqualTo("DemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimpleCamelCase() {
|
||||
assertThat(this.properties.generateApplicationName("myDemo"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("myDemo")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimpleUnderscore() {
|
||||
assertThat(this.properties.generateApplicationName("my_demo"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("my_demo")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimpleColon() {
|
||||
assertThat(this.properties.generateApplicationName("my:demo"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("my:demo")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimpleSpace() {
|
||||
assertThat(this.properties.generateApplicationName("my demo"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("my demo")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameSimpleDash() {
|
||||
assertThat(this.properties.generateApplicationName("my-demo"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("my-demo")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameUpperCaseUnderscore() {
|
||||
assertThat(this.properties.generateApplicationName("MY_DEMO"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("MY_DEMO")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameUpperCaseDash() {
|
||||
assertThat(this.properties.generateApplicationName("MY-DEMO"))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName("MY-DEMO")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameMultiSpaces() {
|
||||
assertThat(this.properties.generateApplicationName(" my demo "))
|
||||
.isEqualTo("MyDemoApplication");
|
||||
assertThat(this.properties.generateApplicationName(" my demo ")).isEqualTo("MyDemoApplication");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generateApplicationNameMultiSpacesUpperCase() {
|
||||
assertThat("MyDemoApplication")
|
||||
.isEqualTo(this.properties.generateApplicationName(" MY DEMO "));
|
||||
assertThat("MyDemoApplication").isEqualTo(this.properties.generateApplicationName(" MY DEMO "));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,102 +118,85 @@ class InitializrConfigurationTests {
|
||||
|
||||
@Test
|
||||
void generatePackageNameSimple() {
|
||||
assertThat(this.properties.cleanPackageName("com.foo", "com.example"))
|
||||
.isEqualTo("com.foo");
|
||||
assertThat(this.properties.cleanPackageName("com.foo", "com.example")).isEqualTo("com.foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameSimpleUnderscore() {
|
||||
assertThat(this.properties.cleanPackageName("com.my_foo", "com.example"))
|
||||
.isEqualTo("com.my_foo");
|
||||
assertThat(this.properties.cleanPackageName("com.my_foo", "com.example")).isEqualTo("com.my_foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameSimpleColon() {
|
||||
assertThat(this.properties.cleanPackageName("com:foo", "com.example"))
|
||||
.isEqualTo("com.foo");
|
||||
assertThat(this.properties.cleanPackageName("com:foo", "com.example")).isEqualTo("com.foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameMultipleDashers() {
|
||||
assertThat(this.properties.cleanPackageName("com.foo--bar", "com.example"))
|
||||
.isEqualTo("com.foobar");
|
||||
assertThat(this.properties.cleanPackageName("com.foo--bar", "com.example")).isEqualTo("com.foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameMultipleSpaces() {
|
||||
assertThat(this.properties.cleanPackageName(" com foo ", "com.example"))
|
||||
.isEqualTo("com.foo");
|
||||
assertThat(this.properties.cleanPackageName(" com foo ", "com.example")).isEqualTo("com.foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameNull() {
|
||||
assertThat(this.properties.cleanPackageName(null, "com.example"))
|
||||
.isEqualTo("com.example");
|
||||
assertThat(this.properties.cleanPackageName(null, "com.example")).isEqualTo("com.example");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameDot() {
|
||||
assertThat(this.properties.cleanPackageName(".", "com.example"))
|
||||
.isEqualTo("com.example");
|
||||
assertThat(this.properties.cleanPackageName(".", "com.example")).isEqualTo("com.example");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameWhitespaces() {
|
||||
assertThat(this.properties.cleanPackageName(" ", "com.example"))
|
||||
.isEqualTo("com.example");
|
||||
assertThat(this.properties.cleanPackageName(" ", "com.example")).isEqualTo("com.example");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameInvalidStartCharacter() {
|
||||
assertThat(this.properties.cleanPackageName("0com.foo", "com.example"))
|
||||
.isEqualTo("com.foo");
|
||||
assertThat(this.properties.cleanPackageName("0com.foo", "com.example")).isEqualTo("com.foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameVersion() {
|
||||
assertThat(this.properties.cleanPackageName("com.foo.test-1.4.5", "com.example"))
|
||||
.isEqualTo("com.foo.test145");
|
||||
assertThat(this.properties.cleanPackageName("com.foo.test-1.4.5", "com.example")).isEqualTo("com.foo.test145");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePackageNameInvalidPackageName() {
|
||||
assertThat(this.properties.cleanPackageName("org.springframework", "com.example"))
|
||||
.isEqualTo("com.example");
|
||||
assertThat(this.properties.cleanPackageName("org.springframework", "com.example")).isEqualTo("com.example");
|
||||
}
|
||||
|
||||
@Test
|
||||
void validateArtifactRepository() {
|
||||
this.properties.getEnv().setArtifactRepository("http://foo/bar");
|
||||
assertThat(this.properties.getEnv().getArtifactRepository())
|
||||
.isEqualTo("http://foo/bar/");
|
||||
assertThat(this.properties.getEnv().getArtifactRepository()).isEqualTo("http://foo/bar/");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveKotlinVersionMatchingMapping() {
|
||||
Kotlin kotlin = this.properties.getEnv().getKotlin();
|
||||
kotlin.setDefaultVersion("1.2.3");
|
||||
kotlin.getMappings()
|
||||
.add(createKotlinVersionMapping("[1.4.0.RELEASE,1.5.0.RELEASE)", "1.5"));
|
||||
kotlin.getMappings().add(createKotlinVersionMapping("[1.4.0.RELEASE,1.5.0.RELEASE)", "1.5"));
|
||||
kotlin.getMappings().add(createKotlinVersionMapping("1.5.0.RELEASE", "1.6"));
|
||||
kotlin.validate();
|
||||
assertThat(kotlin.resolveKotlinVersion(Version.parse("1.5.3.RELEASE")))
|
||||
.isEqualTo("1.6");
|
||||
assertThat(kotlin.resolveKotlinVersion(Version.parse("1.5.3.RELEASE"))).isEqualTo("1.6");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveKotlinVersionUsingDefault() {
|
||||
Kotlin kotlin = this.properties.getEnv().getKotlin();
|
||||
kotlin.setDefaultVersion("1.2.3");
|
||||
kotlin.getMappings()
|
||||
.add(createKotlinVersionMapping("[1.4.0.RELEASE,1.5.0.RELEASE)", "1.5"));
|
||||
kotlin.getMappings().add(createKotlinVersionMapping("[1.4.0.RELEASE,1.5.0.RELEASE)", "1.5"));
|
||||
kotlin.validate();
|
||||
assertThat(kotlin.resolveKotlinVersion(Version.parse("1.3.2.RELEASE")))
|
||||
.isEqualTo("1.2.3");
|
||||
assertThat(kotlin.resolveKotlinVersion(Version.parse("1.3.2.RELEASE"))).isEqualTo("1.2.3");
|
||||
}
|
||||
|
||||
private Kotlin.Mapping createKotlinVersionMapping(String versionRange,
|
||||
String kotlinVersion) {
|
||||
private Kotlin.Mapping createKotlinVersionMapping(String versionRange, String kotlinVersion) {
|
||||
Kotlin.Mapping mapping = new Kotlin.Mapping();
|
||||
mapping.setVersionRange(versionRange);
|
||||
mapping.setVersion(kotlinVersion);
|
||||
|
||||
@@ -40,31 +40,24 @@ class InitializrMetadataBuilderTests {
|
||||
|
||||
@Test
|
||||
void loadDefaultConfig() {
|
||||
InitializrProperties bean = load(
|
||||
new ClassPathResource("application-test-default.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder
|
||||
.fromInitializrProperties(bean).build();
|
||||
InitializrProperties bean = load(new ClassPathResource("application-test-default.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(bean).build();
|
||||
assertDefaultConfig(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mergeIdenticalConfig() {
|
||||
InitializrProperties bean = load(
|
||||
new ClassPathResource("application-test-default.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder
|
||||
.fromInitializrProperties(bean).withInitializrProperties(bean, true)
|
||||
.build();
|
||||
InitializrProperties bean = load(new ClassPathResource("application-test-default.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(bean)
|
||||
.withInitializrProperties(bean, true).build();
|
||||
assertDefaultConfig(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mergeConfig() {
|
||||
InitializrProperties config = load(
|
||||
new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties customDefaultsConfig = load(
|
||||
new ClassPathResource("application-test-custom-defaults.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder
|
||||
.fromInitializrProperties(config)
|
||||
InitializrProperties config = load(new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties customDefaultsConfig = load(new ClassPathResource("application-test-custom-defaults.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(config)
|
||||
.withInitializrProperties(customDefaultsConfig).build();
|
||||
assertDefaultConfig(metadata);
|
||||
assertThat(metadata.getGroupId().getContent()).isEqualTo("org.foo");
|
||||
@@ -78,9 +71,7 @@ class InitializrMetadataBuilderTests {
|
||||
@Test
|
||||
void mergeMetadata() {
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.create()
|
||||
.withInitializrMetadata(
|
||||
new ClassPathResource("metadata/config/test-min.json"))
|
||||
.build();
|
||||
.withInitializrMetadata(new ClassPathResource("metadata/config/test-min.json")).build();
|
||||
assertThat(metadata.getConfiguration().getEnv().isForceSsl()).isEqualTo(true);
|
||||
assertThat(metadata.getDependencies().getContent()).hasSize(1);
|
||||
Dependency dependency = metadata.getDependencies().get("test");
|
||||
@@ -92,8 +83,7 @@ class InitializrMetadataBuilderTests {
|
||||
assertThat(metadata.getJavaVersions().getContent()).hasSize(1);
|
||||
assertThat(metadata.getLanguages().getContent()).hasSize(3);
|
||||
assertThat(metadata.getName().getContent()).isEqualTo("metadata-merge");
|
||||
assertThat(metadata.getDescription().getContent())
|
||||
.isEqualTo("Demo project for metadata merge");
|
||||
assertThat(metadata.getDescription().getContent()).isEqualTo("Demo project for metadata merge");
|
||||
assertThat(metadata.getGroupId().getContent()).isEqualTo("org.acme");
|
||||
assertThat(metadata.getArtifactId().getContent()).isEqualTo("metadata");
|
||||
assertThat(metadata.getVersion().getContent()).isEqualTo("1.0.0-SNAPSHOT");
|
||||
@@ -103,12 +93,9 @@ class InitializrMetadataBuilderTests {
|
||||
@Test
|
||||
void mergeMetadataWithBom() {
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.create()
|
||||
.withInitializrMetadata(
|
||||
new ClassPathResource("metadata/config/test-bom.json"))
|
||||
.build();
|
||||
.withInitializrMetadata(new ClassPathResource("metadata/config/test-bom.json")).build();
|
||||
|
||||
Map<String, BillOfMaterials> boms = metadata.getConfiguration().getEnv()
|
||||
.getBoms();
|
||||
Map<String, BillOfMaterials> boms = metadata.getConfiguration().getEnv().getBoms();
|
||||
assertThat(boms).hasSize(2);
|
||||
BillOfMaterials myBom = boms.get("my-bom");
|
||||
assertThat(myBom).isNotNull();
|
||||
@@ -126,12 +113,9 @@ class InitializrMetadataBuilderTests {
|
||||
@Test
|
||||
void mergeMetadataWithRepository() throws Exception {
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.create()
|
||||
.withInitializrMetadata(
|
||||
new ClassPathResource("metadata/config/test-repository.json"))
|
||||
.build();
|
||||
.withInitializrMetadata(new ClassPathResource("metadata/config/test-repository.json")).build();
|
||||
|
||||
Map<String, Repository> repositories = metadata.getConfiguration().getEnv()
|
||||
.getRepositories();
|
||||
Map<String, Repository> repositories = metadata.getConfiguration().getEnv().getRepositories();
|
||||
assertThat(repositories).hasSize(4); // 2 standard repos
|
||||
Repository myRepo = repositories.get("my-repo");
|
||||
assertThat(myRepo).isNotNull();
|
||||
@@ -148,53 +132,38 @@ class InitializrMetadataBuilderTests {
|
||||
|
||||
@Test
|
||||
void mergeConfigurationDisabledByDefault() {
|
||||
InitializrProperties config = load(
|
||||
new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties customDefaultsConfig = load(
|
||||
new ClassPathResource("application-test-custom-env.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder
|
||||
.fromInitializrProperties(config)
|
||||
InitializrProperties config = load(new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties customDefaultsConfig = load(new ClassPathResource("application-test-custom-env.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(config)
|
||||
.withInitializrProperties(customDefaultsConfig).build();
|
||||
InitializrConfiguration.Env defaultEnv = new InitializrConfiguration().getEnv();
|
||||
InitializrConfiguration.Env actualEnv = metadata.getConfiguration().getEnv();
|
||||
assertThat(actualEnv.getArtifactRepository())
|
||||
.isEqualTo(defaultEnv.getArtifactRepository());
|
||||
assertThat(actualEnv.getSpringBootMetadataUrl())
|
||||
.isEqualTo(defaultEnv.getSpringBootMetadataUrl());
|
||||
assertThat(actualEnv.getFallbackApplicationName())
|
||||
.isEqualTo(defaultEnv.getFallbackApplicationName());
|
||||
assertThat(actualEnv.getArtifactRepository()).isEqualTo(defaultEnv.getArtifactRepository());
|
||||
assertThat(actualEnv.getSpringBootMetadataUrl()).isEqualTo(defaultEnv.getSpringBootMetadataUrl());
|
||||
assertThat(actualEnv.getFallbackApplicationName()).isEqualTo(defaultEnv.getFallbackApplicationName());
|
||||
assertThat(actualEnv.isForceSsl()).isEqualTo(defaultEnv.isForceSsl());
|
||||
}
|
||||
|
||||
@Test
|
||||
void mergeConfiguration() {
|
||||
InitializrProperties config = load(
|
||||
new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties customDefaultsConfig = load(
|
||||
new ClassPathResource("application-test-custom-env.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder
|
||||
.fromInitializrProperties(config)
|
||||
InitializrProperties config = load(new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties customDefaultsConfig = load(new ClassPathResource("application-test-custom-env.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(config)
|
||||
.withInitializrProperties(customDefaultsConfig, true).build();
|
||||
InitializrConfiguration.Env defaultEnv = new InitializrConfiguration().getEnv();
|
||||
InitializrConfiguration.Env actualEnv = metadata.getConfiguration().getEnv();
|
||||
assertThat(actualEnv.getArtifactRepository())
|
||||
.isEqualTo("https://repo.spring.io/lib-release/");
|
||||
assertThat(actualEnv.getSpringBootMetadataUrl())
|
||||
.isEqualTo(defaultEnv.getSpringBootMetadataUrl());
|
||||
assertThat(actualEnv.getArtifactRepository()).isEqualTo("https://repo.spring.io/lib-release/");
|
||||
assertThat(actualEnv.getSpringBootMetadataUrl()).isEqualTo(defaultEnv.getSpringBootMetadataUrl());
|
||||
assertThat(actualEnv.getFallbackApplicationName()).isEqualTo("FooBarApplication");
|
||||
assertThat(actualEnv.isForceSsl()).isEqualTo(false);
|
||||
assertThat(actualEnv.getKotlin().getDefaultVersion())
|
||||
.isEqualTo("1.0.0-beta-2423");
|
||||
assertThat(actualEnv.getKotlin().getDefaultVersion()).isEqualTo("1.0.0-beta-2423");
|
||||
}
|
||||
|
||||
@Test
|
||||
void mergeSslConfiguration() {
|
||||
InitializrProperties config = load(
|
||||
new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties forceSslConfig = load(
|
||||
new ClassPathResource("application-test-ssl.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder
|
||||
.fromInitializrProperties(config)
|
||||
InitializrProperties config = load(new ClassPathResource("application-test-default.yml"));
|
||||
InitializrProperties forceSslConfig = load(new ClassPathResource("application-test-ssl.yml"));
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.fromInitializrProperties(config)
|
||||
.withInitializrProperties(forceSslConfig, true).build();
|
||||
InitializrConfiguration.Env actualEnv = metadata.getConfiguration().getEnv();
|
||||
assertThat(actualEnv.isForceSsl()).isEqualTo(true);
|
||||
@@ -206,8 +175,7 @@ class InitializrMetadataBuilderTests {
|
||||
Dependency dependency = Dependency.withId("com.foo:foo:1.0.0");
|
||||
group.getContent().add(dependency);
|
||||
InitializrMetadata metadata = InitializrMetadataBuilder.create()
|
||||
.withCustomizer((m) -> m.getDependencies().getContent().add(group))
|
||||
.build();
|
||||
.withCustomizer((m) -> m.getDependencies().getContent().add(group)).build();
|
||||
assertThat(metadata.getDependencies().getContent()).hasSize(1);
|
||||
assertThat(metadata.getDependencies().getContent().get(0)).isEqualTo(group);
|
||||
}
|
||||
@@ -220,8 +188,7 @@ class InitializrMetadataBuilderTests {
|
||||
}
|
||||
|
||||
private static InitializrProperties load(Resource resource) {
|
||||
ConfigurationPropertySource source = new MapConfigurationPropertySource(
|
||||
loadProperties(resource));
|
||||
ConfigurationPropertySource source = new MapConfigurationPropertySource(loadProperties(resource));
|
||||
Binder binder = new Binder(source);
|
||||
return binder.bind("initializr", InitializrProperties.class).get();
|
||||
}
|
||||
|
||||
@@ -45,9 +45,8 @@ class InitializrMetadataTests {
|
||||
addTestDependencyGroup(metadata, foo);
|
||||
metadata.getConfiguration().getEnv().getBoms().put("my-bom",
|
||||
BillOfMaterials.create("org.acme", "foo", "1.2.3"));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate).withMessageContaining("foo-bom")
|
||||
.withMessageContaining("my-bom");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("foo-bom").withMessageContaining("my-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,48 +57,38 @@ class InitializrMetadataTests {
|
||||
addTestDependencyGroup(metadata, foo);
|
||||
metadata.getConfiguration().getEnv().getRepositories().put("my-repo",
|
||||
new Repository("repo", new URL("http://example.com/repo"), true));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate).withMessageContaining("foo-repo")
|
||||
.withMessageContaining("my-repo");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("foo-repo").withMessageContaining("my-repo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidBomNoVersion() {
|
||||
InitializrMetadata metadata = initializeMetadata();
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom",
|
||||
BillOfMaterials.create("org.acme", "foo-bom"));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate).withMessageContaining("No version")
|
||||
.withMessageContaining("foo-bom");
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", BillOfMaterials.create("org.acme", "foo-bom"));
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("No version").withMessageContaining("foo-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidBomUnknownRepository() {
|
||||
InitializrMetadata metadata = initializeMetadata();
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom",
|
||||
"1.0.0.RELEASE");
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom", "1.0.0.RELEASE");
|
||||
bom.getRepositories().add("foo-repo");
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid repository id foo-repo")
|
||||
.withMessageContaining("foo-bom");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid repository id foo-repo").withMessageContaining("foo-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
void invalidBomUnknownAdditionalBom() {
|
||||
InitializrMetadata metadata = initializeMetadata();
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom",
|
||||
"1.0.0.RELEASE");
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom", "1.0.0.RELEASE");
|
||||
bom.getAdditionalBoms().addAll(Arrays.asList("bar-bom", "biz-bom"));
|
||||
BillOfMaterials barBom = BillOfMaterials.create("org.acme", "bar-bom",
|
||||
"1.0.0.RELEASE");
|
||||
BillOfMaterials barBom = BillOfMaterials.create("org.acme", "bar-bom", "1.0.0.RELEASE");
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom);
|
||||
metadata.getConfiguration().getEnv().getBoms().put("bar-bom", barBom);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid additional bom")
|
||||
.withMessageContaining("biz-bom");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid additional bom").withMessageContaining("biz-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,9 +98,8 @@ class InitializrMetadataTests {
|
||||
bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.0.0"));
|
||||
bom.getMappings().add(Mapping.create("FOO_BAR", "1.2.0"));
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate).withMessageContaining("FOO_BAR")
|
||||
.withMessageContaining("foo-bom");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("FOO_BAR").withMessageContaining("foo-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,10 +111,9 @@ class InitializrMetadataTests {
|
||||
mapping.getRepositories().add("foo-repo");
|
||||
bom.getMappings().add(mapping);
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid repository id foo-repo")
|
||||
.withMessageContaining("1.3.0.M2").withMessageContaining("foo-bom");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid repository id foo-repo").withMessageContaining("1.3.0.M2")
|
||||
.withMessageContaining("foo-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,10 +125,9 @@ class InitializrMetadataTests {
|
||||
mapping.getAdditionalBoms().add("bar-bom");
|
||||
bom.getMappings().add(mapping);
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid additional bom")
|
||||
.withMessageContaining("1.3.0.M2").withMessageContaining("bar-bom");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("invalid additional bom").withMessageContaining("1.3.0.M2")
|
||||
.withMessageContaining("bar-bom");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -149,42 +135,34 @@ class InitializrMetadataTests {
|
||||
InitializrMetadata metadata = initializeMetadata();
|
||||
BillOfMaterials bom = BillOfMaterials.create("org.acme", "foo-bom");
|
||||
bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.x.RELEASE]", "1.0.0"));
|
||||
bom.getMappings()
|
||||
.add(Mapping.create("1.3.x.BUILD-SNAPSHOT", "1.1.0-BUILD-SNAPSHOT"));
|
||||
bom.getMappings().add(Mapping.create("1.3.x.BUILD-SNAPSHOT", "1.1.0-BUILD-SNAPSHOT"));
|
||||
Dependency dependency = Dependency.withId("bar");
|
||||
dependency.getMappings().add(Dependency.Mapping
|
||||
.create("[1.3.0.RELEASE, 1.3.x.RELEASE]", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings().add(Dependency.Mapping.create("1.3.x.BUILD-SNAPSHOT",
|
||||
null, null, "0.2.0.RELEASE"));
|
||||
dependency.getMappings()
|
||||
.add(Dependency.Mapping.create("[1.3.0.RELEASE, 1.3.x.RELEASE]", null, null, "0.1.0.RELEASE"));
|
||||
dependency.getMappings().add(Dependency.Mapping.create("1.3.x.BUILD-SNAPSHOT", null, null, "0.2.0.RELEASE"));
|
||||
|
||||
addTestDependencyGroup(metadata, dependency);
|
||||
metadata.getConfiguration().getEnv().getBoms().put("foo-bom", bom);
|
||||
Kotlin kotlin = metadata.getConfiguration().getEnv().getKotlin();
|
||||
kotlin.setDefaultVersion("1.3");
|
||||
kotlin.getMappings()
|
||||
.add(createKotlinVersionMapping("[1.2.0.RELEASE,1.3.x.RELEASE]", "1.1"));
|
||||
kotlin.getMappings()
|
||||
.add(createKotlinVersionMapping("1.3.x.BUILD-SNAPSHOT", "1.2"));
|
||||
kotlin.getMappings().add(createKotlinVersionMapping("[1.2.0.RELEASE,1.3.x.RELEASE]", "1.1"));
|
||||
kotlin.getMappings().add(createKotlinVersionMapping("1.3.x.BUILD-SNAPSHOT", "1.2"));
|
||||
metadata.validate();
|
||||
|
||||
List<DefaultMetadataElement> bootVersions = Arrays.asList(
|
||||
DefaultMetadataElement.create("1.3.6.RELEASE", "1.3.6", false),
|
||||
DefaultMetadataElement.create("1.3.7.BUILD-SNAPSHOT", "1.3.7", false));
|
||||
metadata.updateSpringBootVersions(bootVersions);
|
||||
assertThat(metadata.getConfiguration().getEnv().getBoms().get("foo-bom").resolve(Version.parse("1.3.6.RELEASE"))
|
||||
.getVersion()).isEqualTo("1.0.0");
|
||||
assertThat(metadata.getConfiguration().getEnv().getBoms().get("foo-bom")
|
||||
.resolve(Version.parse("1.3.6.RELEASE")).getVersion()).isEqualTo("1.0.0");
|
||||
assertThat(metadata.getConfiguration().getEnv().getBoms().get("foo-bom")
|
||||
.resolve(Version.parse("1.3.7.BUILD-SNAPSHOT")).getVersion())
|
||||
.isEqualTo("1.1.0-BUILD-SNAPSHOT");
|
||||
assertThat(metadata.getDependencies().get("bar")
|
||||
.resolve(Version.parse("1.3.6.RELEASE")).getVersion())
|
||||
.isEqualTo("0.1.0.RELEASE");
|
||||
assertThat(metadata.getDependencies().get("bar")
|
||||
.resolve(Version.parse("1.3.7.BUILD-SNAPSHOT")).getVersion())
|
||||
.isEqualTo("0.2.0.RELEASE");
|
||||
.resolve(Version.parse("1.3.7.BUILD-SNAPSHOT")).getVersion()).isEqualTo("1.1.0-BUILD-SNAPSHOT");
|
||||
assertThat(metadata.getDependencies().get("bar").resolve(Version.parse("1.3.6.RELEASE")).getVersion())
|
||||
.isEqualTo("0.1.0.RELEASE");
|
||||
assertThat(metadata.getDependencies().get("bar").resolve(Version.parse("1.3.7.BUILD-SNAPSHOT")).getVersion())
|
||||
.isEqualTo("0.2.0.RELEASE");
|
||||
assertThat(metadata.getConfiguration().getEnv().getKotlin()
|
||||
.resolveKotlinVersion(Version.parse("1.3.7.BUILD-SNAPSHOT")))
|
||||
.isEqualTo("1.2");
|
||||
.resolveKotlinVersion(Version.parse("1.3.7.BUILD-SNAPSHOT"))).isEqualTo("1.2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,9 +171,8 @@ class InitializrMetadataTests {
|
||||
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");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(metadata::validate)
|
||||
.withMessageContaining("Custom maven pom requires groupId, artifactId and version");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -215,8 +192,7 @@ class InitializrMetadataTests {
|
||||
return new InitializrMetadata();
|
||||
}
|
||||
|
||||
private void addTestDependencyGroup(InitializrMetadata metadata,
|
||||
Dependency... dependencies) {
|
||||
private void addTestDependencyGroup(InitializrMetadata metadata, Dependency... dependencies) {
|
||||
DependencyGroup group = DependencyGroup.create("test");
|
||||
for (Dependency dependency : dependencies) {
|
||||
group.getContent().add(dependency);
|
||||
@@ -224,8 +200,7 @@ class InitializrMetadataTests {
|
||||
metadata.getDependencies().getContent().add(group);
|
||||
}
|
||||
|
||||
private Kotlin.Mapping createKotlinVersionMapping(String versionRange,
|
||||
String kotlinVersion) {
|
||||
private Kotlin.Mapping createKotlinVersionMapping(String versionRange, String kotlinVersion) {
|
||||
Kotlin.Mapping mapping = new Kotlin.Mapping();
|
||||
mapping.setVersionRange(versionRange);
|
||||
mapping.setVersion(kotlinVersion);
|
||||
|
||||
@@ -38,15 +38,13 @@ class LinkTests {
|
||||
void resolveInvalidLinkNoRel() {
|
||||
Link link = new Link();
|
||||
link.setHref("https://example.com");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(link::resolve);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(link::resolve);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveInvalidLinkNoHref() {
|
||||
Link link = Link.create("reference", null, "foo doc");
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class)
|
||||
.isThrownBy(link::resolve);
|
||||
assertThatExceptionOfType(InvalidInitializrMetadataException.class).isThrownBy(link::resolve);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,8 +70,7 @@ class LinkTests {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("a", "test");
|
||||
map.put("b", "another");
|
||||
assertThat(link.expand(map))
|
||||
.isEqualTo(new URI("https://example.com/test/2/another"));
|
||||
assertThat(link.expand(map)).isEqualTo(new URI("https://example.com/test/2/another"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,16 +80,14 @@ class LinkTests {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("a", "test");
|
||||
map.put("b", "another");
|
||||
assertThat(link.expand(map))
|
||||
.isEqualTo(new URI("https://example.com/test/2/test"));
|
||||
assertThat(link.expand(map)).isEqualTo(new URI("https://example.com/test/2/test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void expandLinkMissingVariable() {
|
||||
Link link = Link.create("reference", "https://example.com/{a}/2/{b}");
|
||||
link.resolve();
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> link.expand(Collections.singletonMap("a", "test")))
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> link.expand(Collections.singletonMap("a", "test")))
|
||||
.withMessageContaining("missing value for 'b'");
|
||||
}
|
||||
|
||||
|
||||
@@ -45,14 +45,11 @@ class MetadataBuildItemResolverTests {
|
||||
void resoleDependencyWithMatchingEntry() {
|
||||
InitializrMetadata metadata = new InitializrMetadata();
|
||||
DependencyGroup group = DependencyGroup.create("test");
|
||||
group.getContent().add(
|
||||
Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime"));
|
||||
group.getContent().add(Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime"));
|
||||
metadata.getDependencies().getContent().add(group);
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.Dependency dependency = resolver
|
||||
.resolveDependency("test-dep");
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.Dependency dependency = resolver.resolveDependency("test-dep");
|
||||
assertThat(dependency.getGroupId()).isEqualTo("com.example");
|
||||
assertThat(dependency.getArtifactId()).isEqualTo("test");
|
||||
assertThat(dependency.getVersion()).hasToString("1.0.0");
|
||||
@@ -64,15 +61,12 @@ class MetadataBuildItemResolverTests {
|
||||
InitializrMetadata metadata = new InitializrMetadata();
|
||||
DependencyGroup group = DependencyGroup.create("test");
|
||||
Dependency dependency = Dependency.withId("test-dep", "com.example", "test");
|
||||
dependency.getMappings().add(Mapping.create("[1.0.0.RELEASE, 2.0.0.RELEASE)",
|
||||
null, null, "1.0.0.RELEASE"));
|
||||
dependency.getMappings().add(Mapping.create("2.0.0.RELEASE",
|
||||
"com.example.override", "test-override", null));
|
||||
dependency.getMappings().add(Mapping.create("[1.0.0.RELEASE, 2.0.0.RELEASE)", null, null, "1.0.0.RELEASE"));
|
||||
dependency.getMappings().add(Mapping.create("2.0.0.RELEASE", "com.example.override", "test-override", null));
|
||||
group.getContent().add(dependency);
|
||||
metadata.getDependencies().getContent().add(group);
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.Dependency resolveDependency = resolver
|
||||
.resolveDependency("test-dep");
|
||||
assertThat(resolveDependency.getGroupId()).isEqualTo("com.example.override");
|
||||
@@ -85,12 +79,10 @@ class MetadataBuildItemResolverTests {
|
||||
void resoleDependencyWithNotMatchingEntry() {
|
||||
InitializrMetadata metadata = new InitializrMetadata();
|
||||
DependencyGroup group = DependencyGroup.create("test");
|
||||
group.getContent().add(
|
||||
Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime"));
|
||||
group.getContent().add(Dependency.withId("test-dep", "com.example", "test", "1.0.0", "runtime"));
|
||||
metadata.getDependencies().getContent().add(group);
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
assertThat(resolver.resolveDependency("does-not-exist")).isNull();
|
||||
}
|
||||
|
||||
@@ -100,10 +92,8 @@ class MetadataBuildItemResolverTests {
|
||||
BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "2.0.0");
|
||||
metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom);
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver
|
||||
.resolveBom("test-bom");
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver.resolveBom("test-bom");
|
||||
assertThat(resolvedBom.getGroupId()).isEqualTo("com.example");
|
||||
assertThat(resolvedBom.getArtifactId()).isEqualTo("bom");
|
||||
assertThat(resolvedBom.getVersion()).hasToString("2.0.0");
|
||||
@@ -113,17 +103,14 @@ class MetadataBuildItemResolverTests {
|
||||
void resoleBomWithMatchingEntryAndVersionRange() throws MalformedURLException {
|
||||
InitializrMetadata metadata = new InitializrMetadata();
|
||||
BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "0.0.1");
|
||||
bom.getMappings().add(BillOfMaterials.Mapping
|
||||
.create("[1.0.0.RELEASE, 2.0.0.RELEASE)", "1.0.0"));
|
||||
bom.getMappings().add(BillOfMaterials.Mapping.create("[1.0.0.RELEASE, 2.0.0.RELEASE)", "1.0.0"));
|
||||
bom.getMappings().add(BillOfMaterials.Mapping.create("2.0.0.RELEASE", "1.1.0"));
|
||||
metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom);
|
||||
metadata.getConfiguration().getEnv().getRepositories().put("test-repo",
|
||||
new Repository("test", new URL("https://example.com/repo"), false));
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver
|
||||
.resolveBom("test-bom");
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
io.spring.initializr.generator.buildsystem.BillOfMaterials resolvedBom = resolver.resolveBom("test-bom");
|
||||
assertThat(resolvedBom.getGroupId()).isEqualTo("com.example");
|
||||
assertThat(resolvedBom.getArtifactId()).isEqualTo("bom");
|
||||
assertThat(resolvedBom.getVersion()).hasToString("1.1.0");
|
||||
@@ -135,8 +122,7 @@ class MetadataBuildItemResolverTests {
|
||||
BillOfMaterials bom = BillOfMaterials.create("com.example", "bom", "2.0.0");
|
||||
metadata.getConfiguration().getEnv().getBoms().put("test-bom", bom);
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
assertThat(resolver.resolveBom("does-not-exost")).isNull();
|
||||
}
|
||||
|
||||
@@ -146,8 +132,7 @@ class MetadataBuildItemResolverTests {
|
||||
metadata.getConfiguration().getEnv().getRepositories().put("test-repo",
|
||||
new Repository("test", new URL("https://example.com/repo"), false));
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
MavenRepository repository = resolver.resolveRepository("test-repo");
|
||||
assertThat(repository.getId()).isEqualTo("test-repo");
|
||||
assertThat(repository.getName()).isEqualTo("test");
|
||||
@@ -161,8 +146,7 @@ class MetadataBuildItemResolverTests {
|
||||
metadata.getConfiguration().getEnv().getRepositories().put("test-repo",
|
||||
new Repository("test", new URL("https://example.com/repo"), false));
|
||||
metadata.validate();
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata,
|
||||
VERSION_2_0_0);
|
||||
MetadataBuildItemResolver resolver = new MetadataBuildItemResolver(metadata, VERSION_2_0_0);
|
||||
assertThat(resolver.resolveRepository("does-not-exist")).isNull();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user