Merge branch '2.4.x' into 2.5.x
Closes gh-28661
This commit is contained in:
@@ -48,9 +48,11 @@ import org.gradle.api.tasks.testing.Test;
|
||||
import org.gradle.testretry.TestRetryPlugin;
|
||||
import org.gradle.testretry.TestRetryTaskExtension;
|
||||
|
||||
import org.springframework.boot.build.classpath.CheckClasspathForProhibitedDependencies;
|
||||
import org.springframework.boot.build.optional.OptionalDependenciesPlugin;
|
||||
import org.springframework.boot.build.testing.TestFailuresPlugin;
|
||||
import org.springframework.boot.build.toolchain.ToolchainPlugin;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Conventions that are applied in the presence of the {@link JavaBasePlugin}. When the
|
||||
@@ -112,6 +114,7 @@ class JavaConventions {
|
||||
configureJarManifestConventions(project);
|
||||
configureDependencyManagement(project);
|
||||
configureToolchain(project);
|
||||
configureProhibitedDependencyChecks(project);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -239,4 +242,26 @@ class JavaConventions {
|
||||
project.getPlugins().apply(ToolchainPlugin.class);
|
||||
}
|
||||
|
||||
private void configureProhibitedDependencyChecks(Project project) {
|
||||
SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class);
|
||||
sourceSets.all((sourceSet) -> createProhibitedDependenciesChecks(project,
|
||||
sourceSet.getCompileClasspathConfigurationName(), sourceSet.getRuntimeClasspathConfigurationName()));
|
||||
}
|
||||
|
||||
private void createProhibitedDependenciesChecks(Project project, String... configurationNames) {
|
||||
ConfigurationContainer configurations = project.getConfigurations();
|
||||
for (String configurationName : configurationNames) {
|
||||
Configuration configuration = configurations.getByName(configurationName);
|
||||
createProhibitedDependenciesCheck(configuration, project);
|
||||
}
|
||||
}
|
||||
|
||||
private void createProhibitedDependenciesCheck(Configuration classpath, Project project) {
|
||||
CheckClasspathForProhibitedDependencies checkClasspathForProhibitedDependencies = project.getTasks().create(
|
||||
"check" + StringUtils.capitalize(classpath.getName() + "ForProhibitedDependencies"),
|
||||
CheckClasspathForProhibitedDependencies.class);
|
||||
checkClasspathForProhibitedDependencies.setClasspath(classpath);
|
||||
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForProhibitedDependencies);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,12 @@ public class CheckClasspathForProhibitedDependencies extends DefaultTask {
|
||||
if (group.equals("javax.batch")) {
|
||||
return false;
|
||||
}
|
||||
if (group.equals("javax.cache")) {
|
||||
return false;
|
||||
}
|
||||
if (group.equals("javax.money")) {
|
||||
return false;
|
||||
}
|
||||
if (group.startsWith("javax")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import org.gradle.api.tasks.bundling.Jar;
|
||||
import org.springframework.boot.build.ConventionsPlugin;
|
||||
import org.springframework.boot.build.DeployedPlugin;
|
||||
import org.springframework.boot.build.classpath.CheckClasspathForConflicts;
|
||||
import org.springframework.boot.build.classpath.CheckClasspathForProhibitedDependencies;
|
||||
import org.springframework.boot.build.classpath.CheckClasspathForUnnecessaryExclusions;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -62,7 +61,6 @@ public class StarterPlugin implements Plugin<Project> {
|
||||
project.getArtifacts().add("starterMetadata", project.provider(starterMetadata::getDestination),
|
||||
(artifact) -> artifact.builtBy(starterMetadata));
|
||||
createClasspathConflictsCheck(runtimeClasspath, project);
|
||||
createProhibitedDependenciesCheck(runtimeClasspath, project);
|
||||
createUnnecessaryExclusionsCheck(runtimeClasspath, project);
|
||||
configureJarManifest(project);
|
||||
}
|
||||
@@ -75,14 +73,6 @@ public class StarterPlugin implements Plugin<Project> {
|
||||
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForConflicts);
|
||||
}
|
||||
|
||||
private void createProhibitedDependenciesCheck(Configuration classpath, Project project) {
|
||||
CheckClasspathForProhibitedDependencies checkClasspathForProhibitedDependencies = project.getTasks().create(
|
||||
"check" + StringUtils.capitalize(classpath.getName() + "ForProhibitedDependencies"),
|
||||
CheckClasspathForProhibitedDependencies.class);
|
||||
checkClasspathForProhibitedDependencies.setClasspath(classpath);
|
||||
project.getTasks().getByName(JavaBasePlugin.CHECK_TASK_NAME).dependsOn(checkClasspathForProhibitedDependencies);
|
||||
}
|
||||
|
||||
private void createUnnecessaryExclusionsCheck(Configuration classpath, Project project) {
|
||||
CheckClasspathForUnnecessaryExclusions checkClasspathForUnnecessaryExclusions = project.getTasks().create(
|
||||
"check" + StringUtils.capitalize(classpath.getName() + "ForUnnecessaryExclusions"),
|
||||
|
||||
@@ -105,6 +105,12 @@ class ConventionsPluginTests {
|
||||
out.println("version = '1.2.3'");
|
||||
out.println("sourceCompatibility = '1.8'");
|
||||
out.println("description 'Test'");
|
||||
out.println("repositories {");
|
||||
out.println(" mavenCentral()");
|
||||
out.println("}");
|
||||
out.println("dependencies {");
|
||||
out.println(" implementation(platform(\"org.junit:junit-bom:5.6.0\"))");
|
||||
out.println("}");
|
||||
}
|
||||
runGradle("build");
|
||||
File file = new File(this.projectDir, "/build/libs/" + this.projectDir.getName() + "-1.2.3-sources.jar");
|
||||
@@ -134,6 +140,12 @@ class ConventionsPluginTests {
|
||||
out.println("version = '1.2.3'");
|
||||
out.println("sourceCompatibility = '1.8'");
|
||||
out.println("description 'Test'");
|
||||
out.println("repositories {");
|
||||
out.println(" mavenCentral()");
|
||||
out.println("}");
|
||||
out.println("dependencies {");
|
||||
out.println(" implementation(platform(\"org.junit:junit-bom:5.6.0\"))");
|
||||
out.println("}");
|
||||
}
|
||||
runGradle("build");
|
||||
File file = new File(this.projectDir, "/build/libs/" + this.projectDir.getName() + "-1.2.3-javadoc.jar");
|
||||
|
||||
Reference in New Issue
Block a user