mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 16:27:11 -07:00
Added ability to individually exclude sources and javadocs downloads for dependencies
This commit is contained in:
parent
a07db3f94e
commit
df173c4cfc
5 changed files with 40 additions and 22 deletions
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
package rife.bld.dependencies;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -46,6 +47,7 @@ public class Dependency {
|
|||
private final String type_;
|
||||
private final ExclusionSet exclusions_;
|
||||
private final Dependency parent_;
|
||||
private final HashSet<String> excludedClassifiers_;
|
||||
|
||||
public Dependency(String groupId, String artifactId) {
|
||||
this(groupId, artifactId, null, null, null);
|
||||
|
@ -82,6 +84,7 @@ public class Dependency {
|
|||
this.type_ = type;
|
||||
this.exclusions_ = (exclusions == null ? new ExclusionSet() : exclusions);
|
||||
this.parent_ = parent;
|
||||
this.excludedClassifiers_ = new HashSet<>();
|
||||
}
|
||||
|
||||
private static final Pattern DEPENDENCY_PATTERN = Pattern.compile("^(?<groupId>[^:@]+):(?<artifactId>[^:@]+)(?::(?<version>[^:@]+)(?::(?<classifier>[^:@]+))?)?(?:@(?<type>[^:@]+))?$");
|
||||
|
@ -152,6 +155,28 @@ public class Dependency {
|
|||
return new Dependency(groupId_, artifactId_, version_, classifier, type_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude the sources artifact from download operations.
|
||||
*
|
||||
* @return this dependency instance
|
||||
* @since 2.1
|
||||
*/
|
||||
public Dependency excludeSources() {
|
||||
excludedClassifiers_.add(CLASSIFIER_SOURCES);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exclude the javadoc artifact from download operations.
|
||||
*
|
||||
* @return this dependency instance
|
||||
* @since 2.1
|
||||
*/
|
||||
public Dependency excludeJavadoc() {
|
||||
excludedClassifiers_.add(CLASSIFIER_JAVADOC);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a filename that corresponds to the dependency information.
|
||||
*
|
||||
|
@ -253,6 +278,10 @@ public class Dependency {
|
|||
return exclusions_;
|
||||
}
|
||||
|
||||
public HashSet<String> excludedClassifiers() {
|
||||
return excludedClassifiers_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this dependency's {@code parent} dependency that created this
|
||||
* dependency (only for information purposes).
|
||||
|
|
|
@ -134,7 +134,7 @@ public class DependencySet extends AbstractSet<Dependency> implements Set<Depend
|
|||
* @param repositories the repositories to use for the download
|
||||
* @param directory the directory to download the artifacts into
|
||||
* @param modulesDirectory the directory to download the modules into
|
||||
* @param classifiers the additional classifiers to transfer
|
||||
* @param classifiers the additional classifiers to transfer
|
||||
* @return the list of artifacts that were transferred successfully
|
||||
* @throws DependencyTransferException when an error occurred during the transfer
|
||||
* @since 2.1
|
||||
|
@ -166,7 +166,7 @@ public class DependencySet extends AbstractSet<Dependency> implements Set<Depend
|
|||
|
||||
if (classifiers != null) {
|
||||
for (var classifier : classifiers) {
|
||||
if (classifier != null) {
|
||||
if (classifier != null && !dependency.excludedClassifiers().contains(classifier)) {
|
||||
var classifier_artifact = new DependencyResolver(resolution, retriever, repositories, dependency.withClassifier(classifier)).transferIntoDirectory(transfer_directory);
|
||||
if (classifier_artifact != null) {
|
||||
result.add(classifier_artifact);
|
||||
|
|
|
@ -130,10 +130,10 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
filenames = modules_names;
|
||||
}
|
||||
addTransferLocations(filenames, dependency);
|
||||
if (preserveSources_) {
|
||||
if (preserveSources_ && !dependency.excludedClassifiers().contains(CLASSIFIER_SOURCES)) {
|
||||
addTransferLocations(filenames, dependency.withClassifier(CLASSIFIER_SOURCES));
|
||||
}
|
||||
if (preserveJavadoc_) {
|
||||
if (preserveJavadoc_ && !dependency.excludedClassifiers().contains(CLASSIFIER_JAVADOC)) {
|
||||
addTransferLocations(filenames, dependency.withClassifier(CLASSIFIER_JAVADOC));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue