Remove useless resolutionStrategy for Spring Boot plugin

Closes gh-610
This commit is contained in:
Stephane Nicoll
2021-01-11 16:56:50 +01:00
parent 9f1de5d87b
commit c4485b6cbd
3 changed files with 8 additions and 41 deletions

View File

@@ -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()";

View File

@@ -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

View File

@@ -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