Merge branch '3.1.x'
Closes gh-38233
This commit is contained in:
@@ -24,6 +24,8 @@ import java.io.StringReader;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.gradle.testkit.runner.BuildResult;
|
||||
import org.gradle.testkit.runner.TaskOutcome;
|
||||
@@ -191,11 +193,12 @@ class JavaPluginActionIntegrationTests {
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
void productionRuntimeClasspathIsConfiguredWithAttributes() {
|
||||
assertThat(this.gradleBuild.build("build").getOutput()).contains("3 productionRuntimeClasspath attributes:")
|
||||
.contains("org.gradle.usage: java-runtime")
|
||||
.contains("org.gradle.libraryelements: jar")
|
||||
.contains("org.gradle.dependency.bundling: external");
|
||||
void productionRuntimeClasspathIsConfiguredWithAttributesThatMatchRuntimeClasspath() {
|
||||
String output = this.gradleBuild.build("build").getOutput();
|
||||
Matcher matcher = Pattern.compile("runtimeClasspath: (\\[.*\\])").matcher(output);
|
||||
assertThat(matcher.find()).as("%s found in %s", matcher, output).isTrue();
|
||||
String attributes = matcher.group(1);
|
||||
assertThat(output).contains("productionRuntimeClasspath: " + attributes);
|
||||
}
|
||||
|
||||
@TestTemplate
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
def attributes = configurations.findByName('productionRuntimeClasspath').attributes
|
||||
println "${attributes.keySet().size()} productionRuntimeClasspath attributes:"
|
||||
attributes.keySet().each { attribute ->
|
||||
println " ${attribute}: ${attributes.getAttribute(attribute)}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
def collectAttributes(String configurationName) {
|
||||
def attributes = configurations.findByName(configurationName).attributes
|
||||
def keys = new TreeSet<>((a1, a2) -> a1.name.compareTo(a2.name))
|
||||
keys.addAll(attributes.keySet())
|
||||
keys.collect { key -> "${key}: ${attributes.getAttribute(key)}" }
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.springframework.boot' version '{version}'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
springBoot {
|
||||
mainClass = "com.example.Main"
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
def runtimeClasspathAttributes = collectAttributes("runtimeClasspath")
|
||||
def productionRuntimeClasspathAttributes = collectAttributes("productionRuntimeClasspath")
|
||||
println("runtimeClasspath: ${runtimeClasspathAttributes}")
|
||||
println("productionRuntimeClasspath: ${productionRuntimeClasspathAttributes}")
|
||||
}
|
||||
Reference in New Issue
Block a user