Skip to content

Commit

Permalink
Upgrade to Spring Java Format 0.0.39
Browse files Browse the repository at this point in the history
Closes gh-60
  • Loading branch information
wilkinsona committed Aug 10, 2023
1 parent 3a3acb3 commit cddf8f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.0.14-SNAPSHOT

gradleEnterprisePluginVersion=3.12.1
javaFormatVersion=0.0.33
javaFormatVersion=0.0.39
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -58,8 +58,8 @@ class BuildScanConventions implements Action<BuildScanExtension> {
@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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -50,7 +50,7 @@ void ipAddressesAreObfuscated() throws UnknownHostException {
new BuildScanConventions(this.processRunner).execute(this.buildScan);
assertThat(this.buildScan.obfuscation.ipAddressesObfuscator).isNotNull();
List<String> 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");
}

Expand All @@ -70,22 +70,24 @@ 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");
}

@Test
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");
}

Expand All @@ -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");
}

Expand All @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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("}");
});
Expand Down Expand Up @@ -171,8 +171,12 @@ private BuildResult build(File projectDir, String gradleVersion, String... argum
List<File> 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();
}

}

0 comments on commit cddf8f4

Please sign in to comment.