Skip to content

Commit cddf8f4

Browse files
committed
Upgrade to Spring Java Format 0.0.39
Closes gh-60
1 parent 3a3acb3 commit cddf8f4

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
version=0.0.14-SNAPSHOT
22

33
gradleEnterprisePluginVersion=3.12.1
4-
javaFormatVersion=0.0.33
4+
javaFormatVersion=0.0.39

src/main/java/io/spring/ge/conventions/gradle/BuildScanConventions.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -58,8 +58,8 @@ class BuildScanConventions implements Action<BuildScanExtension> {
5858
@Override
5959
@SuppressWarnings("deprecation")
6060
public void execute(BuildScanExtension buildScan) {
61-
buildScan.obfuscation((obfuscation) -> obfuscation.ipAddresses(
62-
(addresses) -> addresses.stream().map((address) -> "0.0.0.0").collect(Collectors.toList())));
61+
buildScan.obfuscation((obfuscation) -> obfuscation
62+
.ipAddresses((addresses) -> addresses.stream().map((address) -> "0.0.0.0").collect(Collectors.toList())));
6363
configurePublishing(buildScan);
6464
tagBuildScan(buildScan);
6565
buildScan.background(this::addGitMetadata);

src/main/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPlugin.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,15 +61,17 @@ private void apply(Settings settings) {
6161
settings.getRootDir());
6262
});
6363
if (settings.getStartParameter().isBuildCacheEnabled()) {
64-
settings.buildCache(
65-
(buildCacheConfiguration) -> new BuildCacheConventions().execute(buildCacheConfiguration));
64+
settings
65+
.buildCache((buildCacheConfiguration) -> new BuildCacheConventions().execute(buildCacheConfiguration));
6666
}
6767
}
6868

6969
private void apply(Project project) {
70-
project.getPlugins().withId("com.gradle.build-scan",
71-
(plugin) -> configureBuildScanConventions(project.getExtensions().getByType(BuildScanExtension.class),
72-
project.getGradle().getStartParameter(), project.getRootDir()));
70+
project.getPlugins()
71+
.withId("com.gradle.build-scan",
72+
(plugin) -> configureBuildScanConventions(
73+
project.getExtensions().getByType(BuildScanExtension.class),
74+
project.getGradle().getStartParameter(), project.getRootDir()));
7375
}
7476

7577
private void configureBuildScanConventions(BuildScanExtension buildScan, StartParameter startParameter,

src/test/java/io/spring/ge/conventions/gradle/BuildScanConventionsTests.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@ void ipAddressesAreObfuscated() throws UnknownHostException {
5050
new BuildScanConventions(this.processRunner).execute(this.buildScan);
5151
assertThat(this.buildScan.obfuscation.ipAddressesObfuscator).isNotNull();
5252
List<String> obfuscatedAddresses = this.buildScan.obfuscation.ipAddressesObfuscator
53-
.apply(Arrays.asList(InetAddress.getByName("10.0.0.1"), InetAddress.getByName("10.0.0.2")));
53+
.apply(Arrays.asList(InetAddress.getByName("10.0.0.1"), InetAddress.getByName("10.0.0.2")));
5454
assertThat(obfuscatedAddresses).containsExactly("0.0.0.0", "0.0.0.0");
5555
}
5656

@@ -70,22 +70,24 @@ void buildScansAreConfiguredToPublishToGeSpringIo() {
7070
@Test
7171
void whenBambooResultEnvVarIsPresentThenBuildScanIsTaggedWithCiNotLocal() {
7272
new BuildScanConventions(this.processRunner,
73-
Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.exampl.com")).execute(this.buildScan);
73+
Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.exampl.com"))
74+
.execute(this.buildScan);
7475
assertThat(this.buildScan.tags).contains("CI").doesNotContain("Local");
7576
}
7677

7778
@Test
7879
void whenBambooResultEnvVarIsPresentThenBuildScanHasACiBuildLinkToIt() {
7980
new BuildScanConventions(this.processRunner,
80-
Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.example.com")).execute(this.buildScan);
81+
Collections.singletonMap("bamboo_resultsUrl", "https://bamboo.example.com"))
82+
.execute(this.buildScan);
8183
assertThat(this.buildScan.links).containsEntry("CI build", "https://bamboo.example.com");
8284
}
8385

8486
@Test
8587
void whenCircleBuildUrlEnvVarIsPresentThenBuildScanHasACiBuildLinkToIt() {
8688
new BuildScanConventions(this.processRunner,
8789
Collections.singletonMap("CIRCLE_BUILD_URL", "https://circleci.example.com/gh/org/project/123"))
88-
.execute(this.buildScan);
90+
.execute(this.buildScan);
8991
assertThat(this.buildScan.links).containsEntry("CI build", "https://circleci.example.com/gh/org/project/123");
9092
}
9193

@@ -107,7 +109,8 @@ void whenCiEnvVarIsPresentThenBuildScanIsTaggedWithCiNotLocal() {
107109
@Test
108110
void whenJenkinsUrlEnvVarIsPresentThenBuildScanIsTaggedWithCiNotLocal() {
109111
new BuildScanConventions(this.processRunner,
110-
Collections.singletonMap("JENKINS_URL", "https://jenkins.example.com")).execute(this.buildScan);
112+
Collections.singletonMap("JENKINS_URL", "https://jenkins.example.com"))
113+
.execute(this.buildScan);
111114
assertThat(this.buildScan.tags).contains("CI").doesNotContain("Local");
112115
}
113116

@@ -132,7 +135,7 @@ void buildScanIsTaggedWithOperatingSystem() {
132135
@Test
133136
void whenBranchEnvVarIsPresentThenBuildScanIsTaggedAndConfiguredWithCustomValue() {
134137
new BuildScanConventions(this.processRunner, Collections.singletonMap("BRANCH", "1.1.x"))
135-
.execute(this.buildScan);
138+
.execute(this.buildScan);
136139
assertThat(this.buildScan.tags).contains("1.1.x");
137140
assertThat(this.buildScan.values).containsEntry("Git branch", "1.1.x");
138141
}

src/test/java/io/spring/ge/conventions/gradle/GradleEnterpriseConventionsPluginIntegrationTests.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -140,8 +140,8 @@ private void prepareGradle6Project(File projectDir) {
140140
writer.println("}");
141141
writer.println("task verifyBuildCacheConfig {");
142142
writer.println(" doFirst {");
143-
writer.println(
144-
" println \"Build cache remote: ${project.ext['settings'].buildCache?.remote?.url}\"");
143+
writer
144+
.println(" println \"Build cache remote: ${project.ext['settings'].buildCache?.remote?.url}\"");
145145
writer.println(" }");
146146
writer.println("}");
147147
});
@@ -171,8 +171,12 @@ private BuildResult build(File projectDir, String gradleVersion, String... argum
171171
List<File> classpath = Arrays.asList(new File("bin/main"), new File("build/classes/java/main"),
172172
new File("build/resources/main"),
173173
new File(GradleEnterprisePlugin.class.getProtectionDomain().getCodeSource().getLocation().getFile()));
174-
return GradleRunner.create().withGradleVersion(gradleVersion).withProjectDir(projectDir)
175-
.withPluginClasspath(classpath).withArguments(arguments).build();
174+
return GradleRunner.create()
175+
.withGradleVersion(gradleVersion)
176+
.withProjectDir(projectDir)
177+
.withPluginClasspath(classpath)
178+
.withArguments(arguments)
179+
.build();
176180
}
177181

178182
}

0 commit comments

Comments
 (0)