mirror of
https://github.com/rife2/bld
synced 2026-08-04 23:07:46 +02:00
Compare commits
No commits in common. "b9f24ebed9633078a291ef32664ea898e4c9d7f3" and "5dd1c08c54f493e121ca2412f7dfeb0e32f031d1" have entirely different histories.
b9f24ebed9
...
5dd1c08c54
2
core
2
core
|
|
@ -1 +1 @@
|
||||||
Subproject commit fdce2096637ee6b9cd34fd27f8be207e23f9bb83
|
Subproject commit be04188f686b15ab0f9d10d924c6cea919328dc9
|
||||||
|
|
@ -494,10 +494,7 @@ public class BldCache {
|
||||||
var properties = new Properties();
|
var properties = new Properties();
|
||||||
if (getCacheFile().exists()) {
|
if (getCacheFile().exists()) {
|
||||||
try {
|
try {
|
||||||
// the cache holds dependency trees with box drawing
|
try (var reader = new BufferedReader(new FileReader(getCacheFile()))) {
|
||||||
// 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) {
|
||||||
|
|
@ -658,7 +655,7 @@ public class BldCache {
|
||||||
|
|
||||||
cacheDir_.mkdirs();
|
cacheDir_.mkdirs();
|
||||||
|
|
||||||
try (var writer = new BufferedWriter(new FileWriter(getCacheFile(), StandardCharsets.UTF_8))) {
|
try (var writer = new BufferedWriter(new FileWriter(getCacheFile()))) {
|
||||||
properties.store(writer, null);
|
properties.store(writer, null);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
||||||
|
|
@ -258,11 +258,8 @@ 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,36 +230,6 @@ 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,30 +18,6 @@ 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