mirror of
https://gitee.com/dcren/initializr.git
synced 2025-04-05 17:38:06 +08:00
Fix registration of additional repository with SemVer versions
Closes gh-1091
This commit is contained in:
parent
01a6f92047
commit
1bfa7f6f47
@ -44,11 +44,13 @@ class SpringBootVersionRepositoriesBuildCustomizer implements BuildCustomizer<Bu
|
||||
@Override
|
||||
public void customize(Build build) {
|
||||
build.repositories().add("maven-central");
|
||||
String qualifier = this.springBootVersion.getQualifier().getId();
|
||||
if (!"RELEASE".equals(qualifier)) {
|
||||
addMilestoneRepository(build);
|
||||
if ("BUILD-SNAPSHOT".equals(qualifier)) {
|
||||
addSnapshotRepository(build);
|
||||
if (this.springBootVersion.getQualifier() != null) {
|
||||
String qualifier = this.springBootVersion.getQualifier().getId();
|
||||
if (!qualifier.equals("RELEASE")) {
|
||||
addMilestoneRepository(build);
|
||||
if (qualifier.contains("SNAPSHOT")) {
|
||||
addSnapshotRepository(build);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -40,6 +40,13 @@ class SpringBootVersionRepositoriesBuildCustomizerTests {
|
||||
assertThat(build.repositories().items()).containsExactly(MavenRepository.MAVEN_CENTRAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralWhenUsingSemVerRelease() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
new SpringBootVersionRepositoriesBuildCustomizer(Version.parse("2.1.0")).customize(build);
|
||||
assertThat(build.repositories().items()).containsExactly(MavenRepository.MAVEN_CENTRAL);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndMilestonesWhenUsingMilestone() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
@ -47,6 +54,13 @@ class SpringBootVersionRepositoriesBuildCustomizerTests {
|
||||
assertMavenCentralAndMilestonesRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndMilestonesWhenUsingSemVerMilestone() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
new SpringBootVersionRepositoriesBuildCustomizer(Version.parse("2.1.0-M1")).customize(build);
|
||||
assertMavenCentralAndMilestonesRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndMilestonesWhenUsingReleaseCandidate() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
@ -54,6 +68,13 @@ class SpringBootVersionRepositoriesBuildCustomizerTests {
|
||||
assertMavenCentralAndMilestonesRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndMilestonesWhenUsingSemVerReleaseCandidate() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
new SpringBootVersionRepositoriesBuildCustomizer(Version.parse("2.1.0-RC1")).customize(build);
|
||||
assertMavenCentralAndMilestonesRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndNonReleaseWhenUsingSnapshot() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
@ -61,6 +82,13 @@ class SpringBootVersionRepositoriesBuildCustomizerTests {
|
||||
assertNonReleaseRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndNonReleaseWhenUsingSemVerSnapshot() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
new SpringBootVersionRepositoriesBuildCustomizer(Version.parse("2.1.0-SNAPSHOT")).customize(build);
|
||||
assertNonReleaseRepositories(build);
|
||||
}
|
||||
|
||||
private void assertNonReleaseRepositories(MavenBuild build) {
|
||||
List<MavenRepository> repositories = build.repositories().items().collect(Collectors.toList());
|
||||
assertThat(repositories).hasSize(3);
|
||||
|
Loading…
Reference in New Issue
Block a user