mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-26 00:37:10 -07:00
Fixes for dependency override property behavior.
This commit is contained in:
parent
bb6052250e
commit
48c43a05ed
6 changed files with 74 additions and 11 deletions
Binary file not shown.
|
@ -1618,6 +1618,7 @@ public class BaseProject extends BuildExecutor {
|
||||||
private String createHash() {
|
private String createHash() {
|
||||||
var resolution = new VersionResolution(properties());
|
var resolution = new VersionResolution(properties());
|
||||||
var finger_print = new StringBuilder();
|
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()) {
|
for (var repository : repositories()) {
|
||||||
finger_print.append(repository.toString());
|
finger_print.append(repository.toString());
|
||||||
finger_print.append('\n');
|
finger_print.append('\n');
|
||||||
|
@ -1627,7 +1628,7 @@ public class BaseProject extends BuildExecutor {
|
||||||
finger_print.append('\n');
|
finger_print.append('\n');
|
||||||
if (entry.getValue() != null) {
|
if (entry.getValue() != null) {
|
||||||
for (var dependency : entry.getValue()) {
|
for (var dependency : entry.getValue()) {
|
||||||
finger_print.append(resolution.overrideDependency(dependency).toString());
|
finger_print.append(dependency.toString());
|
||||||
finger_print.append('\n');
|
finger_print.append('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,4 +112,14 @@ public class VersionResolution {
|
||||||
original.exclusions(),
|
original.exclusions(),
|
||||||
original.parent());
|
original.parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the map of version overrides, where the key is the name of the dependency and the value is the overridden version.
|
||||||
|
*
|
||||||
|
* @return the map of version overrides
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public Map<String, VersionNumber> versionOverrides() {
|
||||||
|
return versionOverrides_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package rife.bld.operations;
|
||||||
|
|
||||||
import rife.bld.BaseProject;
|
import rife.bld.BaseProject;
|
||||||
import rife.bld.BldVersion;
|
import rife.bld.BldVersion;
|
||||||
|
import rife.bld.BuildExecutor;
|
||||||
import rife.bld.dependencies.*;
|
import rife.bld.dependencies.*;
|
||||||
import rife.bld.wrapper.Wrapper;
|
import rife.bld.wrapper.Wrapper;
|
||||||
import rife.ioc.HierarchicalProperties;
|
import rife.ioc.HierarchicalProperties;
|
||||||
|
@ -24,6 +25,7 @@ import static rife.bld.dependencies.Scope.*;
|
||||||
*/
|
*/
|
||||||
public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOperation> {
|
public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOperation> {
|
||||||
private HierarchicalProperties properties_ = null;
|
private HierarchicalProperties properties_ = null;
|
||||||
|
private HierarchicalProperties extensionProperties_ = null;
|
||||||
private ArtifactRetriever retriever_ = null;
|
private ArtifactRetriever retriever_ = null;
|
||||||
private final List<Repository> repositories_ = new ArrayList<>();
|
private final List<Repository> repositories_ = new ArrayList<>();
|
||||||
private final DependencyScopes dependencies_ = new DependencyScopes();
|
private final DependencyScopes dependencies_ = new DependencyScopes();
|
||||||
|
@ -68,7 +70,7 @@ public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOpe
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
protected String executeGenerateExtensionsDependencies() {
|
protected String executeGenerateExtensionsDependencies() {
|
||||||
var extensions_tree = extensionDependencies().scope(compile).generateTransitiveDependencyTree(new VersionResolution(properties()), artifactRetriever(), extensionRepositories(), compile, runtime);
|
var extensions_tree = extensionDependencies().scope(compile).generateTransitiveDependencyTree(new VersionResolution(extensionProperties()), artifactRetriever(), extensionRepositories(), compile, runtime);
|
||||||
if (extensions_tree.isEmpty()) {
|
if (extensions_tree.isEmpty()) {
|
||||||
extensions_tree = "no dependencies" + System.lineSeparator();
|
extensions_tree = "no dependencies" + System.lineSeparator();
|
||||||
}
|
}
|
||||||
|
@ -140,8 +142,14 @@ public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOpe
|
||||||
wrapper.currentDir(project.workDirectory());
|
wrapper.currentDir(project.workDirectory());
|
||||||
try {
|
try {
|
||||||
wrapper.initWrapperProperties(BldVersion.getVersion());
|
wrapper.initWrapperProperties(BldVersion.getVersion());
|
||||||
|
|
||||||
|
var extension_properties = BuildExecutor.setupProperties(project.workDirectory());
|
||||||
|
extension_properties = new HierarchicalProperties().parent(extension_properties);
|
||||||
|
extension_properties.putAll(wrapper.wrapperProperties());
|
||||||
|
extensionProperties(extension_properties);
|
||||||
|
|
||||||
for (var repository : wrapper.repositories()) {
|
for (var repository : wrapper.repositories()) {
|
||||||
extensionRepositories().add(Repository.resolveRepository(project.properties(), repository));
|
extensionRepositories().add(Repository.resolveRepository(extensionProperties(), repository));
|
||||||
}
|
}
|
||||||
extensionDependencies().scope(compile).addAll(wrapper.extensions().stream().map(Dependency::parse).toList());
|
extensionDependencies().scope(compile).addAll(wrapper.extensions().stream().map(Dependency::parse).toList());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -255,6 +263,18 @@ public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOpe
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the extension hierarchical properties to use.
|
||||||
|
*
|
||||||
|
* @param properties the extension hierarchical properties
|
||||||
|
* @return this operation instance
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public DependencyTreeOperation extensionProperties(HierarchicalProperties properties) {
|
||||||
|
extensionProperties_ = properties;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the repositories in which the dependencies will be resolved.
|
* Retrieves the repositories in which the dependencies will be resolved.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -338,4 +358,17 @@ public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOpe
|
||||||
}
|
}
|
||||||
return properties_;
|
return properties_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the extension hierarchical properties that are used.
|
||||||
|
*
|
||||||
|
* @return the extension hierarchical properties
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public HierarchicalProperties extensionProperties() {
|
||||||
|
if (extensionProperties_ == null) {
|
||||||
|
extensionProperties_ = new HierarchicalProperties();
|
||||||
|
}
|
||||||
|
return extensionProperties_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,6 +305,22 @@ public class Wrapper {
|
||||||
return extensions_;
|
return extensions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the wrapper properties.
|
||||||
|
*
|
||||||
|
* @return the wrapper properties
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public Properties wrapperProperties() {
|
||||||
|
return wrapperProperties_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the wrapper properties file.
|
||||||
|
*
|
||||||
|
* @return the wrapper properties file
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
public File wrapperPropertiesFile() {
|
public File wrapperPropertiesFile() {
|
||||||
return wrapperPropertiesFile_;
|
return wrapperPropertiesFile_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import static rife.bld.dependencies.Dependency.CLASSIFIER_SOURCES;
|
||||||
* @since 1.5.8
|
* @since 1.5.8
|
||||||
*/
|
*/
|
||||||
public class WrapperExtensionResolver {
|
public class WrapperExtensionResolver {
|
||||||
private final HierarchicalProperties properties_;
|
|
||||||
private final VersionResolution resolution_;
|
private final VersionResolution resolution_;
|
||||||
private final ArtifactRetriever retriever_;
|
private final ArtifactRetriever retriever_;
|
||||||
private final File hashFile_;
|
private final File hashFile_;
|
||||||
|
@ -49,20 +48,20 @@ public class WrapperExtensionResolver {
|
||||||
boolean downloadSources, boolean downloadJavadoc) {
|
boolean downloadSources, boolean downloadJavadoc) {
|
||||||
var properties = BuildExecutor.setupProperties(currentDir);
|
var properties = BuildExecutor.setupProperties(currentDir);
|
||||||
properties.getRoot().putAll(jvmProperties);
|
properties.getRoot().putAll(jvmProperties);
|
||||||
properties_ = new HierarchicalProperties().parent(properties);
|
properties = new HierarchicalProperties().parent(properties);
|
||||||
properties_.putAll(wrapperProperties);
|
properties.putAll(wrapperProperties);
|
||||||
|
|
||||||
resolution_ = new VersionResolution(properties_);
|
resolution_ = new VersionResolution(properties);
|
||||||
|
|
||||||
retriever_ = ArtifactRetriever.cachingInstance();
|
retriever_ = ArtifactRetriever.cachingInstance();
|
||||||
Repository.resolveMavenLocal(properties_);
|
Repository.resolveMavenLocal(properties);
|
||||||
|
|
||||||
hashFile_ = hashFile;
|
hashFile_ = hashFile;
|
||||||
|
|
||||||
destinationDirectory_ = destinationDirectory;
|
destinationDirectory_ = destinationDirectory;
|
||||||
|
|
||||||
for (var repository : repositories) {
|
for (var repository : repositories) {
|
||||||
repositories_.add(Repository.resolveRepository(properties_, repository));
|
repositories_.add(Repository.resolveRepository(properties, repository));
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies_.addAll(extensions.stream().map(d -> resolution_.overrideDependency(Dependency.parse(d))).toList());
|
dependencies_.addAll(extensions.stream().map(d -> resolution_.overrideDependency(Dependency.parse(d))).toList());
|
||||||
|
@ -70,14 +69,18 @@ public class WrapperExtensionResolver {
|
||||||
downloadSources_ = downloadSources;
|
downloadSources_ = downloadSources;
|
||||||
downloadJavadoc_ = downloadJavadoc;
|
downloadJavadoc_ = downloadJavadoc;
|
||||||
fingerPrintHash_ = createHash(
|
fingerPrintHash_ = createHash(
|
||||||
|
resolution_,
|
||||||
repositories_.stream().map(Objects::toString).toList(),
|
repositories_.stream().map(Objects::toString).toList(),
|
||||||
dependencies_.stream().map(Objects::toString).toList(),
|
dependencies_.stream().map(Objects::toString).toList(),
|
||||||
downloadSources, downloadJavadoc);
|
downloadSources, downloadJavadoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createHash(Collection<String> repositories, Collection<String> extensions, boolean downloadSources, boolean downloadJavadoc) {
|
private static String createHash(VersionResolution resolution, Collection<String> repositories, Collection<String> extensions, boolean downloadSources, boolean downloadJavadoc) {
|
||||||
try {
|
try {
|
||||||
var fingerprint = String.join("\n", repositories) + "\n" + String.join("\n", extensions) + "\n" + downloadSources + "\n" + downloadJavadoc;
|
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");
|
var digest = MessageDigest.getInstance("SHA-1");
|
||||||
digest.update(fingerprint.getBytes(StandardCharsets.UTF_8));
|
digest.update(fingerprint.getBytes(StandardCharsets.UTF_8));
|
||||||
return StringUtils.encodeHexLower(digest.digest());
|
return StringUtils.encodeHexLower(digest.digest());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue