Precompute Spring Boot version at build time

Closes gh-29670
This commit is contained in:
Scott Frederick
2022-02-11 14:44:28 -06:00
parent 76510fae48
commit f80490bafb
4 changed files with 141 additions and 64 deletions

View File

@@ -83,6 +83,7 @@ class ConventionsPluginTests {
try (JarFile jar = new JarFile(file)) {
assertThatLicenseIsPresent(jar);
assertThatNoticeIsPresent(jar);
assertThatSpringBootPropertiesIsPresent(jar);
Attributes mainAttributes = jar.getManifest().getMainAttributes();
assertThat(mainAttributes.getValue("Implementation-Title"))
.isEqualTo("Test project for manifest customization");
@@ -112,6 +113,7 @@ class ConventionsPluginTests {
try (JarFile jar = new JarFile(file)) {
assertThatLicenseIsPresent(jar);
assertThatNoticeIsPresent(jar);
assertThatSpringBootPropertiesIsPresent(jar);
Attributes mainAttributes = jar.getManifest().getMainAttributes();
assertThat(mainAttributes.getValue("Implementation-Title"))
.isEqualTo("Source for " + this.projectDir.getName());
@@ -141,6 +143,7 @@ class ConventionsPluginTests {
try (JarFile jar = new JarFile(file)) {
assertThatLicenseIsPresent(jar);
assertThatNoticeIsPresent(jar);
assertThatSpringBootPropertiesIsPresent(jar);
Attributes mainAttributes = jar.getManifest().getMainAttributes();
assertThat(mainAttributes.getValue("Implementation-Title"))
.isEqualTo("Javadoc for " + this.projectDir.getName());
@@ -165,6 +168,13 @@ class ConventionsPluginTests {
assertThat(noticeContent).doesNotContain("${");
}
private void assertThatSpringBootPropertiesIsPresent(JarFile jar) throws IOException {
JarEntry properties = jar.getJarEntry("META-INF/spring-boot.properties");
assertThat(properties).isNotNull();
String content = FileCopyUtils.copyToString(new InputStreamReader(jar.getInputStream(properties)));
assertThat(content).contains("version=");
}
@Test
void testRetryIsConfiguredWithThreeRetriesOnCI() throws IOException {
try (PrintWriter out = new PrintWriter(new FileWriter(this.buildFile))) {