From cddf8f424531b58784b15a3a8cbb496aa5f4d861 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 10 Aug 2023 13:20:30 +0100 Subject: [PATCH] Upgrade to Spring Java Format 0.0.39 Closes gh-60 --- gradle.properties | 2 +- .../gradle/BuildScanConventions.java | 6 +++--- .../GradleEnterpriseConventionsPlugin.java | 14 ++++++++------ .../gradle/BuildScanConventionsTests.java | 17 ++++++++++------- ...rpriseConventionsPluginIntegrationTests.java | 14 +++++++++----- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9cb63e7..34fe322 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ version=0.0.14-SNAPSHOT gradleEnterprisePluginVersion=3.12.1 -javaFormatVersion=0.0.33 +javaFormatVersion=0.0.39 diff --git a/src/main/java/io/spring/ge/conventions/gradle/BuildScanConventions.java b/src/main/java/io/spring/ge/conventions/gradle/BuildScanConventions.java index ef929a8..0b519f8 100644 --- a/src/main/java/io/spring/ge/conventions/gradle/BuildScanConventions.java +++ b/src/main/java/io/spring/ge/conventions/gradle/BuildScanConventions.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2023 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,8 +58,8 @@ class BuildScanConventions implements Action { @Override @SuppressWarnings("deprecation") public void execute(BuildScanExtension buildScan) { - buildScan.obfuscation((obfuscation) -> obfuscation.ipAddresses( - (addresses) -> addresses.stream().map((address) -> "0.0.0.0").collect(Collectors.toList()))); + buildScan.obfuscation((obfuscation) -> obfuscation + .ipAddresses((addresses) -> addresses.stream().map((address) -> "0.0.0.0").collect(Collectors.toList()))); configurePublishing(buildScan); tagBuildScan(buildScan); buildScan.background(this::addGitMetadata); diff --git a/src/main/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPlugin.java b/src/main/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPlugin.java index 5ac149e..ca9df06 100644 --- a/src/main/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPlugin.java +++ b/src/main/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPlugin.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2023 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. @@ -61,15 +61,17 @@ private void apply(Settings settings) { settings.getRootDir()); }); if (settings.getStartParameter().isBuildCacheEnabled()) { - settings.buildCache( - (buildCacheConfiguration) -> new BuildCacheConventions().execute(buildCacheConfiguration)); + settings + .buildCache((buildCacheConfiguration) -> new BuildCacheConventions().execute(buildCacheConfiguration)); } } private void apply(Project project) { - project.getPlugins().withId("com.gradle.build-scan", - (plugin) -> configureBuildScanConventions(project.getExtensions().getByType(BuildScanExtension.class), - project.getGradle().getStartParameter(), project.getRootDir())); + project.getPlugins() + .withId("com.gradle.build-scan", + (plugin) -> configureBuildScanConventions( + project.getExtensions().getByType(BuildScanExtension.class), + project.getGradle().getStartParameter(), project.getRootDir())); } private void configureBuildScanConventions(BuildScanExtension buildScan, StartParameter startParameter, diff --git a/src/test/java/io/spring/ge/conventions/gradle/BuildScanConventionsTests.java b/src/test/java/io/spring/ge/conventions/gradle/BuildScanConventionsTests.java index c61f374..05f9a15 100644 --- a/src/test/java/io/spring/ge/conventions/gradle/BuildScanConventionsTests.java +++ b/src/test/java/io/spring/ge/conventions/gradle/BuildScanConventionsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2023 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. @@ -50,7 +50,7 @@ void ipAddressesAreObfuscated() throws UnknownHostException { new BuildScanConventions(this.processRunner).execute(this.buildScan); assertThat(this.buildScan.obfuscation.ipAddressesObfuscator).isNotNull(); List obfuscatedAddresses = this.buildScan.obfuscation.ipAddressesObfuscator - .apply(Arrays.asList(InetAddress.getByName("10.0.0.1"), InetAddress.getByName("10.0.0.2"))); + .apply(Arrays.asList(InetAddress.getByName("10.0.0.1"), InetAddress.getByName("10.0.0.2"))); assertThat(obfuscatedAddresses).containsExactly("0.0.0.0", "0.0.0.0"); } @@ -70,14 +70,16 @@ void buildScansAreConfiguredToPublishToGeSpringIo() { @Test void whenBambooResultEnvVarIsPresentThenBuildScanIsTaggedWithCiNotLocal() { new BuildScanConventions(this.processRunner, - Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.exampl.com")).execute(this.buildScan); + Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.exampl.com")) + .execute(this.buildScan); assertThat(this.buildScan.tags).contains("CI").doesNotContain("Local"); } @Test void whenBambooResultEnvVarIsPresentThenBuildScanHasACiBuildLinkToIt() { new BuildScanConventions(this.processRunner, - Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.example.com")).execute(this.buildScan); + Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.example.com")) + .execute(this.buildScan); assertThat(this.buildScan.links).containsEntry("CI build", "https://bamboo.example.com"); } @@ -85,7 +87,7 @@ void whenBambooResultEnvVarIsPresentThenBuildScanHasACiBuildLinkToIt() { void whenCircleBuildUrlEnvVarIsPresentThenBuildScanHasACiBuildLinkToIt() { new BuildScanConventions(this.processRunner, Collections.singletonMap("CIRCLE_BUILD_URL", "https://circleci.example.com/gh/org/project/123")) - .execute(this.buildScan); + .execute(this.buildScan); assertThat(this.buildScan.links).containsEntry("CI build", "https://circleci.example.com/gh/org/project/123"); } @@ -107,7 +109,8 @@ void whenCiEnvVarIsPresentThenBuildScanIsTaggedWithCiNotLocal() { @Test void whenJenkinsUrlEnvVarIsPresentThenBuildScanIsTaggedWithCiNotLocal() { new BuildScanConventions(this.processRunner, - Collections.singletonMap("JENKINS_URL", "https://jenkins.example.com")).execute(this.buildScan); + Collections.singletonMap("JENKINS_URL", "https://jenkins.example.com")) + .execute(this.buildScan); assertThat(this.buildScan.tags).contains("CI").doesNotContain("Local"); } @@ -132,7 +135,7 @@ void buildScanIsTaggedWithOperatingSystem() { @Test void whenBranchEnvVarIsPresentThenBuildScanIsTaggedAndConfiguredWithCustomValue() { new BuildScanConventions(this.processRunner, Collections.singletonMap("BRANCH", "1.1.x")) - .execute(this.buildScan); + .execute(this.buildScan); assertThat(this.buildScan.tags).contains("1.1.x"); assertThat(this.buildScan.values).containsEntry("Git branch", "1.1.x"); } diff --git a/src/test/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPluginIntegrationTests.java b/src/test/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPluginIntegrationTests.java index 2720c99..7deb06f 100644 --- a/src/test/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPluginIntegrationTests.java +++ b/src/test/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPluginIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2023 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. @@ -140,8 +140,8 @@ private void prepareGradle6Project(File projectDir) { writer.println("}"); writer.println("task verifyBuildCacheConfig {"); writer.println(" doFirst {"); - writer.println( - " println \"Build cache remote: ${project.ext['settings'].buildCache?.remote?.url}\""); + writer + .println(" println \"Build cache remote: ${project.ext['settings'].buildCache?.remote?.url}\""); writer.println(" }"); writer.println("}"); }); @@ -171,8 +171,12 @@ private BuildResult build(File projectDir, String gradleVersion, String... argum List classpath = Arrays.asList(new File("bin/main"), new File("build/classes/java/main"), new File("build/resources/main"), new File(GradleEnterprisePlugin.class.getProtectionDomain().getCodeSource().getLocation().getFile())); - return GradleRunner.create().withGradleVersion(gradleVersion).withProjectDir(projectDir) - .withPluginClasspath(classpath).withArguments(arguments).build(); + return GradleRunner.create() + .withGradleVersion(gradleVersion) + .withProjectDir(projectDir) + .withPluginClasspath(classpath) + .withArguments(arguments) + .build(); } }