Skip to content

Commit e921d78

Browse files
Excavator: Upgrades Baseline to the latest version (#1370)
1 parent 0984f78 commit e921d78

File tree

18 files changed

+47
-52
lines changed

18 files changed

+47
-52
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
dependencies {
88
classpath 'com.palantir.jakartapackagealignment:jakarta-package-alignment:0.6.0'
99
classpath 'com.gradle.publish:plugin-publish-plugin:1.3.1'
10-
classpath 'com.palantir.baseline:gradle-baseline-java:6.43.0'
10+
classpath 'com.palantir.baseline:gradle-baseline-java:6.44.0'
1111
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.36.0'
1212
classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.19.0'
1313
classpath 'com.palantir.gradle.failure-reports:gradle-failure-reports:1.14.0'

gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/ExecutableTransform.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.File;
2020
import java.io.IOException;
21+
import java.io.UncheckedIOException;
2122
import java.nio.file.Files;
2223
import java.nio.file.Path;
2324
import java.nio.file.StandardCopyOption;
@@ -46,7 +47,6 @@ public abstract class ExecutableTransform implements TransformAction<TransformPa
4647
@InputArtifact
4748
public abstract Provider<FileSystemLocation> getInputArtifact();
4849

49-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
5050
@Override
5151
public void transform(TransformOutputs outputs) {
5252
File inputFile = getInputArtifact().get().getAsFile();
@@ -55,11 +55,11 @@ public void transform(TransformOutputs outputs) {
5555
Files.copy(inputFile.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
5656
makeFileExecutable(outputFile.toPath());
5757
} catch (IOException e) {
58-
throw new RuntimeException(String.format("Failed to create executable file %s", outputFile.toPath()), e);
58+
throw new UncheckedIOException(
59+
String.format("Failed to create executable file %s", outputFile.toPath()), e);
5960
}
6061
}
6162

62-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
6363
private static void makeFileExecutable(Path pathToExe) {
6464
try {
6565
Set<PosixFilePermission> existingPermissions = Files.getPosixFilePermissions(pathToExe);
@@ -73,7 +73,7 @@ private static void makeFileExecutable(Path pathToExe) {
7373
PosixFilePermission.OTHERS_EXECUTE))
7474
.collect(Collectors.toSet()));
7575
} catch (IOException e) {
76-
throw new RuntimeException("Failed to set execute permissions on native-image", e);
76+
throw new UncheckedIOException("Failed to set execute permissions on native-image", e);
7777
}
7878
}
7979
}

gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/JavaFormatExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.base.Suppliers;
2020
import com.google.common.collect.Iterables;
2121
import com.palantir.javaformat.java.FormatterService;
22+
import java.io.UncheckedIOException;
2223
import java.net.MalformedURLException;
2324
import java.net.URL;
2425
import java.net.URLClassLoader;
@@ -41,13 +42,12 @@ public FormatterService serviceLoad() {
4142

4243
@SuppressWarnings("for-rollout:NullAway")
4344
private FormatterService serviceLoadInternal() {
44-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
4545
URL[] jarUris = configuration.getFiles().stream()
4646
.map(file -> {
4747
try {
4848
return file.toURI().toURL();
4949
} catch (MalformedURLException e) {
50-
throw new RuntimeException("Unable to convert URI to URL: " + file, e);
50+
throw new UncheckedIOException("Unable to convert URI to URL: " + file, e);
5151
}
5252
})
5353
.toArray(URL[]::new);

gradle-palantir-java-format/src/main/java/com/palantir/javaformat/gradle/spotless/PalantirJavaFormatStep.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.io.File;
2323
import java.io.IOException;
2424
import java.io.Serializable;
25+
import java.io.UncheckedIOException;
2526
import java.util.function.Supplier;
2627
import org.gradle.api.artifacts.Configuration;
2728

@@ -79,7 +80,7 @@ static final class State implements Serializable {
7980
this.memoizedFormatter = memoizedFormatter;
8081
}
8182

82-
@SuppressWarnings({"NullableProblems", "for-rollout:PreferUncheckedIoException"})
83+
@SuppressWarnings("NullableProblems")
8384
FormatterFunc createFormat() {
8485
return input -> {
8586
try {
@@ -92,7 +93,7 @@ FormatterFunc createFormat() {
9293

9394
return memoizedFormatter.get().formatSourceReflowStringsAndFixImports(input);
9495
} catch (IOException e) {
95-
throw new RuntimeException(e);
96+
throw new UncheckedIOException(e);
9697
}
9798
};
9899
}

idea-plugin/src/main/java/com/palantir/javaformat/intellij/FormatterProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.palantir.javaformat.bootstrap.NativeImageFormatterService;
3535
import com.palantir.javaformat.java.FormatterService;
3636
import java.io.IOException;
37+
import java.io.UncheckedIOException;
3738
import java.net.MalformedURLException;
3839
import java.net.URI;
3940
import java.net.URL;
@@ -207,12 +208,11 @@ private static URL[] toUrlsUnchecked(List<Path> paths) {
207208
.toArray(URL[]::new);
208209
}
209210

210-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
211211
private static List<Path> listDirAsUrlsUnchecked(Path dir) {
212212
try (Stream<Path> list = Files.list(dir)) {
213213
return list.collect(Collectors.toList());
214214
} catch (IOException e) {
215-
throw new RuntimeException("Couldn't list dir: " + dir, e);
215+
throw new UncheckedIOException("Couldn't list dir: " + dir, e);
216216
}
217217
}
218218

idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatSettings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.palantir.javaformat.java.JavaFormatterOptions;
2525
import com.palantir.sls.versions.OrderableSlsVersion;
2626
import java.io.IOException;
27+
import java.io.UncheckedIOException;
2728
import java.net.URI;
2829
import java.util.List;
2930
import java.util.Optional;
@@ -113,7 +114,6 @@ Optional<String> getImplementationVersion() {
113114
return Optional.ofNullable(FormatterProvider.getPluginDescriptor().getVersion());
114115
}
115116

116-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
117117
Optional<String> computeFormatterVersion() {
118118
return getImplementationClassPath().map(classpath -> classpath.stream()
119119
.flatMap(uri -> {
@@ -127,7 +127,7 @@ Optional<String> computeFormatterVersion() {
127127
}
128128
return Stream.empty();
129129
} catch (IOException e) {
130-
throw new RuntimeException(e);
130+
throw new UncheckedIOException(e);
131131
}
132132
})
133133
.findFirst()

idea-plugin/src/test/java/com/palantir/javaformat/intellij/PalantirJavaFormatFormattingServiceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.palantir.javaformat.intellij.PalantirJavaFormatSettings.State;
4242
import java.io.File;
4343
import java.io.IOException;
44+
import java.io.UncheckedIOException;
4445
import java.nio.file.Files;
4546
import java.nio.file.Path;
4647
import java.nio.file.Paths;
@@ -103,15 +104,14 @@ protected Project getProject() {
103104
@NotNull
104105
protected LightProjectDescriptor getProjectDescriptor() {
105106
return new DefaultLightProjectDescriptor() {
106-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
107107
@Override
108108
public Sdk getSdk() {
109109
try {
110110
return JavaSdk.getInstance()
111111
.createJdk(
112112
"java 1.11", new File(System.getProperty("java.home")).getCanonicalPath(), false);
113113
} catch (IOException e) {
114-
throw new RuntimeException(e);
114+
throw new UncheckedIOException(e);
115115
}
116116
}
117117
};

palantir-java-format-benchmarks/src/jmh/java/com/palantir/javaformat/BenchmarkMultiFiles.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.assertj.core.api.Assertions.assertThat;
2020

2121
import java.io.IOException;
22+
import java.io.UncheckedIOException;
2223
import java.nio.file.Files;
2324
import java.nio.file.Path;
2425
import java.nio.file.Paths;
@@ -47,7 +48,6 @@ public static class BenchmarkState {
4748

4849
final List<String> filesToFormat = getFilesToFormat();
4950

50-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
5151
private static List<String> getFilesToFormat() {
5252
Path srcJavaFormatFiles = Paths.get(".")
5353
.toAbsolutePath()
@@ -57,7 +57,7 @@ private static List<String> getFilesToFormat() {
5757
.map(path -> path.toAbsolutePath().toString())) {
5858
return paths.collect(Collectors.toList());
5959
} catch (IOException e) {
60-
throw new RuntimeException("Couldn't list src files: " + srcJavaFormatFiles, e);
60+
throw new UncheckedIOException("Couldn't list src files: " + srcJavaFormatFiles, e);
6161
}
6262
}
6363
}

palantir-java-format-jdk-bootstrap/src/main/java/com/palantir/javaformat/bootstrap/BootstrappingFormatterService.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.palantir.javaformat.java.FormatterService;
2828
import com.palantir.javaformat.java.Replacement;
2929
import java.io.IOException;
30+
import java.io.UncheckedIOException;
3031
import java.nio.file.Path;
3132
import java.util.Collection;
3233
import java.util.List;
@@ -50,33 +51,30 @@ public BootstrappingFormatterService(Path jdkPath, Integer jdkMajorVersion, List
5051
this.implementationClassPath = implementationClassPath;
5152
}
5253

53-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
5454
@Override
5555
public ImmutableList<Replacement> getFormatReplacements(String input, Collection<Range<Integer>> ranges) {
5656
try {
5757
return getFormatReplacementsInternal(input, ranges);
5858
} catch (IOException e) {
59-
throw new RuntimeException("Error running formatter command", e);
59+
throw new UncheckedIOException("Error running formatter command", e);
6060
}
6161
}
6262

63-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
6463
@Override
6564
public String formatSourceReflowStringsAndFixImports(String input) {
6665
try {
6766
return runFormatterCommand(input);
6867
} catch (IOException e) {
69-
throw new RuntimeException("Error running formatter command", e);
68+
throw new UncheckedIOException("Error running formatter command", e);
7069
}
7170
}
7271

73-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
7472
@Override
7573
public String fixImports(String input) throws FormatterException {
7674
try {
7775
return runFormatterCommand(input);
7876
} catch (IOException e) {
79-
throw new RuntimeException("Error running formatter command", e);
77+
throw new UncheckedIOException("Error running formatter command", e);
8078
}
8179
}
8280

palantir-java-format-jdk-bootstrap/src/main/java/com/palantir/javaformat/bootstrap/NativeImageFormatterService.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.palantir.javaformat.java.FormatterService;
2727
import com.palantir.javaformat.java.Replacement;
2828
import java.io.IOException;
29+
import java.io.UncheckedIOException;
2930
import java.nio.file.Path;
3031
import java.util.Collection;
3132
import java.util.List;
@@ -42,7 +43,6 @@ public NativeImageFormatterService(Path nativeImagePath) {
4243
this.nativeImagePath = nativeImagePath;
4344
}
4445

45-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
4646
@Override
4747
public ImmutableList<Replacement> getFormatReplacements(String input, Collection<Range<Integer>> ranges) {
4848
try {
@@ -60,27 +60,25 @@ public ImmutableList<Replacement> getFormatReplacements(String input, Collection
6060
}
6161
return MAPPER.readValue(output.get(), new TypeReference<>() {});
6262
} catch (IOException e) {
63-
throw new RuntimeException("Error running the native image command", e);
63+
throw new UncheckedIOException("Error running the native image command", e);
6464
}
6565
}
6666

67-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
6867
@Override
6968
public String formatSourceReflowStringsAndFixImports(String input) {
7069
try {
7170
return runFormatterCommand(input);
7271
} catch (IOException e) {
73-
throw new RuntimeException("Error running the native image command", e);
72+
throw new UncheckedIOException("Error running the native image command", e);
7473
}
7574
}
7675

77-
@SuppressWarnings("for-rollout:PreferUncheckedIoException")
7876
@Override
7977
public String fixImports(String input) {
8078
try {
8179
return runFormatterCommand(input);
8280
} catch (IOException e) {
83-
throw new RuntimeException("Error running the native image command", e);
81+
throw new UncheckedIOException("Error running the native image command", e);
8482
}
8583
}
8684

0 commit comments

Comments
 (0)