From 7face792f22ffe52eb04b8fcaf820df7ad771d52 Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Sun, 1 Oct 2023 14:42:04 -0400 Subject: [PATCH] More Windows tweaks --- .../java/rife/bld/dependencies/Repository.java | 4 +++- .../rife/bld/dependencies/TestRepository.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/rife/bld/dependencies/Repository.java b/src/main/java/rife/bld/dependencies/Repository.java index d388f67..0bf83ce 100644 --- a/src/main/java/rife/bld/dependencies/Repository.java +++ b/src/main/java/rife/bld/dependencies/Repository.java @@ -161,7 +161,9 @@ public String getArtifactLocation(String groupId, String artifactId) { var separator = "/"; var result = new StringBuilder(); if (isLocal()) { - separator = File.separator; + if (isWindowsLocation()) { + separator = File.separator; + } if (location().startsWith("file://")) { result.append(location().substring("file://".length())); } else { diff --git a/src/test/java/rife/bld/dependencies/TestRepository.java b/src/test/java/rife/bld/dependencies/TestRepository.java index a5892ae..a89ec7c 100644 --- a/src/test/java/rife/bld/dependencies/TestRepository.java +++ b/src/test/java/rife/bld/dependencies/TestRepository.java @@ -5,6 +5,8 @@ package rife.bld.dependencies; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; import rife.ioc.HierarchicalProperties; import java.nio.file.Path; @@ -78,11 +80,25 @@ void testArtifactLocation() { assertEquals("/local/repo/groupId3/artifactId3/", repository3.getArtifactLocation("groupId3", "artifactId3")); } + @Test + @EnabledOnOs(OS.WINDOWS) + void testArtifactLocationWindows() { + var repository1 = new Repository("c:\\local\\repo"); + assertNotNull(repository1); + assertEquals("c:\\local\\repo\\groupId1\\artifactId1\\", repository1.getArtifactLocation("groupId1", "artifactId1")); + + var repository2 = new Repository("E:\\local\\repo"); + assertNotNull(repository2); + assertEquals("E:\\local\\repo\\groupId2\\artifactId2\\", repository2.getArtifactLocation("groupId2", "artifactId2")); + } + @Test void testIsLocal() { assertFalse(new Repository("http://my.repo").isLocal()); assertTrue(new Repository("file:///local/repo").isLocal()); assertTrue(new Repository("//local/repo").isLocal()); + assertTrue(new Repository("c:\\local\\repo").isLocal()); + assertTrue(new Repository("E:\\local\\repo").isLocal()); } @Test