Skip to content

Commit

Permalink
More Windows tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Oct 1, 2023
1 parent 35887e7 commit 7face79
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/rife/bld/dependencies/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/rife/bld/dependencies/TestRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7face79

Please sign in to comment.