diff --git a/eclipse/spring-boot-project.setup b/eclipse/spring-boot-project.setup index 5f40a3712b4..5a9da8b699c 100644 --- a/eclipse/spring-boot-project.setup +++ b/eclipse/spring-boot-project.setup @@ -59,7 +59,7 @@ + name="io.spring.javaformat.eclipse.feature.feature.group" versionRange="[0.0.14,0.0.15)"/> - 0.0.11 + 0.0.14 0.0.1.RELEASE @@ -37,7 +37,7 @@ com.puppycrawl.tools checkstyle - 8.18 + 8.22 io.spring.javaformat diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java index b8c3b1378d3..e7053f9c38a 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java @@ -359,12 +359,14 @@ public class InitCommandTests extends AbstractHttpClientMockTests { } private byte[] createFakeZipArchive(String fileName, String content) throws IOException { - try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(bos)) { - ZipEntry entry = new ZipEntry(fileName); - zos.putNextEntry(entry); - zos.write(content.getBytes()); - zos.closeEntry(); - return bos.toByteArray(); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + try (ZipOutputStream zos = new ZipOutputStream(bos)) { + ZipEntry entry = new ZipEntry(fileName); + zos.putNextEntry(entry); + zos.write(content.getBytes()); + zos.closeEntry(); + return bos.toByteArray(); + } } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilderTests.java index 6978639f6d1..fa15d8dc0cb 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/ConfigurationMetadataRepositoryJsonBuilderTests.java @@ -62,44 +62,53 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon @Test public void severalRepositoriesNoConflict() throws IOException { - try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) { - ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar).build(); - validateFoo(repo); - validateBar(repo); - assertThat(repo.getAllGroups()).hasSize(2); - contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", - "spring.bar.name", "spring.bar.description", "spring.bar.counter"); - assertThat(repo.getAllProperties()).hasSize(6); + try (InputStream foo = getInputStreamFor("foo")) { + try (InputStream bar = getInputStreamFor("bar")) { + ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, bar) + .build(); + validateFoo(repo); + validateBar(repo); + assertThat(repo.getAllGroups()).hasSize(2); + contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", + "spring.bar.name", "spring.bar.description", "spring.bar.counter"); + assertThat(repo.getAllProperties()).hasSize(6); + } } } @Test public void repositoryWithRoot() throws IOException { - try (InputStream foo = getInputStreamFor("foo"); InputStream root = getInputStreamFor("root")) { - ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root).build(); - validateFoo(repo); - assertThat(repo.getAllGroups()).hasSize(2); + try (InputStream foo = getInputStreamFor("foo")) { + try (InputStream root = getInputStreamFor("root")) { + ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, root) + .build(); + validateFoo(repo); + assertThat(repo.getAllGroups()).hasSize(2); - contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", - "spring.root.name", "spring.root2.name"); - assertThat(repo.getAllProperties()).hasSize(5); + contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", + "spring.root.name", "spring.root2.name"); + assertThat(repo.getAllProperties()).hasSize(5); + } } } @Test public void severalRepositoriesIdenticalGroups() throws IOException { - try (InputStream foo = getInputStreamFor("foo"); InputStream foo2 = getInputStreamFor("foo2")) { - ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2).build(); - assertThat(repo.getAllGroups()).hasSize(1); - ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo"); - contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties"); - assertThat(group.getSources()).hasSize(3); - contains(group.getProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", - "spring.foo.enabled", "spring.foo.type"); - assertThat(group.getProperties()).hasSize(5); - contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", - "spring.foo.enabled", "spring.foo.type"); - assertThat(repo.getAllProperties()).hasSize(5); + try (InputStream foo = getInputStreamFor("foo")) { + try (InputStream foo2 = getInputStreamFor("foo2")) { + ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder.create(foo, foo2) + .build(); + assertThat(repo.getAllGroups()).hasSize(1); + ConfigurationMetadataGroup group = repo.getAllGroups().get("spring.foo"); + contains(group.getSources(), "org.acme.Foo", "org.acme.Foo2", "org.springframework.boot.FooProperties"); + assertThat(group.getSources()).hasSize(3); + contains(group.getProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", + "spring.foo.enabled", "spring.foo.type"); + assertThat(group.getProperties()).hasSize(5); + contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description", "spring.foo.counter", + "spring.foo.enabled", "spring.foo.type"); + assertThat(repo.getAllProperties()).hasSize(5); + } } } @@ -116,19 +125,22 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractCon @Test public void builderInstancesAreIsolated() throws IOException { - try (InputStream foo = getInputStreamFor("foo"); InputStream bar = getInputStreamFor("bar")) { - ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); - ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build(); - validateFoo(firstRepo); - ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build(); - validateFoo(secondRepo); - validateBar(secondRepo); - // first repo not impacted by second build - assertThat(secondRepo).isNotEqualTo(firstRepo); - assertThat(firstRepo.getAllGroups()).hasSize(1); - assertThat(firstRepo.getAllProperties()).hasSize(3); - assertThat(secondRepo.getAllGroups()).hasSize(2); - assertThat(secondRepo.getAllProperties()).hasSize(6); + try (InputStream foo = getInputStreamFor("foo")) { + try (InputStream bar = getInputStreamFor("bar")) { + ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder + .create(); + ConfigurationMetadataRepository firstRepo = builder.withJsonResource(foo).build(); + validateFoo(firstRepo); + ConfigurationMetadataRepository secondRepo = builder.withJsonResource(bar).build(); + validateFoo(secondRepo); + validateBar(secondRepo); + // first repo not impacted by second build + assertThat(secondRepo).isNotEqualTo(firstRepo); + assertThat(firstRepo.getAllGroups()).hasSize(1); + assertThat(firstRepo.getAllProperties()).hasSize(3); + assertThat(secondRepo.getAllGroups()).hasSize(2); + assertThat(secondRepo.getAllProperties()).hasSize(6); + } } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle index d410b6ff9c6..9a7e75b4ce0 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle @@ -4,7 +4,7 @@ buildscript { mavenCentral() } dependencies { - classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.11") + classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.14") } }