mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 16:27:11 -07:00
Consolidate all hashing and caching into a single properties file instead of multiple files
This commit is contained in:
parent
604f5ba424
commit
9614bd8014
8 changed files with 330 additions and 231 deletions
Binary file not shown.
|
@ -1595,83 +1595,23 @@ public class BaseProject extends BuildExecutor {
|
|||
purge();
|
||||
}
|
||||
|
||||
private static final String BLD_BUILD_HASH = "bld-build.hash";
|
||||
|
||||
private void performAutoDownloadPurge() {
|
||||
// verify and update the fingerprint hash file,
|
||||
// don't download and purge if the hash is identical
|
||||
var hash_file = new File(libBldDirectory(), BLD_BUILD_HASH);
|
||||
var hash = createHash();
|
||||
if (validateHash(hash_file, hash)) {
|
||||
var resolution = new VersionResolution(properties());
|
||||
var cache = new BldCache(libBldDirectory(), resolution);
|
||||
cache.fingerprintDependencies(repositories(), dependencies(), downloadSources(), downloadJavadoc());
|
||||
if (cache.isDependenciesHashValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
executeAutoDownloadPurge();
|
||||
|
||||
writeHash(hash_file, hash);
|
||||
cache.writeCache();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String createHash() {
|
||||
var resolution = new VersionResolution(properties());
|
||||
var finger_print = new StringBuilder();
|
||||
finger_print.append(String.join("\n", resolution.versionOverrides().entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).toList()));
|
||||
for (var repository : repositories()) {
|
||||
finger_print.append(repository.toString());
|
||||
finger_print.append('\n');
|
||||
}
|
||||
for (var entry : dependencies().entrySet()) {
|
||||
finger_print.append(entry.getKey());
|
||||
finger_print.append('\n');
|
||||
if (entry.getValue() != null) {
|
||||
for (var dependency : entry.getValue()) {
|
||||
finger_print.append(dependency.toString());
|
||||
finger_print.append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
finger_print.append(downloadSources())
|
||||
.append('\n')
|
||||
.append(downloadJavadoc())
|
||||
.append('\n');
|
||||
|
||||
try {
|
||||
var digest = MessageDigest.getInstance("SHA-1");
|
||||
digest.update(finger_print.toString().getBytes(StandardCharsets.UTF_8));
|
||||
return StringUtils.encodeHexLower(digest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// should not happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateHash(File hashFile, String hash) {
|
||||
try {
|
||||
if (hashFile.exists()) {
|
||||
var current_hash = FileUtils.readString(hashFile);
|
||||
if (current_hash.equals(hash)) {
|
||||
return true;
|
||||
}
|
||||
hashFile.delete();
|
||||
}
|
||||
return false;
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeHash(File hashFile, String hash) {
|
||||
try {
|
||||
hashFile.getParentFile().mkdirs();
|
||||
FileUtils.writeString(hash, hashFile);
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute(String[] arguments) {
|
||||
if (!offline() &&
|
||||
|
|
200
src/main/java/rife/bld/BldCache.java
Normal file
200
src/main/java/rife/bld/BldCache.java
Normal file
|
@ -0,0 +1,200 @@
|
|||
/*
|
||||
* Copyright 2001-2023 Geert Bevin (gbevin[remove] at uwyn dot com)
|
||||
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||
*/
|
||||
package rife.bld;
|
||||
|
||||
import rife.bld.dependencies.DependencyScopes;
|
||||
import rife.bld.dependencies.Repository;
|
||||
import rife.bld.dependencies.VersionResolution;
|
||||
import rife.bld.wrapper.Wrapper;
|
||||
import rife.tools.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Geert Bevin (gbevin[remove] at uwyn dot com)
|
||||
* @since 2.0
|
||||
*/
|
||||
public class BldCache {
|
||||
public static final String BLD_CACHE = "bld.cache";
|
||||
|
||||
private static final String PROPERTY_SUFFIX_HASH = ".hash";
|
||||
private static final String PROPERTY_SUFFIX_LOCAL = ".local";
|
||||
|
||||
public static final String WRAPPER_PROPERTIES_HASH = Wrapper.WRAPPER_PROPERTIES + PROPERTY_SUFFIX_HASH;
|
||||
public static final String BLD_BUILD_HASH = "bld-build" + PROPERTY_SUFFIX_HASH;
|
||||
|
||||
private static final String PROPERTY_EXTENSIONS_PREFIX = "bld.extensions";
|
||||
private static final String PROPERTY_EXTENSIONS_HASH = PROPERTY_EXTENSIONS_PREFIX + PROPERTY_SUFFIX_HASH;
|
||||
private static final String PROPERTY_EXTENSIONS_LOCAL = PROPERTY_EXTENSIONS_PREFIX + PROPERTY_SUFFIX_LOCAL;
|
||||
|
||||
private static final String PROPERTY_DEPENDENCIES_PREFIX = "bld.dependencies";
|
||||
private static final String PROPERTY_DEPENDENCIES_HASH = PROPERTY_DEPENDENCIES_PREFIX + PROPERTY_SUFFIX_HASH;
|
||||
|
||||
private final File hashFile_;
|
||||
private final Properties hashProperties_ = new Properties();
|
||||
private final VersionResolution resolution_;
|
||||
private String extensionsHash_;
|
||||
private String dependenciesHash_;
|
||||
|
||||
public BldCache(File bldLibDir, VersionResolution resolution) {
|
||||
hashFile_ = new File(bldLibDir, BLD_CACHE);
|
||||
resolution_ = resolution;
|
||||
|
||||
new File(bldLibDir, WRAPPER_PROPERTIES_HASH).delete();
|
||||
new File(bldLibDir, BLD_BUILD_HASH).delete();
|
||||
|
||||
if (hashFile_.exists()) {
|
||||
try {
|
||||
hashProperties_.load(new FileInputStream(hashFile_));
|
||||
} catch (IOException e) {
|
||||
// no-op, we'll store a new properties file when we're writing the cache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fingerprintExtensions(Collection<String> repositories, Collection<String> extensions, boolean downloadSources, boolean downloadJavadoc) {
|
||||
try {
|
||||
var overrides_fp = String.join("\n", resolution_.versionOverrides().entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).toList());
|
||||
var repositories_fp = String.join("\n", repositories);
|
||||
var extensions_fp = String.join("\n", extensions);
|
||||
var fingerprint = overrides_fp + "\n" + repositories_fp + "\n" + extensions_fp + "\n" + downloadSources + "\n" + downloadJavadoc;
|
||||
var digest = MessageDigest.getInstance("SHA-1");
|
||||
digest.update(fingerprint.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
extensionsHash_ = StringUtils.encodeHexLower(digest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// should not happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void fingerprintDependencies(List<Repository> repositories, DependencyScopes dependencies, boolean downloadSources, boolean downloadJavadoc) {
|
||||
var finger_print = new StringBuilder();
|
||||
finger_print.append(String.join("\n", resolution_.versionOverrides().entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).toList()));
|
||||
for (var repository : repositories) {
|
||||
finger_print.append(repository.toString());
|
||||
finger_print.append('\n');
|
||||
}
|
||||
for (var entry : dependencies.entrySet()) {
|
||||
finger_print.append(entry.getKey());
|
||||
finger_print.append('\n');
|
||||
if (entry.getValue() != null) {
|
||||
for (var dependency : entry.getValue()) {
|
||||
finger_print.append(dependency.toString());
|
||||
finger_print.append('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
finger_print.append(downloadSources)
|
||||
.append('\n')
|
||||
.append(downloadJavadoc)
|
||||
.append('\n');
|
||||
|
||||
try {
|
||||
var digest = MessageDigest.getInstance("SHA-1");
|
||||
digest.update(finger_print.toString().getBytes(StandardCharsets.UTF_8));
|
||||
dependenciesHash_ = StringUtils.encodeHexLower(digest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// should not happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isExtensionHashValid() {
|
||||
return validateExtensionsHash(extensionsHash_);
|
||||
}
|
||||
|
||||
private boolean validateExtensionsHash(String hash) {
|
||||
if (!hashFile_.exists() || hashProperties_.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!hash.equals(hashProperties_.getProperty(PROPERTY_EXTENSIONS_HASH))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var local_files = hashProperties_.getProperty(PROPERTY_EXTENSIONS_LOCAL);
|
||||
if (local_files != null && !local_files.isEmpty()) {
|
||||
var lines = StringUtils.split(local_files, "\n");
|
||||
if (!lines.isEmpty()) {
|
||||
// other lines are last modified timestamps of local files
|
||||
// that were dependency artifacts
|
||||
while (!lines.isEmpty()) {
|
||||
var line = lines.get(0);
|
||||
var parts = line.split(":", 2);
|
||||
// verify that the local file has the same modified timestamp still
|
||||
if (parts.length == 2) {
|
||||
var file = new File(parts[1]);
|
||||
if (!file.exists() || !file.canRead() || file.lastModified() != Long.parseLong(parts[0])) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
lines.remove(0);
|
||||
}
|
||||
|
||||
// there were no invalid lines, so the hash file contents are valid
|
||||
return lines.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isDependenciesHashValid() {
|
||||
return validateDependenciesHash(dependenciesHash_);
|
||||
}
|
||||
|
||||
private boolean validateDependenciesHash(String hash) {
|
||||
if (!hashFile_.exists() || hashProperties_.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return hash.equals(hashProperties_.getProperty(PROPERTY_DEPENDENCIES_HASH));
|
||||
}
|
||||
|
||||
public void writeCache() {
|
||||
writeCache(null);
|
||||
}
|
||||
|
||||
public void writeCache(List<File> extensionsLocalArtifacts) {
|
||||
try {
|
||||
if (extensionsHash_ != null) {
|
||||
hashProperties_.put(PROPERTY_EXTENSIONS_HASH, extensionsHash_);
|
||||
}
|
||||
|
||||
if (extensionsLocalArtifacts != null) {
|
||||
var extensions_local = new StringBuilder();
|
||||
for (var file : extensionsLocalArtifacts) {
|
||||
if (file.exists() && file.canRead()) {
|
||||
extensions_local.append("\n").append(file.lastModified()).append(':').append(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
hashProperties_.put(PROPERTY_EXTENSIONS_LOCAL, extensions_local.toString());
|
||||
}
|
||||
|
||||
if (dependenciesHash_ != null) {
|
||||
hashProperties_.put(PROPERTY_DEPENDENCIES_HASH, dependenciesHash_);
|
||||
}
|
||||
|
||||
hashFile_.getParentFile().mkdirs();
|
||||
hashProperties_.store(new FileOutputStream(hashFile_), null);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -439,6 +439,7 @@ public class BuildExecutor {
|
|||
|
||||
// try to find a match for the provided command amongst
|
||||
// the ones that are known
|
||||
var matched = false;
|
||||
if (definition == null) {
|
||||
// try to find starting matching options
|
||||
var matches = new ArrayList<>(buildCommands().keySet().stream()
|
||||
|
@ -463,7 +464,7 @@ public class BuildExecutor {
|
|||
// only proceed if exactly one match was found
|
||||
if (matches.size() == 1) {
|
||||
matched_command = matches.get(0);
|
||||
System.out.println("Executing matched command: " + matched_command);
|
||||
matched = true;
|
||||
definition = buildCommands().get(matched_command);
|
||||
}
|
||||
}
|
||||
|
@ -473,6 +474,13 @@ public class BuildExecutor {
|
|||
currentCommandName_.set(matched_command);
|
||||
currentCommandDefinition_.set(definition);
|
||||
try {
|
||||
if (matched) {
|
||||
System.out.println("Executing matched command: " + matched_command);
|
||||
}
|
||||
else {
|
||||
System.out.println("Executing command: " + currentCommandName_);
|
||||
}
|
||||
|
||||
definition.execute();
|
||||
} catch (ExitStatusException e) {
|
||||
exitStatus(e.getExitStatus());
|
||||
|
|
|
@ -44,23 +44,23 @@ public class Wrapper {
|
|||
public static final String OFFLINE_ARGUMENT = "--offline";
|
||||
public static final String HELP_COMMAND = "help";
|
||||
|
||||
public static final String WRAPPER_PREFIX = "bld-wrapper";
|
||||
public static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties";
|
||||
|
||||
static final String MAVEN_CENTRAL = "https://repo1.maven.org/maven2/";
|
||||
static final String SONATYPE_SNAPSHOTS = "https://s01.oss.sonatype.org/content/repositories/snapshots/";
|
||||
static final String DOWNLOAD_LOCATION = MAVEN_CENTRAL + "com/uwyn/rife2/bld/${version}/";
|
||||
static final String DOWNLOAD_LOCATION_SNAPSHOT = SONATYPE_SNAPSHOTS + "com/uwyn/rife2/bld/${version}/";
|
||||
static final String BLD_CACHE = "bld.cache";
|
||||
static final String BLD_FILENAME = "bld-${version}.jar";
|
||||
static final String BLD_SOURCES_FILENAME = "bld-${version}-sources.jar";
|
||||
static final String BLD_VERSION = "BLD_VERSION";
|
||||
static final String BLD_BUILD_HASH = "bld-build.hash";
|
||||
static final String WRAPPER_PREFIX = "bld-wrapper";
|
||||
static final String WRAPPER_PROPERTIES = WRAPPER_PREFIX + ".properties";
|
||||
static final String WRAPPER_JAR = WRAPPER_PREFIX + ".jar";
|
||||
static final String BLD_PROPERTY_VERSION = "bld.version";
|
||||
static final String RIFE2_PROPERTY_DOWNLOAD_LOCATION = "rife2.downloadLocation";
|
||||
static final String BLD_PROPERTY_DOWNLOAD_LOCATION = "bld.downloadLocation";
|
||||
static final String PROPERTY_REPOSITORIES = "bld.repositories";
|
||||
static final String PROPERTY_EXTENSION_PREFIX = "bld.extension";
|
||||
static final String PROPERTY_EXTENSIONS = "bld.extensions";
|
||||
static final String PROPERTY_DOWNLOAD_EXTENSION_SOURCES = "bld.downloadExtensionSources";
|
||||
static final String PROPERTY_DOWNLOAD_EXTENSION_JAVADOC = "bld.downloadExtensionJavadoc";
|
||||
static final String PROPERTY_SOURCE_DIRECTORIES = "bld.sourceDirectories";
|
||||
|
@ -637,9 +637,9 @@ public class Wrapper {
|
|||
|
||||
try {
|
||||
var resolver_class = classloader_.loadClass("rife.bld.wrapper.WrapperExtensionResolver");
|
||||
var constructor = resolver_class.getConstructor(File.class, File.class, File.class, Properties.class, Properties.class, Collection.class, Collection.class, boolean.class, boolean.class);
|
||||
var constructor = resolver_class.getConstructor(File.class, File.class, Properties.class, Properties.class, Collection.class, Collection.class, boolean.class, boolean.class);
|
||||
var update_method = resolver_class.getMethod("updateExtensions");
|
||||
var resolver = constructor.newInstance(currentDir_, new File(wrapperPropertiesFile_.getAbsolutePath() + ".hash"), libBldDirectory(),
|
||||
var resolver = constructor.newInstance(currentDir_, libBldDirectory(),
|
||||
jvmProperties_, wrapperProperties_,
|
||||
repositories_, extensions_,
|
||||
downloadExtensionSources_, downloadExtensionJavadoc_);
|
||||
|
|
|
@ -4,17 +4,12 @@
|
|||
*/
|
||||
package rife.bld.wrapper;
|
||||
|
||||
import rife.bld.BldCache;
|
||||
import rife.bld.BuildExecutor;
|
||||
import rife.bld.dependencies.*;
|
||||
import rife.ioc.HierarchicalProperties;
|
||||
import rife.tools.FileUtils;
|
||||
import rife.tools.StringUtils;
|
||||
import rife.tools.exceptions.FileUtilsErrorException;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
|
||||
import static rife.bld.dependencies.Dependency.CLASSIFIER_JAVADOC;
|
||||
|
@ -31,8 +26,7 @@ import static rife.bld.dependencies.Dependency.CLASSIFIER_SOURCES;
|
|||
public class WrapperExtensionResolver {
|
||||
private final VersionResolution resolution_;
|
||||
private final ArtifactRetriever retriever_;
|
||||
private final File hashFile_;
|
||||
private final String fingerPrintHash_;
|
||||
private final BldCache cache_;
|
||||
private final File destinationDirectory_;
|
||||
private final List<Repository> repositories_ = new ArrayList<>();
|
||||
private final DependencySet dependencies_ = new DependencySet();
|
||||
|
@ -42,7 +36,7 @@ public class WrapperExtensionResolver {
|
|||
|
||||
private boolean headerPrinted_ = false;
|
||||
|
||||
public WrapperExtensionResolver(File currentDir, File hashFile, File destinationDirectory,
|
||||
public WrapperExtensionResolver(File currentDir, File destinationDirectory,
|
||||
Properties jvmProperties, Properties wrapperProperties,
|
||||
Collection<String> repositories, Collection<String> extensions,
|
||||
boolean downloadSources, boolean downloadJavadoc) {
|
||||
|
@ -56,7 +50,7 @@ public class WrapperExtensionResolver {
|
|||
retriever_ = ArtifactRetriever.cachingInstance();
|
||||
Repository.resolveMavenLocal(properties);
|
||||
|
||||
hashFile_ = hashFile;
|
||||
cache_ = new BldCache(destinationDirectory, resolution_);
|
||||
|
||||
destinationDirectory_ = destinationDirectory;
|
||||
|
||||
|
@ -68,32 +62,16 @@ public class WrapperExtensionResolver {
|
|||
|
||||
downloadSources_ = downloadSources;
|
||||
downloadJavadoc_ = downloadJavadoc;
|
||||
fingerPrintHash_ = createHash(
|
||||
resolution_,
|
||||
cache_.fingerprintExtensions(
|
||||
repositories_.stream().map(Objects::toString).toList(),
|
||||
dependencies_.stream().map(Objects::toString).toList(),
|
||||
downloadSources, downloadJavadoc);
|
||||
}
|
||||
|
||||
private static String createHash(VersionResolution resolution, Collection<String> repositories, Collection<String> extensions, boolean downloadSources, boolean downloadJavadoc) {
|
||||
try {
|
||||
var overrides_fp = String.join("\n", resolution.versionOverrides().entrySet().stream().map(e -> e.getKey() + ":" + e.getValue()).toList());
|
||||
var repositories_fp = String.join("\n", repositories);
|
||||
var extensions_fp = String.join("\n", extensions);
|
||||
var fingerprint = overrides_fp + "\n" + repositories_fp + "\n" + extensions_fp + "\n" + downloadSources + "\n" + downloadJavadoc;
|
||||
var digest = MessageDigest.getInstance("SHA-1");
|
||||
digest.update(fingerprint.getBytes(StandardCharsets.UTF_8));
|
||||
return StringUtils.encodeHexLower(digest.digest());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// should not happen
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateExtensions() {
|
||||
// verify and update the fingerprint hash file,
|
||||
// don't update the extensions if the hash is identical
|
||||
if (validateHash()) {
|
||||
if (cache_.isExtensionHashValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -103,68 +81,13 @@ public class WrapperExtensionResolver {
|
|||
// purge the files that are not part of the latest extensions anymore
|
||||
purgeExtensionDependencies(filenames);
|
||||
|
||||
writeHash();
|
||||
cache_.writeCache(localArtifacts_);
|
||||
|
||||
if (headerPrinted_) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validateHash() {
|
||||
try {
|
||||
if (hashFile_.exists()) {
|
||||
var contents = FileUtils.readString(hashFile_);
|
||||
var lines = StringUtils.split(contents, "\n");
|
||||
if (!lines.isEmpty()) {
|
||||
// first line is the fingerprint hash
|
||||
if (lines.remove(0).equals(fingerPrintHash_)) {
|
||||
// other lines are last modified timestamps of local files
|
||||
// that were dependency artifacts
|
||||
while (!lines.isEmpty()) {
|
||||
var line = lines.get(0);
|
||||
var parts = line.split(":", 2);
|
||||
// verify that the local file has the same modified timestamp still
|
||||
if (parts.length == 2) {
|
||||
var file = new File(parts[1]);
|
||||
if (!file.exists() || !file.canRead() || file.lastModified() != Long.parseLong(parts[0])) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
lines.remove(0);
|
||||
}
|
||||
|
||||
// there were no invalid lines, so the hash file contents are valid
|
||||
if (lines.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
hashFile_.delete();
|
||||
}
|
||||
return false;
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeHash() {
|
||||
try {
|
||||
var contents = new StringBuilder();
|
||||
contents.append(fingerPrintHash_);
|
||||
for (var file : localArtifacts_) {
|
||||
if (file.exists() && file.canRead()) {
|
||||
contents.append("\n").append(file.lastModified()).append(':').append(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
FileUtils.writeString(contents.toString(), hashFile_);
|
||||
} catch (FileUtilsErrorException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> transferExtensionDependencies() {
|
||||
var filenames = new HashSet<String>();
|
||||
var dependencies = new DependencySet();
|
||||
|
@ -204,7 +127,7 @@ public class WrapperExtensionResolver {
|
|||
private void purgeExtensionDependencies(Set<String> filenames) {
|
||||
for (var file : destinationDirectory_.listFiles()) {
|
||||
if (file.getName().startsWith(Wrapper.WRAPPER_PREFIX) ||
|
||||
file.getName().equals(Wrapper.BLD_BUILD_HASH)) {
|
||||
file.getName().equals(Wrapper.BLD_CACHE)) {
|
||||
continue;
|
||||
}
|
||||
if (!filenames.contains(file.getName())) {
|
||||
|
|
|
@ -361,7 +361,7 @@ public class TestProject {
|
|||
assertEquals("""
|
||||
/lib
|
||||
/lib/bld
|
||||
/lib/bld/bld-build.hash
|
||||
/lib/bld/bld.cache
|
||||
/lib/compile
|
||||
/lib/compile/rife2-1.5.11.jar
|
||||
/lib/provided
|
||||
|
@ -385,7 +385,7 @@ public class TestProject {
|
|||
assertEquals("""
|
||||
/lib
|
||||
/lib/bld
|
||||
/lib/bld/bld-build.hash""", FileUtils.generateDirectoryListing(tmp));
|
||||
/lib/bld/bld.cache""", FileUtils.generateDirectoryListing(tmp));
|
||||
|
||||
project = new CustomProjectAutoPurge(tmp);
|
||||
project.enableAutoDownloadPurge();
|
||||
|
@ -393,7 +393,7 @@ public class TestProject {
|
|||
assertEquals("""
|
||||
/lib
|
||||
/lib/bld
|
||||
/lib/bld/bld-build.hash""", FileUtils.generateDirectoryListing(tmp));
|
||||
/lib/bld/bld.cache""", FileUtils.generateDirectoryListing(tmp));
|
||||
|
||||
project = new CustomProjectAutoPurge(tmp);
|
||||
project.enableAutoDownloadPurge();
|
||||
|
@ -402,7 +402,7 @@ public class TestProject {
|
|||
assertEquals("""
|
||||
/lib
|
||||
/lib/bld
|
||||
/lib/bld/bld-build.hash
|
||||
/lib/bld/bld.cache
|
||||
/lib/compile
|
||||
/lib/compile/rife2-1.5.12.jar
|
||||
/lib/provided
|
||||
|
@ -426,7 +426,7 @@ public class TestProject {
|
|||
assertEquals("""
|
||||
/lib
|
||||
/lib/bld
|
||||
/lib/bld/bld-build.hash
|
||||
/lib/bld/bld.cache
|
||||
/lib/compile
|
||||
/lib/compile/rife2-1.5.15.jar
|
||||
/lib/provided
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package rife.bld.wrapper;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.bld.BldCache;
|
||||
import rife.bld.BldVersion;
|
||||
import rife.bld.dependencies.VersionResolution;
|
||||
import rife.tools.FileUtils;
|
||||
|
@ -25,7 +26,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -34,16 +35,17 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), Collections.emptySet(), Collections.emptySet(), false, false);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), Collections.emptySet(), Collections.emptySet(), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files2.size());
|
||||
assertEquals(3, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files2));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files2));
|
||||
} finally {
|
||||
tmp2.delete();
|
||||
tmp1.delete();
|
||||
|
@ -58,7 +60,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -67,14 +69,14 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2,
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2,
|
||||
new Properties(), new Properties(),
|
||||
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files2.size());
|
||||
assertEquals(10, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -83,6 +85,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files2));
|
||||
|
@ -100,7 +103,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -111,14 +114,14 @@ public class TestWrapperExtensionResolver {
|
|||
|
||||
var properties = new Properties();
|
||||
properties.put(VersionResolution.PROPERTY_OVERRIDE_PREFIX, "org.antlr:antlr4:4.11.0");
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2,
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2,
|
||||
properties, new Properties(),
|
||||
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files2.size());
|
||||
assertEquals(10, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -127,6 +130,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.0.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files2));
|
||||
|
@ -144,7 +148,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -155,14 +159,14 @@ public class TestWrapperExtensionResolver {
|
|||
|
||||
var properties = new Properties();
|
||||
properties.put(VersionResolution.PROPERTY_OVERRIDE_PREFIX, "org.glassfish:javax.json:1.1.3");
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2,
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2,
|
||||
properties, new Properties(),
|
||||
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(10, files2.size());
|
||||
assertEquals(11, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -171,6 +175,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.3.jar
|
||||
javax.json-api-1.1.3.jar
|
||||
|
@ -189,7 +194,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -198,12 +203,12 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, false);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(16, files2.size());
|
||||
assertEquals(17, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4-sources.jar
|
||||
|
@ -216,6 +221,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1-sources.jar
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4-sources.jar
|
||||
|
@ -236,7 +242,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -245,12 +251,12 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, true);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, true);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(16, files2.size());
|
||||
assertEquals(17, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4-javadoc.jar
|
||||
|
@ -263,6 +269,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1-javadoc.jar
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4-javadoc.jar
|
||||
|
@ -283,7 +290,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -292,12 +299,12 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, true);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, true);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(23, files2.size());
|
||||
assertEquals(24, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4-javadoc.jar
|
||||
|
@ -314,6 +321,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1-javadoc.jar
|
||||
icu4j-71.1-sources.jar
|
||||
icu4j-71.1.jar
|
||||
|
@ -337,7 +345,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -348,14 +356,14 @@ public class TestWrapperExtensionResolver {
|
|||
|
||||
var properties = new Properties();
|
||||
properties.put(VersionResolution.PROPERTY_OVERRIDE_PREFIX, "org.antlr:antlr4:4.11.0");
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2,
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2,
|
||||
properties, new Properties(),
|
||||
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), true, true);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(23, files2.size());
|
||||
assertEquals(24, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4-javadoc.jar
|
||||
|
@ -372,6 +380,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.0.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1-javadoc.jar
|
||||
icu4j-71.1-sources.jar
|
||||
icu4j-71.1.jar
|
||||
|
@ -395,7 +404,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -407,12 +416,12 @@ public class TestWrapperExtensionResolver {
|
|||
var properties = new File(tmp1, "local.properties");
|
||||
FileUtils.writeString("bld.repo.testrepo=" + MAVEN_CENTRAL, properties);
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of("testrepo"), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of("testrepo"), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files2.size());
|
||||
assertEquals(10, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -421,6 +430,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files2));
|
||||
|
@ -438,7 +448,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -447,31 +457,34 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files = tmp2.listFiles();
|
||||
assertEquals(9, files.length);
|
||||
assertEquals(10, files.length);
|
||||
Arrays.stream(files).forEach(file -> {
|
||||
if (!file.getName().startsWith(Wrapper.WRAPPER_PREFIX)) {
|
||||
if (!file.getName().startsWith(Wrapper.WRAPPER_PREFIX) &&
|
||||
!file.getName().equals(BldCache.BLD_CACHE)) {
|
||||
file.delete();
|
||||
}
|
||||
});
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files2.size());
|
||||
assertEquals(3, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files2));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files2));
|
||||
|
||||
resolver.updateExtensions();
|
||||
var files3 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files3.size());
|
||||
assertEquals(3, files3.size());
|
||||
Collections.sort(files3);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files3));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files3));
|
||||
} finally {
|
||||
tmp2.delete();
|
||||
tmp1.delete();
|
||||
|
@ -486,7 +499,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -495,36 +508,39 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files = tmp2.listFiles();
|
||||
assertEquals(9, files.length);
|
||||
assertEquals(10, files.length);
|
||||
Arrays.stream(files).forEach(file -> {
|
||||
if (!file.getName().startsWith(Wrapper.WRAPPER_PREFIX)) {
|
||||
if (!file.getName().startsWith(Wrapper.WRAPPER_PREFIX) &&
|
||||
!file.getName().equals(BldCache.BLD_CACHE)) {
|
||||
file.delete();
|
||||
}
|
||||
});
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files2.size());
|
||||
assertEquals(3, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files2));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files2));
|
||||
|
||||
resolver.updateExtensions();
|
||||
var files3 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files3.size());
|
||||
assertEquals(3, files3.size());
|
||||
Collections.sort(files3);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files3));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files3));
|
||||
hash_file.delete();
|
||||
|
||||
resolver.updateExtensions();
|
||||
var files4 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files4.size());
|
||||
assertEquals(10, files4.size());
|
||||
Collections.sort(files4);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -533,6 +549,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files4));
|
||||
|
@ -550,7 +567,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -559,36 +576,40 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
var resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files = tmp2.listFiles();
|
||||
assertEquals(9, files.length);
|
||||
assertEquals(10, files.length);
|
||||
Arrays.stream(files).forEach(file -> {
|
||||
if (!file.getName().startsWith(Wrapper.WRAPPER_PREFIX)) {
|
||||
if (!file.getName().startsWith(Wrapper.WRAPPER_PREFIX) &&
|
||||
!file.getName().equals(BldCache.BLD_CACHE)) {
|
||||
file.delete();
|
||||
}
|
||||
});
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files2.size());
|
||||
assertEquals(3, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files2));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files2));
|
||||
|
||||
resolver.updateExtensions();
|
||||
var files3 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files3.size());
|
||||
assertEquals(3, files3.size());
|
||||
Collections.sort(files3);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files3));
|
||||
bld-wrapper.properties
|
||||
bld.cache""", String.join("\n", files3));
|
||||
FileUtils.writeString("updated", hash_file);
|
||||
|
||||
resolver = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver.updateExtensions();
|
||||
var files4 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files4.size());
|
||||
assertEquals(10, files4.size());
|
||||
Collections.sort(files4);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -597,6 +618,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files4));
|
||||
|
@ -614,7 +636,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -623,12 +645,12 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver1 = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
var resolver1 = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver1.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files2.size());
|
||||
assertEquals(10, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -637,14 +659,15 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files2));
|
||||
|
||||
var resolver2 = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1", "org.jsoup:jsoup:1.15.4"), false, false);
|
||||
var resolver2 = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1", "org.jsoup:jsoup:1.15.4"), false, false);
|
||||
resolver2.updateExtensions();
|
||||
var files3 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(10, files3.size());
|
||||
assertEquals(11, files3.size());
|
||||
Collections.sort(files3);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -653,6 +676,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
jsoup-1.15.4.jar
|
||||
|
@ -671,7 +695,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -680,12 +704,12 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver1 = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1", "org.jsoup:jsoup:1.15.4"), false, false);
|
||||
var resolver1 = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1", "org.jsoup:jsoup:1.15.4"), false, false);
|
||||
resolver1.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(10, files2.size());
|
||||
assertEquals(11, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -694,19 +718,21 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
jsoup-1.15.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files2));
|
||||
|
||||
var resolver2 = new WrapperExtensionResolver(tmp1, hash_file, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.jsoup:jsoup:1.15.4"), false, false);
|
||||
var resolver2 = new WrapperExtensionResolver(tmp1, tmp2, new Properties(), new Properties(), List.of(MAVEN_CENTRAL), List.of("org.jsoup:jsoup:1.15.4"), false, false);
|
||||
resolver2.updateExtensions();
|
||||
var files3 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(3, files3.size());
|
||||
assertEquals(4, files3.size());
|
||||
Collections.sort(files3);
|
||||
assertEquals("""
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
jsoup-1.15.4.jar""", String.join("\n", files3));
|
||||
} finally {
|
||||
tmp2.delete();
|
||||
|
@ -722,7 +748,7 @@ public class TestWrapperExtensionResolver {
|
|||
try {
|
||||
new Wrapper().createWrapperFiles(tmp2, BldVersion.getVersion());
|
||||
|
||||
var hash_file = new File(tmp1, "wrapper.hash");
|
||||
var hash_file = new File(tmp2, BldCache.BLD_CACHE);
|
||||
assertFalse(hash_file.exists());
|
||||
var files1 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(2, files1.size());
|
||||
|
@ -731,14 +757,14 @@ public class TestWrapperExtensionResolver {
|
|||
bld-wrapper.jar
|
||||
bld-wrapper.properties""", String.join("\n", files1));
|
||||
|
||||
var resolver1 = new WrapperExtensionResolver(tmp1, hash_file, tmp2,
|
||||
var resolver1 = new WrapperExtensionResolver(tmp1, tmp2,
|
||||
new Properties(), new Properties(),
|
||||
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver1.updateExtensions();
|
||||
|
||||
assertTrue(hash_file.exists());
|
||||
var files2 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files2.size());
|
||||
assertEquals(10, files2.size());
|
||||
Collections.sort(files2);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -747,18 +773,19 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.1.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files2));
|
||||
|
||||
var properties = new Properties();
|
||||
properties.put(VersionResolution.PROPERTY_OVERRIDE_PREFIX, "org.antlr:antlr4:4.11.0");
|
||||
var resolver2 = new WrapperExtensionResolver(tmp1, hash_file, tmp2,
|
||||
var resolver2 = new WrapperExtensionResolver(tmp1, tmp2,
|
||||
properties, new Properties(),
|
||||
List.of(MAVEN_CENTRAL), List.of("org.antlr:antlr4:4.11.1"), false, false);
|
||||
resolver2.updateExtensions();
|
||||
var files3 = FileUtils.getFileList(tmp2);
|
||||
assertEquals(9, files3.size());
|
||||
assertEquals(10, files3.size());
|
||||
Collections.sort(files3);
|
||||
assertEquals("""
|
||||
ST4-4.3.4.jar
|
||||
|
@ -767,6 +794,7 @@ public class TestWrapperExtensionResolver {
|
|||
antlr4-runtime-4.11.0.jar
|
||||
bld-wrapper.jar
|
||||
bld-wrapper.properties
|
||||
bld.cache
|
||||
icu4j-71.1.jar
|
||||
javax.json-1.1.4.jar
|
||||
org.abego.treelayout.core-1.0.3.jar""", String.join("\n", files3));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue