mirror of
https://gitee.com/dcren/initializr.git
synced 2025-05-12 00:28:07 +08:00
Do not add snapshot repo unless absolutely necessary
See gh-960
This commit is contained in:
parent
e0dfac1a77
commit
c54ec295bf
@ -39,16 +39,17 @@ class SpringBootVersionRepositoriesBuildCustomizer implements BuildCustomizer<Bu
|
||||
build.repositories().add("maven-central");
|
||||
String qualifier = this.springBootVersion.getQualifier().getQualifier();
|
||||
if (!"RELEASE".equals(qualifier)) {
|
||||
MavenRepository snapshotRepository = new MavenRepository("spring-snapshots", "Spring Snapshots",
|
||||
"https://repo.spring.io/snapshot", true);
|
||||
build.repositories().add(snapshotRepository);
|
||||
build.pluginRepositories().add(snapshotRepository);
|
||||
if ("BUILD-SNAPSHOT".equals(qualifier)) {
|
||||
MavenRepository snapshotRepository = new MavenRepository("spring-snapshots", "Spring Snapshots",
|
||||
"https://repo.spring.io/snapshot", true);
|
||||
build.repositories().add(snapshotRepository);
|
||||
build.pluginRepositories().add(snapshotRepository);
|
||||
}
|
||||
MavenRepository milestoneRepository = new MavenRepository("spring-milestones", "Spring Milestones",
|
||||
"https://repo.spring.io/milestone");
|
||||
build.repositories().add(milestoneRepository);
|
||||
build.pluginRepositories().add(milestoneRepository);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,17 +41,17 @@ class SpringBootVersionRepositoriesBuildCustomizerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndNonReleaseWhenUsingMilestone() {
|
||||
void addMavenCentralAndMilestonesWhenUsingMilestone() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
new SpringBootVersionRepositoriesBuildCustomizer(Version.parse("2.1.0.M1")).customize(build);
|
||||
assertNonReleaseRepositories(build);
|
||||
assertMavenCentralAndMilestonesRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
void addMavenCentralAndNonReleaseWhenUsingReleaseCandidate() {
|
||||
void addMavenCentralAndMilestonesWhenUsingReleaseCandidate() {
|
||||
MavenBuild build = new MavenBuild();
|
||||
new SpringBootVersionRepositoriesBuildCustomizer(Version.parse("2.1.0.RC1")).customize(build);
|
||||
assertNonReleaseRepositories(build);
|
||||
assertMavenCentralAndMilestonesRepositories(build);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -75,4 +75,14 @@ class SpringBootVersionRepositoriesBuildCustomizerTests {
|
||||
.hasFieldOrPropertyWithValue("snapshotsEnabled", false);
|
||||
}
|
||||
|
||||
private void assertMavenCentralAndMilestonesRepositories(MavenBuild build) {
|
||||
List<MavenRepository> repositories = build.repositories().items().collect(Collectors.toList());
|
||||
assertThat(repositories).hasSize(2);
|
||||
assertThat(repositories.get(0)).isEqualTo(MavenRepository.MAVEN_CENTRAL);
|
||||
assertThat(repositories.get(1)).hasFieldOrPropertyWithValue("id", "spring-milestones")
|
||||
.hasFieldOrPropertyWithValue("name", "Spring Milestones")
|
||||
.hasFieldOrPropertyWithValue("url", "https://repo.spring.io/milestone")
|
||||
.hasFieldOrPropertyWithValue("snapshotsEnabled", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ sourceCompatibility = '1.8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://repo.spring.io/snapshot' }
|
||||
maven { url 'https://repo.spring.io/milestone' }
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||
maven { url = uri("https://repo.spring.io/milestone") }
|
||||
}
|
||||
|
||||
|
@ -41,14 +41,6 @@
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
@ -56,14 +48,6 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
|
Loading…
Reference in New Issue
Block a user