2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-27 00:38:12 -07:00

Windows related tweaks and fixes

This commit is contained in:
Geert Bevin 2023-10-01 12:43:04 -04:00
parent 0b9f29a175
commit cac57b3e4b
9 changed files with 57 additions and 44 deletions

View file

@ -7,8 +7,10 @@ package rife.bld.dependencies;
import rife.ioc.HierarchicalProperties;
import rife.tools.StringEncryptor;
import java.io.File;
import java.nio.file.Path;
import java.security.NoSuchAlgorithmException;
import java.util.regex.Pattern;
/**
* Contains the information required to locate a Maven-compatible repository.
@ -103,6 +105,12 @@ public record Repository(String location, String username, String password) {
this(location, null, null);
}
private final static Pattern WINDOWS_ABSOLUTE_PATH = Pattern.compile("^\\p{L}:\\\\");
private boolean isWindowsLocation() {
return WINDOWS_ABSOLUTE_PATH.matcher(location()).find();
}
/**
* Indicates whether this repository is local.
*
@ -111,7 +119,7 @@ public record Repository(String location, String username, String password) {
* @since 1.5.10
*/
public boolean isLocal() {
return location().startsWith("/") || location().startsWith("file:");
return location().startsWith("/") || location().startsWith("file:") || isWindowsLocation();
}
/**
@ -147,9 +155,10 @@ public record Repository(String location, String username, String password) {
* @since 1.5.10
*/
public String getArtifactLocation(String groupId, String artifactId) {
var group_path = groupId.replace(".", "/");
var separator = "/";
var result = new StringBuilder();
if (isLocal()) {
separator = File.separator;
if (location().startsWith("file://")) {
result.append(location().substring("file://".length()));
} else {
@ -158,10 +167,11 @@ public record Repository(String location, String username, String password) {
} else {
result.append(location());
}
if (!location().endsWith("/")) {
result.append("/");
if (!location().endsWith(separator)) {
result.append(separator);
}
return result.append(group_path).append("/").append(artifactId).append("/").toString();
var group_path = groupId.replace(".", separator);
return result.append(group_path).append(separator).append(artifactId).append(separator).toString();
}
/**