mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 08:17:11 -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
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
bld.downloadExtensionJavadoc=false
|
||||
bld.downloadExtensionSources=true
|
||||
bld.downloadLocation=
|
||||
bld.downloadLocation=file:/Users/gbevin/.m2/repository/com/uwyn/rife2/bld/2.0.0-SNAPSHOT/
|
||||
bld.extension-antlr=com.uwyn.rife2:bld-antlr4:1.2.8
|
||||
bld.extension-archive=com.uwyn.rife2:bld-archive:0.4.8
|
||||
bld.extension-tests=com.uwyn.rife2:bld-tests-badge:1.4.8
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -22,6 +22,7 @@ public class TestDependencyTreeOperation {
|
|||
@Test
|
||||
void testInstantiation() {
|
||||
var operation = new DependencyTreeOperation();
|
||||
assertFalse(operation.offline());
|
||||
assertEquals(operation.properties().size(), 0);
|
||||
assertTrue(operation.dependencies().isEmpty());
|
||||
assertTrue(operation.repositories().isEmpty());
|
||||
|
@ -55,7 +56,9 @@ public class TestDependencyTreeOperation {
|
|||
assertTrue(operation2.dependencies().scope(Scope.compile).contains(dependency2));
|
||||
|
||||
var operation3 = new DependencyTreeOperation()
|
||||
.offline(true)
|
||||
.repositories(repository1, repository2);
|
||||
assertTrue(operation3.offline());
|
||||
assertTrue(operation3.repositories().contains(repository1));
|
||||
assertTrue(operation3.repositories().contains(repository2));
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ public class TestDownloadOperation {
|
|||
@Test
|
||||
void testInstantiation() {
|
||||
var operation = new DownloadOperation();
|
||||
assertFalse(operation.offline());
|
||||
assertTrue(operation.dependencies().isEmpty());
|
||||
assertTrue(operation.repositories().isEmpty());
|
||||
assertNull(operation.libCompileDirectory());
|
||||
|
@ -81,7 +82,9 @@ public class TestDownloadOperation {
|
|||
assertEquals(dir5, operation2.libTestDirectory());
|
||||
|
||||
var operation3 = new DownloadOperation()
|
||||
.offline(true)
|
||||
.repositories(repository1, repository2);
|
||||
assertTrue(operation3.offline());
|
||||
assertTrue(operation3.repositories().contains(repository1));
|
||||
assertTrue(operation3.repositories().contains(repository2));
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public class TestPublishOperation {
|
|||
@Test
|
||||
void testInstantiation() {
|
||||
var operation = new PublishOperation();
|
||||
assertFalse(operation.offline());
|
||||
assertTrue(operation.repositories().isEmpty());
|
||||
assertNull(operation.moment());
|
||||
assertTrue(operation.dependencies().isEmpty());
|
||||
|
@ -109,10 +110,12 @@ public class TestPublishOperation {
|
|||
assertTrue(operation2.artifacts().contains(artifact2));
|
||||
|
||||
var operation3 = new PublishOperation()
|
||||
.offline(true)
|
||||
.repository(repository1)
|
||||
.repository(repository2)
|
||||
.moment(moment)
|
||||
.artifacts(List.of(artifact1, artifact2));
|
||||
assertTrue(operation3.offline());
|
||||
operation3.publishProperties().mavenCompilerSource(17).mavenCompilerTarget(19);
|
||||
assertTrue(operation3.repositories().contains(repository1));
|
||||
assertTrue(operation3.repositories().contains(repository2));
|
||||
|
|
|
@ -19,6 +19,7 @@ public class TestPurgeOperation {
|
|||
@Test
|
||||
void testInstantiation() {
|
||||
var operation = new PurgeOperation();
|
||||
assertFalse(operation.offline());
|
||||
assertTrue(operation.dependencies().isEmpty());
|
||||
assertTrue(operation.repositories().isEmpty());
|
||||
assertNull(operation.libCompileDirectory());
|
||||
|
@ -81,7 +82,9 @@ public class TestPurgeOperation {
|
|||
assertEquals(dir5, operation2.libTestDirectory());
|
||||
|
||||
var operation3 = new PurgeOperation()
|
||||
.offline(true)
|
||||
.repositories(repository1, repository2);
|
||||
assertTrue(operation3.offline());
|
||||
assertTrue(operation3.repositories().contains(repository1));
|
||||
assertTrue(operation3.repositories().contains(repository2));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue