mirror of
https://github.com/rife2/bld
synced 2026-08-04 23:07:46 +02:00
Compare commits
3 commits
5dd1c08c54
...
b9f24ebed9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9f24ebed9 | ||
|
|
396aa142aa | ||
|
|
e2239ab8d2 |
2
core
2
core
|
|
@ -1 +1 @@
|
||||||
Subproject commit be04188f686b15ab0f9d10d924c6cea919328dc9
|
Subproject commit fdce2096637ee6b9cd34fd27f8be207e23f9bb83
|
||||||
|
|
@ -494,7 +494,10 @@ public class BldCache {
|
||||||
var properties = new Properties();
|
var properties = new Properties();
|
||||||
if (getCacheFile().exists()) {
|
if (getCacheFile().exists()) {
|
||||||
try {
|
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);
|
properties.load(reader);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -655,7 +658,7 @@ public class BldCache {
|
||||||
|
|
||||||
cacheDir_.mkdirs();
|
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);
|
properties.store(writer, null);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
||||||
|
|
@ -258,8 +258,11 @@ public class Wrapper {
|
||||||
manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, getClass().getName());
|
manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, getClass().getName());
|
||||||
|
|
||||||
try (var jar = new JarOutputStream(new FileOutputStream(new File(destinationDirectory, WRAPPER_JAR)), manifest)) {
|
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.class);
|
||||||
addClassToJar(jar, Wrapper.LaunchMode.class);
|
addClassToJar(jar, Wrapper.LaunchMode.class);
|
||||||
|
addClassToJar(jar, Wrapper.IoAction.class);
|
||||||
addClassToJar(jar, WrapperClassLoader.class);
|
addClassToJar(jar, WrapperClassLoader.class);
|
||||||
addClassToJar(jar, FileUtils.class);
|
addClassToJar(jar, FileUtils.class);
|
||||||
addClassToJar(jar, FileUtilsErrorException.class);
|
addClassToJar(jar, FileUtilsErrorException.class);
|
||||||
|
|
|
||||||
|
|
@ -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
|
@Test
|
||||||
void testDependencyTreeLifecycle() throws Exception {
|
void testDependencyTreeLifecycle() throws Exception {
|
||||||
var requests = new AtomicInteger();
|
var requests = new AtomicInteger();
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,30 @@ import java.util.*;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TestWrapperExtensionResolver {
|
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
|
@Test
|
||||||
void testNoExtensions()
|
void testNoExtensions()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue