Skip to content

Commit a56e7e6

Browse files
committed
Use Path.of(URI) instead of manual string wrangling.
1 parent d8913c4 commit a56e7e6

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/RomeStepConfig.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static java.util.Objects.requireNonNull;
1919

2020
import java.io.File;
21+
import java.nio.file.Path;
2122
import java.nio.file.Paths;
2223
import java.util.function.Consumer;
2324

@@ -26,7 +27,6 @@
2627
import org.gradle.api.Project;
2728
import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
2829

29-
import com.diffplug.spotless.FileSignature;
3030
import com.diffplug.spotless.FormatterStep;
3131
import com.diffplug.spotless.rome.RomeStep;
3232

@@ -208,11 +208,7 @@ private File findDataDir() {
208208
var localRepo = currentRepo != null ? (MavenArtifactRepository) currentRepo : project.getRepositories().mavenLocal();
209209
try {
210210
// e.g. ~/.m2/repository/
211-
var path = localRepo.getUrl().getPath();
212-
if (FileSignature.machineIsWin() && path.startsWith("/")) {
213-
path = path.substring(1);
214-
}
215-
var repoPath = Paths.get(path);
211+
var repoPath = Path.of(localRepo.getUrl());
216212
var dataPath = repoPath.resolve("com").resolve("diffplug").resolve("spotless").resolve("spotless-data");
217213
return dataPath.toAbsolutePath().toFile();
218214
} finally {
@@ -246,8 +242,6 @@ private RomeStep newBuilder() {
246242
* the user's path. Otherwise resolve the executable path against the project's
247243
* base directory.
248244
*
249-
* @param config Configuration from the Maven Mojo execution with details about
250-
* the currently executed project.
251245
* @return The resolved path to the Rome executable.
252246
*/
253247
private String resolvePathToExe() {
@@ -265,7 +259,6 @@ private String resolvePathToExe() {
265259
* current project's directory. Otherwise, use the {@code Rome} sub folder in
266260
* the shared data directory.
267261
*
268-
* @param config Configuration for this step.
269262
* @return The download directory for the Rome executable.
270263
*/
271264
private String resolveDownloadDir() {

0 commit comments

Comments
 (0)