mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-26 00:37:10 -07:00
Improvement to offline operation, now pushed to the actual operations instead of the commands
This commit is contained in:
parent
d904fd22b7
commit
a02e78820e
13 changed files with 146 additions and 33 deletions
|
@ -485,12 +485,7 @@ public class BaseProject extends BuildExecutor {
|
|||
@BuildCommand(value = "dependency-tree", help = DependencyTreeHelp.class)
|
||||
public void dependencyTree()
|
||||
throws Exception {
|
||||
if (isOffline()) {
|
||||
System.out.println("Offline mode: dependency-tree is disabled");
|
||||
}
|
||||
else {
|
||||
dependencyTreeOperation().executeOnce(() -> dependencyTreeOperation().fromProject(this));
|
||||
}
|
||||
dependencyTreeOperation().executeOnce(() -> dependencyTreeOperation().fromProject(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -501,12 +496,7 @@ public class BaseProject extends BuildExecutor {
|
|||
@BuildCommand(help = DownloadHelp.class)
|
||||
public void download()
|
||||
throws Exception {
|
||||
if (isOffline()) {
|
||||
System.out.println("Offline mode: download is disabled");
|
||||
}
|
||||
else {
|
||||
downloadOperation().executeOnce(() -> downloadOperation().fromProject(this));
|
||||
}
|
||||
downloadOperation().executeOnce(() -> downloadOperation().fromProject(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -517,12 +507,7 @@ public class BaseProject extends BuildExecutor {
|
|||
@BuildCommand(help = PurgeHelp.class)
|
||||
public void purge()
|
||||
throws Exception {
|
||||
if (isOffline()) {
|
||||
System.out.println("Offline mode: purge is disabled");
|
||||
}
|
||||
else {
|
||||
purgeOperation().executeOnce(() -> purgeOperation().fromProject(this));
|
||||
}
|
||||
purgeOperation().executeOnce(() -> purgeOperation().fromProject(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1689,7 +1674,7 @@ public class BaseProject extends BuildExecutor {
|
|||
|
||||
@Override
|
||||
public int execute(String[] arguments) {
|
||||
if (!isOffline() &&
|
||||
if (!offline() &&
|
||||
autoDownloadPurge()) {
|
||||
performAutoDownloadPurge();
|
||||
}
|
||||
|
|
|
@ -9,12 +9,9 @@ import rife.bld.help.HelpHelp;
|
|||
import rife.bld.operations.HelpOperation;
|
||||
import rife.bld.operations.exceptions.ExitStatusException;
|
||||
import rife.ioc.HierarchicalProperties;
|
||||
import rife.template.Template;
|
||||
import rife.template.TemplateFactory;
|
||||
import rife.tools.ExceptionUtils;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -134,7 +131,7 @@ public class BuildExecutor {
|
|||
* or {@code false} otherwise
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean isOffline() {
|
||||
public boolean offline() {
|
||||
return offline_;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,12 +191,7 @@ public class Project extends BaseProject {
|
|||
jar();
|
||||
jarSources();
|
||||
jarJavadoc();
|
||||
if (isOffline()) {
|
||||
System.out.println("Offline mode: publish is disabled");
|
||||
}
|
||||
else {
|
||||
publishOperation().executeOnce(() -> publishOperation().fromProject(this));
|
||||
}
|
||||
publishOperation().executeOnce(() -> publishOperation().fromProject(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,7 @@ import static rife.bld.dependencies.Scope.*;
|
|||
* @since 1.5.21
|
||||
*/
|
||||
public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOperation> {
|
||||
private boolean offline_ = false;
|
||||
private HierarchicalProperties properties_ = null;
|
||||
private HierarchicalProperties extensionProperties_ = null;
|
||||
private ArtifactRetriever retriever_ = null;
|
||||
|
@ -40,6 +41,11 @@ public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOpe
|
|||
* @since 1.5.21
|
||||
*/
|
||||
public void execute() {
|
||||
if (offline_) {
|
||||
System.out.println("Offline mode: dependency-tree is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
var extensions_tree = executeGenerateExtensionsDependencies();
|
||||
var compile_tree = executeGenerateCompileDependencies();
|
||||
var provided_tree = executeGenerateProvidedDependencies();
|
||||
|
@ -157,12 +163,37 @@ public class DependencyTreeOperation extends AbstractOperation<DependencyTreeOpe
|
|||
}
|
||||
|
||||
// add the repositories and the dependencies from the project
|
||||
return properties(project.properties())
|
||||
return offline(project.offline())
|
||||
.properties(project.properties())
|
||||
.artifactRetriever(project.artifactRetriever())
|
||||
.repositories(project.repositories())
|
||||
.dependencies(project.dependencies());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the operation has to run offline.
|
||||
*
|
||||
* @param flag {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @return this operation instance
|
||||
* @since 2.0
|
||||
*/
|
||||
public DependencyTreeOperation offline(boolean flag) {
|
||||
offline_ = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the operation has to run offline.
|
||||
*
|
||||
* @return {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean offline() {
|
||||
return offline_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides repositories to resolve the dependencies against.
|
||||
*
|
||||
|
|
|
@ -25,6 +25,7 @@ import static rife.bld.dependencies.Dependency.CLASSIFIER_SOURCES;
|
|||
* @since 1.5
|
||||
*/
|
||||
public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
||||
private boolean offline_ = false;
|
||||
private HierarchicalProperties properties_ = null;
|
||||
private ArtifactRetriever retriever_ = null;
|
||||
private final List<Repository> repositories_ = new ArrayList<>();
|
||||
|
@ -43,6 +44,11 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public void execute() {
|
||||
if (offline_) {
|
||||
System.out.println("Offline mode: download is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
executeDownloadCompileDependencies();
|
||||
executeDownloadProvidedDependencies();
|
||||
executeDownloadRuntimeDependencies();
|
||||
|
@ -133,7 +139,8 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public DownloadOperation fromProject(BaseProject project) {
|
||||
return properties(project.properties())
|
||||
return offline(project.offline())
|
||||
.properties(project.properties())
|
||||
.artifactRetriever(project.artifactRetriever())
|
||||
.repositories(project.repositories())
|
||||
.dependencies(project.dependencies())
|
||||
|
@ -146,6 +153,30 @@ public class DownloadOperation extends AbstractOperation<DownloadOperation> {
|
|||
.downloadJavadoc(project.downloadJavadoc());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the operation has to run offline.
|
||||
*
|
||||
* @param flag {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @return this operation instance
|
||||
* @since 2.0
|
||||
*/
|
||||
public DownloadOperation offline(boolean flag) {
|
||||
offline_ = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the operation has to run offline.
|
||||
*
|
||||
* @return {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean offline() {
|
||||
return offline_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides repositories to resolve the dependencies against.
|
||||
*
|
||||
|
|
|
@ -39,6 +39,7 @@ import static rife.tools.StringUtils.encodeHexLower;
|
|||
* @since 1.5.7
|
||||
*/
|
||||
public class PublishOperation extends AbstractOperation<PublishOperation> {
|
||||
private boolean offline_ = false;
|
||||
private HierarchicalProperties properties_ = null;
|
||||
private ArtifactRetriever retriever_ = null;
|
||||
private final HttpClient client_ = HttpClient.newHttpClient();
|
||||
|
@ -56,6 +57,11 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
|
|||
* @since 1.5.7
|
||||
*/
|
||||
public void execute() {
|
||||
if (offline_) {
|
||||
System.out.println("Offline mode: publish is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (repositories().isEmpty()) {
|
||||
throw new OperationOptionException("ERROR: the publication repositories should be specified");
|
||||
}
|
||||
|
@ -506,6 +512,7 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
|
|||
.mavenCompilerSource(project.javaRelease())
|
||||
.mavenCompilerTarget(project.javaRelease());
|
||||
}
|
||||
offline(project.offline());
|
||||
properties(project.properties());
|
||||
artifactRetriever(project.artifactRetriever());
|
||||
dependencies().include(project.dependencies());
|
||||
|
@ -528,6 +535,30 @@ public class PublishOperation extends AbstractOperation<PublishOperation> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the operation has to run offline.
|
||||
*
|
||||
* @param flag {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @return this operation instance
|
||||
* @since 2.0
|
||||
*/
|
||||
public PublishOperation offline(boolean flag) {
|
||||
offline_ = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the operation has to run offline.
|
||||
*
|
||||
* @return {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean offline() {
|
||||
return offline_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the moment of publication.
|
||||
* <p>
|
||||
|
|
|
@ -25,6 +25,7 @@ import static rife.bld.dependencies.Dependency.CLASSIFIER_SOURCES;
|
|||
* @since 1.5
|
||||
*/
|
||||
public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
||||
private boolean offline_ = false;
|
||||
private HierarchicalProperties properties_ = null;
|
||||
private ArtifactRetriever retriever_ = null;
|
||||
private final List<Repository> repositories_ = new ArrayList<>();
|
||||
|
@ -43,6 +44,11 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public void execute() {
|
||||
if (offline_) {
|
||||
System.out.println("Offline mode: purge is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
executePurgeCompileDependencies();
|
||||
executePurgeProvidedDependencies();
|
||||
executePurgeRuntimeDependencies();
|
||||
|
@ -147,7 +153,8 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public PurgeOperation fromProject(BaseProject project) {
|
||||
return properties(project.properties())
|
||||
return offline(project.offline())
|
||||
.properties(project.properties())
|
||||
.artifactRetriever(project.artifactRetriever())
|
||||
.repositories(project.repositories())
|
||||
.dependencies(project.dependencies())
|
||||
|
@ -160,6 +167,30 @@ public class PurgeOperation extends AbstractOperation<PurgeOperation> {
|
|||
.preserveJavadoc(project.downloadJavadoc());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the operation has to run offline.
|
||||
*
|
||||
* @param flag {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @return this operation instance
|
||||
* @since 2.0
|
||||
*/
|
||||
public PurgeOperation offline(boolean flag) {
|
||||
offline_ = flag;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the operation has to run offline.
|
||||
*
|
||||
* @return {@code true} if the operation runs offline; or
|
||||
* {@code false} otherwise
|
||||
* @since 2.0
|
||||
*/
|
||||
public boolean offline() {
|
||||
return offline_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the sources classifier files should be preserved.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue