mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 00:07:12 -07:00
Windows related tweaks and fixes
This commit is contained in:
parent
0b9f29a175
commit
cac57b3e4b
9 changed files with 57 additions and 44 deletions
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PDMPlugin">
|
||||
<option name="skipTestSources" value="false" />
|
||||
|
@ -6,4 +5,4 @@
|
|||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="19" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build" />
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
2
core
2
core
|
@ -1 +1 @@
|
|||
Subproject commit 0ad243b95e76bb506e625822a0f7ef9d03733f71
|
||||
Subproject commit 88f7cb4af908d8c093ba9b72e6fc9c7e189fe6e5
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,25 +57,25 @@ public class TestDependencySet {
|
|||
|
||||
var set_union1 = new DependencySet(set1);
|
||||
set_union1.addAll(set2);
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
org.eclipse.jetty:jetty-server:11.0.14
|
||||
org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:5.0.2
|
||||
org.eclipse.jetty:jetty-http:11.0.14
|
||||
org.eclipse.jetty:jetty-io:11.0.14
|
||||
org.eclipse.jetty:jetty-util:11.0.14
|
||||
org.slf4j:slf4j-simple:2.0.6
|
||||
org.slf4j:slf4j-api:2.0.6""", StringUtils.join(set_union1, "\n"));
|
||||
org.slf4j:slf4j-api:2.0.6"""), StringUtils.join(set_union1, System.lineSeparator()));
|
||||
|
||||
var set_union2 = new DependencySet(set2);
|
||||
set_union2.addAll(set1);
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
org.slf4j:slf4j-simple:2.0.6
|
||||
org.slf4j:slf4j-api:2.0.6
|
||||
org.eclipse.jetty:jetty-server:11.0.14
|
||||
org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:5.0.2
|
||||
org.eclipse.jetty:jetty-http:11.0.14
|
||||
org.eclipse.jetty:jetty-io:11.0.14
|
||||
org.eclipse.jetty:jetty-util:11.0.14""", StringUtils.join(set_union2, "\n"));
|
||||
org.eclipse.jetty:jetty-util:11.0.14"""), StringUtils.join(set_union2, System.lineSeparator()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -83,7 +83,7 @@ public class TestDependencySet {
|
|||
var dependencies = new DependencySet()
|
||||
.include(new Dependency("org.eclipse.jetty", "jetty-server", new VersionNumber(11, 0, 14)))
|
||||
.include(new Dependency("org.slf4j", "slf4j-simple", new VersionNumber(2, 0, 6)));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
├─ org.eclipse.jetty:jetty-server:11.0.14
|
||||
│ ├─ org.eclipse.jetty.toolchain:jetty-jakarta-servlet-api:5.0.2
|
||||
│ ├─ org.eclipse.jetty:jetty-http:11.0.14
|
||||
|
@ -91,14 +91,14 @@ public class TestDependencySet {
|
|||
│ └─ org.eclipse.jetty:jetty-io:11.0.14
|
||||
└─ org.slf4j:slf4j-simple:2.0.6
|
||||
└─ org.slf4j:slf4j-api:2.0.6
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateDependencyTreeSpringBoot() {
|
||||
var dependencies = new DependencySet()
|
||||
.include(new Dependency("org.springframework.boot", "spring-boot-starter", new VersionNumber(3, 0, 4)));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
└─ org.springframework.boot:spring-boot-starter:3.0.4
|
||||
├─ org.springframework.boot:spring-boot:3.0.4
|
||||
│ └─ org.springframework:spring-context:6.0.6
|
||||
|
@ -117,14 +117,14 @@ public class TestDependencySet {
|
|||
├─ org.springframework:spring-core:6.0.6
|
||||
│ └─ org.springframework:spring-jcl:6.0.6
|
||||
└─ org.yaml:snakeyaml:1.33
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateDependencyTreeMaven() {
|
||||
var dependencies = new DependencySet()
|
||||
.include(new Dependency("org.apache.maven", "maven-core", new VersionNumber(3, 9, 0)));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
└─ org.apache.maven:maven-core:3.9.0
|
||||
├─ org.apache.maven:maven-model:3.9.0
|
||||
├─ org.apache.maven:maven-settings:3.9.0
|
||||
|
@ -157,14 +157,14 @@ public class TestDependencySet {
|
|||
├─ org.codehaus.plexus:plexus-component-annotations:2.1.0
|
||||
├─ org.apache.commons:commons-lang3:3.8.1
|
||||
└─ org.slf4j:slf4j-api:1.7.36
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateDependencyTreePlay() {
|
||||
var dependencies = new DependencySet()
|
||||
.include(new Dependency("com.typesafe.play", "play_2.13", new VersionNumber(2, 8, 19)));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
└─ com.typesafe.play:play_2.13:2.8.19
|
||||
├─ org.scala-lang:scala-library:2.13.10
|
||||
├─ com.typesafe.play:build-link:2.8.19
|
||||
|
@ -213,14 +213,14 @@ public class TestDependencySet {
|
|||
├─ org.scala-lang.modules:scala-java8-compat_2.13:1.0.2
|
||||
├─ com.typesafe:ssl-config-core_2.13:0.4.3
|
||||
└─ org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateDependencyTreeVaadin() {
|
||||
var dependencies = new DependencySet()
|
||||
.include(new Dependency("com.vaadin", "vaadin", new VersionNumber(23, 3, 7)));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
└─ com.vaadin:vaadin:23.3.7
|
||||
├─ com.vaadin:vaadin-core:23.3.7
|
||||
│ ├─ com.vaadin:flow-server:23.3.4
|
||||
|
@ -309,7 +309,7 @@ public class TestDependencySet {
|
|||
│ ├─ net.java.dev.jna:jna:5.11.0
|
||||
│ └─ net.java.dev.jna:jna-platform:5.11.0
|
||||
└─ com.auth0:java-jwt:3.19.2
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -324,7 +324,7 @@ public class TestDependencySet {
|
|||
.include(new Dependency("commons-codec", "commons-codec", new VersionNumber(1,15)))
|
||||
.include(new Dependency("org.apache.httpcomponents", "httpcore", new VersionNumber(4,4,16)))
|
||||
.include(new Dependency("com.google.zxing", "javase", new VersionNumber(3,5,1)));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
├─ com.uwyn.rife2:rife2:1.5.20
|
||||
├─ com.stripe:stripe-java:20.136.0
|
||||
├─ org.json:json:20230227
|
||||
|
@ -352,14 +352,14 @@ public class TestDependencySet {
|
|||
└─ com.google.zxing:javase:3.5.1
|
||||
├─ com.google.zxing:core:3.5.1
|
||||
└─ com.beust:jcommander:1.82
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL), compile));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateDependencyTreeCompileRuntime() {
|
||||
var dependencies = new DependencySet()
|
||||
.include(new Dependency("net.thauvin.erik", "bitly-shorten", new VersionNumber(0, 9, 4, "SNAPSHOT")));
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
└─ net.thauvin.erik:bitly-shorten:0.9.4-SNAPSHOT
|
||||
├─ org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22
|
||||
│ ├─ org.jetbrains.kotlin:kotlin-stdlib:1.8.22
|
||||
|
@ -371,6 +371,6 @@ public class TestDependencySet {
|
|||
│ └─ com.squareup.okio:okio-jvm:3.2.0
|
||||
├─ com.squareup.okhttp3:logging-interceptor:4.11.0
|
||||
└─ org.json:json:20230618
|
||||
""", dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY), compile, runtime));
|
||||
"""), dependencies.generateTransitiveDependencyTree(ArtifactRetriever.instance(), List.of(MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY), compile, runtime));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import rife.tools.FileUtils;
|
|||
import javax.tools.DiagnosticCollector;
|
||||
import javax.tools.JavaFileObject;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -305,11 +306,11 @@ public class TestCompileOperation {
|
|||
var diagnostic4 = operation.diagnostics().get(3);
|
||||
var diagnostic5 = operation.diagnostics().get(4);
|
||||
|
||||
assertEquals("/Source1.java", diagnostic1.getSource().toUri().getPath().substring(tmp.getAbsolutePath().length()));
|
||||
assertEquals("/Source3.java", diagnostic2.getSource().toUri().getPath().substring(tmp.getAbsolutePath().length()));
|
||||
assertEquals("/Source3.java", diagnostic3.getSource().toUri().getPath().substring(tmp.getAbsolutePath().length()));
|
||||
assertEquals("/Source3.java", diagnostic4.getSource().toUri().getPath().substring(tmp.getAbsolutePath().length()));
|
||||
assertEquals("/Source3.java", diagnostic5.getSource().toUri().getPath().substring(tmp.getAbsolutePath().length()));
|
||||
assertEquals("Source1.java", diagnostic1.getSource().toUri().getPath().substring(tmp.toURI().getPath().length()));
|
||||
assertEquals("Source3.java", diagnostic2.getSource().toUri().getPath().substring(tmp.toURI().getPath().length()));
|
||||
assertEquals("Source3.java", diagnostic3.getSource().toUri().getPath().substring(tmp.toURI().getPath().length()));
|
||||
assertEquals("Source3.java", diagnostic4.getSource().toUri().getPath().substring(tmp.toURI().getPath().length()));
|
||||
assertEquals("Source3.java", diagnostic5.getSource().toUri().getPath().substring(tmp.toURI().getPath().length()));
|
||||
|
||||
assertFalse(build_main_class1.exists());
|
||||
assertFalse(build_main_class2.exists());
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
|
|||
import rife.bld.WebProject;
|
||||
import rife.bld.dependencies.*;
|
||||
import rife.tools.FileUtils;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
@ -80,7 +81,7 @@ public class TestDependencyTreeOperation {
|
|||
|
||||
var tree = operation.dependencyTree();
|
||||
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
compile:
|
||||
├─ com.uwyn.rife2:rife2:1.5.20
|
||||
├─ com.stripe:stripe-java:20.136.0
|
||||
|
@ -120,7 +121,7 @@ public class TestDependencyTreeOperation {
|
|||
test:
|
||||
no dependencies
|
||||
|
||||
""", tree);
|
||||
"""), tree);
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
}
|
||||
|
@ -152,7 +153,7 @@ public class TestDependencyTreeOperation {
|
|||
|
||||
var tree = operation.dependencyTree();
|
||||
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
compile:
|
||||
no dependencies
|
||||
|
||||
|
@ -188,7 +189,7 @@ public class TestDependencyTreeOperation {
|
|||
│ └─ org.eclipse.jetty:jetty-security:11.0.15
|
||||
└─ net.imagej:ij:1.54d
|
||||
|
||||
""", tree);
|
||||
"""), tree);
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
}
|
||||
|
@ -229,7 +230,7 @@ public class TestDependencyTreeOperation {
|
|||
|
||||
var tree = operation.dependencyTree();
|
||||
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
compile:
|
||||
├─ com.uwyn.rife2:rife2:1.5.20
|
||||
├─ com.stripe:stripe-java:20.136.0
|
||||
|
@ -269,7 +270,7 @@ public class TestDependencyTreeOperation {
|
|||
test:
|
||||
no dependencies
|
||||
|
||||
""", tree);
|
||||
"""), tree);
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
}
|
||||
|
@ -305,7 +306,7 @@ public class TestDependencyTreeOperation {
|
|||
|
||||
var tree = operation.dependencyTree();
|
||||
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
compile:
|
||||
no dependencies
|
||||
|
||||
|
@ -341,7 +342,7 @@ public class TestDependencyTreeOperation {
|
|||
│ └─ org.eclipse.jetty:jetty-security:11.0.15
|
||||
└─ net.imagej:ij:1.54d
|
||||
|
||||
""", tree);
|
||||
"""), tree);
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ package rife.bld.operations;
|
|||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.tools.FileUtils;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
@ -191,7 +192,7 @@ public class TestJUnitOperation {
|
|||
return true;
|
||||
})
|
||||
.execute();
|
||||
assertTrue(check_result.toString().contains("""
|
||||
assertTrue(check_result.toString().contains(StringUtils.convertLineSeparator("""
|
||||
[ 2 containers found ]
|
||||
[ 0 containers skipped ]
|
||||
[ 2 containers started ]
|
||||
|
@ -204,7 +205,7 @@ public class TestJUnitOperation {
|
|||
[ 0 tests aborted ]
|
||||
[ 1 tests successful ]
|
||||
[ 0 tests failed ]
|
||||
"""));
|
||||
""")));
|
||||
|
||||
} finally {
|
||||
FileUtils.deleteDirectory(tmp);
|
||||
|
|
|
@ -354,7 +354,7 @@ public class TestJavadocOperation {
|
|||
|
||||
var diagnostic1 = operation.diagnostics().get(0);
|
||||
|
||||
assertEquals("/Source1.java", diagnostic1.getSource().toUri().getPath().substring(tmp.getAbsolutePath().length()));
|
||||
assertEquals("Source1.java", diagnostic1.getSource().toUri().getPath().substring(tmp.toURI().getPath().length()));
|
||||
|
||||
assertFalse(build_html1.exists());
|
||||
assertFalse(build_html2.exists());
|
||||
|
|
|
@ -9,6 +9,7 @@ import rife.bld.dependencies.Dependency;
|
|||
import rife.bld.dependencies.DependencyScopes;
|
||||
import rife.bld.dependencies.Scope;
|
||||
import rife.bld.dependencies.VersionNumber;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -108,7 +109,7 @@ public class TestPomBuilder {
|
|||
|
||||
PomBuilder.generateInto(new PublishInfo().name("the thing"), deps, temp);
|
||||
|
||||
assertEquals("""
|
||||
assertEquals(StringUtils.convertLineSeparator("""
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
@ -126,7 +127,7 @@ public class TestPomBuilder {
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>""", String.join(System.lineSeparator(), Files.readAllLines(temp.toPath())));
|
||||
</project>"""), String.join(System.lineSeparator(), Files.readAllLines(temp.toPath())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue