Compare commits

...

3 commits

Author SHA1 Message Date
Geert Bevin b9f24ebed9 Include the nested wrapper types in the wrapper jar
Some checks failed
bld-ci / build (./bld, 17, macos-latest, false) (push) Has been cancelled
bld-ci / build (./bld, 21, macos-latest, false) (push) Has been cancelled
bld-ci / build (./bld, 25, macos-latest, false) (push) Has been cancelled
bld-ci / build (./bld, 26, macos-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 17, windows-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 21, windows-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 25, windows-latest, false) (push) Has been cancelled
bld-ci / build (.\bld.bat, 26, windows-latest, false) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 17, ubuntu-latest, true) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 21, ubuntu-latest, true) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 25, ubuntu-latest, true) (push) Has been cancelled
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 26, ubuntu-latest, true) (push) Has been cancelled
javadocs-pages / deploy (push) Has been cancelled
2026-07-27 13:36:33 -04:00
Geert Bevin 396aa142aa Store the bld cache as UTF-8 so that dependency trees survive it 2026-07-27 12:57:57 -04:00
Geert Bevin e2239ab8d2 Updated RIFE2/core 2026-07-27 12:36:38 -04:00
5 changed files with 63 additions and 3 deletions

2
core

@ -1 +1 @@
Subproject commit be04188f686b15ab0f9d10d924c6cea919328dc9
Subproject commit fdce2096637ee6b9cd34fd27f8be207e23f9bb83

View file

@ -494,7 +494,10 @@ public class BldCache {
var properties = new Properties();
if (getCacheFile().exists()) {
try {
try (var reader = new BufferedReader(new FileReader(getCacheFile()))) {
// the cache holds dependency trees with box drawing
// characters, the platform charset can't encode those on
// every JVM and would corrupt them
try (var reader = new BufferedReader(new FileReader(getCacheFile(), StandardCharsets.UTF_8))) {
properties.load(reader);
}
} catch (IOException e) {
@ -655,7 +658,7 @@ public class BldCache {
cacheDir_.mkdirs();
try (var writer = new BufferedWriter(new FileWriter(getCacheFile()))) {
try (var writer = new BufferedWriter(new FileWriter(getCacheFile(), StandardCharsets.UTF_8))) {
properties.store(writer, null);
}
} catch (IOException e) {

View file

@ -258,8 +258,11 @@ public class Wrapper {
manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, getClass().getName());
try (var jar = new JarOutputStream(new FileOutputStream(new File(destinationDirectory, WRAPPER_JAR)), manifest)) {
// every nested type of the wrapper has to be added here too,
// the wrapper jar only contains what is listed
addClassToJar(jar, Wrapper.class);
addClassToJar(jar, Wrapper.LaunchMode.class);
addClassToJar(jar, Wrapper.IoAction.class);
addClassToJar(jar, WrapperClassLoader.class);
addClassToJar(jar, FileUtils.class);
addClassToJar(jar, FileUtilsErrorException.class);

View file

@ -230,6 +230,36 @@ public class TestBldCacheLifecycle {
}
}
@Test
void testDependencyTreeCacheKeepsTreeCharacters() throws Exception {
// the tree is drawn with box drawing characters, the cache file
// has to keep them no matter what the platform charset of the JVM
// is able to encode
var requests = new AtomicInteger();
var server = createArtifactServer(Map.of(
"tool:1.0.0", pom("tool", "1.0.0", dependency("liba", "1.1.0")),
"liba:1.1.0", pom("liba", "1.1.0", "")), requests);
server.start();
var tmp = Files.createTempDirectory("cachelifecycle").toFile();
try {
var build1 = new LifecycleProject(tmp, serverRepository(server));
writeWrapperProperties(build1, server, "");
build1.dependencies().scope(provided)
.include(new Dependency("com.example", "tool", new VersionNumber(1, 0, 0)));
var operation1 = new DependencyTreeOperation().fromProject(build1);
operation1.executeOnce();
assertTrue(operation1.dependencyTree().contains(""), operation1.dependencyTree());
// the characters survive the round trip through the cache file
var cached = FileUtils.readString(new File(build1.libBldDirectory(), BldCache.BLD_CACHE));
assertTrue(cached.contains(""), "the cache file lost the tree characters");
} finally {
server.stop(0);
FileUtils.deleteDirectory(tmp);
}
}
@Test
void testDependencyTreeLifecycle() throws Exception {
var requests = new AtomicInteger();

View file

@ -18,6 +18,30 @@ import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
public class TestWrapperExtensionResolver {
@Test
void testWrapperJarContainsEveryNestedType()
throws Exception {
// the wrapper jar only contains the classes that are listed
// explicitly, a nested type that isn't listed makes the wrapper
// fail with a NoClassDefFoundError while it bootstraps
var tmp = Files.createTempDirectory("wrapperjar").toFile();
try {
new Wrapper().createWrapperFiles(tmp, "2.4.0-SNAPSHOT");
var entries = new java.util.HashSet<String>();
try (var jar = new java.util.jar.JarFile(new File(tmp, "bld-wrapper.jar"))) {
jar.stream().map(java.util.zip.ZipEntry::getName).forEach(entries::add);
}
for (var nested : Wrapper.class.getDeclaredClasses()) {
assertTrue(entries.contains(nested.getName().replace('.', '/') + ".class"),
"the wrapper jar doesn't contain " + nested.getName());
}
} finally {
FileUtils.deleteDirectory(tmp);
}
}
@Test
void testNoExtensions()
throws Exception {