Add download --auto argument, emulating autoDownloadPurge = true in the CLI.

To be used when caching dependencies in CI workflows.
This commit is contained in:
Erik C. Thauvin 2026-05-28 04:13:03 -07:00
parent 8ca8c213d5
commit c521d6578f
No known key found for this signature in database
GPG key ID: 776702A6A2DA330E
3 changed files with 24 additions and 8 deletions

View file

@ -534,7 +534,22 @@ public class BaseProject extends BuildExecutor {
@BuildCommand(help = DownloadHelp.class)
public void download()
throws Exception {
downloadOperation().executeOnce(() -> downloadOperation().fromProject(this));
var auto = false;
var arguments = this.arguments();
while (!arguments.isEmpty()) {
var argument = arguments.get(0);
if (DownloadOperation.AUTO_OPTION.equals(argument)) {
arguments.remove(0);
auto = true;
} else {
break;
}
}
if (auto) {
performAutoDownloadPurge();
} else {
downloadOperation().executeOnce(() -> downloadOperation().fromProject(this));
}
}
/**

View file

@ -5,7 +5,7 @@
package rife.bld.help;
import rife.bld.CommandHelp;
import rife.tools.StringUtils;
import rife.bld.operations.DownloadOperation;
/**
* Provides help for the download command.
@ -15,13 +15,13 @@ import rife.tools.StringUtils;
*/
public class DownloadHelp implements CommandHelp {
public String getSummary() {
return "Downloads all dependencies of the project";
return "Downloads all dependencies of the project (take option)";
}
public String getDescription(String topic) {
return StringUtils.replace("""
Downloads all dependencies of the project
Usage : ${topic}""", "${topic}", topic);
return String.format("""
Downloads all dependencies of the project
Usage : %s [%s]""", topic, DownloadOperation.AUTO_OPTION);
}
}
}

View file

@ -25,6 +25,7 @@ import static rife.bld.dependencies.Dependency.CLASSIFIER_SOURCES;
* @since 1.5
*/
public class DownloadOperation extends AbstractOperation<DownloadOperation> {
public static final String AUTO_OPTION = "--auto";
private boolean offline_ = false;
private HierarchicalProperties properties_ = null;
private ArtifactRetriever retriever_ = null;