mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-26 05:32:58 +08:00
Remove useless resolutionStrategy for Spring Boot plugin
Closes gh-610
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -45,10 +45,7 @@ public abstract class GradleSettingsWriter {
|
||||
return;
|
||||
}
|
||||
writer.println("pluginManagement {");
|
||||
writer.indented(() -> {
|
||||
writeRepositories(writer, build);
|
||||
writeResolutionStrategyIfNecessary(writer, build);
|
||||
});
|
||||
writer.indented(() -> writeRepositories(writer, build));
|
||||
writer.println("}");
|
||||
}
|
||||
|
||||
@@ -61,24 +58,6 @@ public abstract class GradleSettingsWriter {
|
||||
writer.println("}");
|
||||
}
|
||||
|
||||
private void writeResolutionStrategyIfNecessary(IndentingWriter writer, GradleBuild build) {
|
||||
if (build.pluginRepositories().items().allMatch(MavenRepository.MAVEN_CENTRAL::equals)) {
|
||||
return;
|
||||
}
|
||||
writer.println("resolutionStrategy {");
|
||||
writer.indented(() -> {
|
||||
writer.println("eachPlugin {");
|
||||
writer.indented(() -> {
|
||||
writer.println("if (requested.id.id == " + wrapWithQuotes("org.springframework.boot") + ") {");
|
||||
writer.indented(() -> writer.println(
|
||||
"useModule(\"org.springframework.boot:spring-boot-gradle-plugin:${requested.version}\")"));
|
||||
writer.println("}");
|
||||
});
|
||||
writer.println("}");
|
||||
});
|
||||
writer.println("}");
|
||||
}
|
||||
|
||||
private String repositoryAsString(MavenRepository repository) {
|
||||
if (MavenRepository.MAVEN_CENTRAL.equals(repository)) {
|
||||
return "mavenCentral()";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -58,10 +58,7 @@ class GroovyDslGradleSettingsWriterTests {
|
||||
List<String> lines = generateSettings(build);
|
||||
assertThat(lines).containsSequence("pluginManagement {", " repositories {",
|
||||
" maven { url 'https://repo.spring.io/milestone' }", " gradlePluginPortal()", " }",
|
||||
" resolutionStrategy {", " eachPlugin {",
|
||||
" if (requested.id.id == 'org.springframework.boot') {",
|
||||
" useModule(\"org.springframework.boot:spring-boot-gradle-plugin:${requested.version}\")",
|
||||
" }", " }", " }", "}");
|
||||
"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,10 +70,7 @@ class GroovyDslGradleSettingsWriterTests {
|
||||
List<String> lines = generateSettings(build);
|
||||
assertThat(lines).containsSequence("pluginManagement {", " repositories {",
|
||||
" maven { url 'https://repo.spring.io/snapshot' }", " gradlePluginPortal()", " }",
|
||||
" resolutionStrategy {", " eachPlugin {",
|
||||
" if (requested.id.id == 'org.springframework.boot') {",
|
||||
" useModule(\"org.springframework.boot:spring-boot-gradle-plugin:${requested.version}\")",
|
||||
" }", " }", " }", "}");
|
||||
"}");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -57,10 +57,7 @@ class KotlinDslGradleSettingsWriterTests {
|
||||
List<String> lines = generateSettings(build);
|
||||
assertThat(lines).containsSequence("pluginManagement {", " repositories {",
|
||||
" maven { url = uri(\"https://repo.spring.io/milestone\") }", " gradlePluginPortal()",
|
||||
" }", " resolutionStrategy {", " eachPlugin {",
|
||||
" if (requested.id.id == \"org.springframework.boot\") {",
|
||||
" useModule(\"org.springframework.boot:spring-boot-gradle-plugin:${requested.version}\")",
|
||||
" }", " }", " }", "}");
|
||||
" }", "}");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,10 +69,7 @@ class KotlinDslGradleSettingsWriterTests {
|
||||
List<String> lines = generateSettings(build);
|
||||
assertThat(lines).containsSequence("pluginManagement {", " repositories {",
|
||||
" maven { url = uri(\"https://repo.spring.io/snapshot\") }", " gradlePluginPortal()",
|
||||
" }", " resolutionStrategy {", " eachPlugin {",
|
||||
" if (requested.id.id == \"org.springframework.boot\") {",
|
||||
" useModule(\"org.springframework.boot:spring-boot-gradle-plugin:${requested.version}\")",
|
||||
" }", " }", " }", "}");
|
||||
" }", "}");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user