Skip to content

Commit

Permalink
Merge pull request #87 from thevpc/issue_86
Browse files Browse the repository at this point in the history
[FIXED] Prepare for Better Gradle Integration #86
  • Loading branch information
thevpc committed Oct 24, 2021
2 parents 562261b + 0016753 commit b02894a
Show file tree
Hide file tree
Showing 39 changed files with 804 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class DefaultNutsSession implements Cloneable, NutsSession {
private NutsSessionTerminal terminal;
private NutsPropertiesHolder properties = new NutsPropertiesHolder();
private Map<Class, LinkedHashSet<NutsListener>> listeners = new HashMap<>();
private String dependencySolver;
private Boolean trace;
private Boolean bot;
private Boolean debug;
Expand Down Expand Up @@ -267,6 +268,14 @@ public boolean configureFirst(NutsCommandLine cmdLine) {
}
return true;
}
case "--solver": {
a = cmdLine.nextString();
if (enabled) {
String s = a.getValue().getString();
this.setDependencySolver(s);
}
break;
}
case "--progress": {
NutsArgument v = cmdLine.nextString();
if (enabled) {
Expand Down Expand Up @@ -712,6 +721,7 @@ public NutsSession copyFrom(NutsSession other) {
this.logFileFilter = other.getLogFileFilter();
this.eout = other.eout();
this.appId = other.getAppId();
this.dependencySolver = other.getDependencySolver();
return this;
}

Expand Down Expand Up @@ -740,7 +750,7 @@ public NutsSession copyFrom(NutsWorkspaceOptions options) {
this.logFileLevel = logConfig.getLogFileLevel();
this.logFileFilter = logConfig.getLogFileFilter();
}

this.dependencySolver=options.getDependencySolver();
}
return this;
}
Expand Down Expand Up @@ -1229,6 +1239,9 @@ public NutsSession configure(NutsWorkspaceOptions options) {
if (options.getExecutionType() != null) {
setExecutionType(options.getExecutionType());
}
if (options.getDependencySolver() != null) {
setDependencySolver(options.getDependencySolver());
}
}
return this;
}
Expand Down Expand Up @@ -1527,4 +1540,15 @@ public NutsTextManager text() {
public NutsElementFormat elem() {
return getWorkspace().elem();
}

@Override
public String getDependencySolver() {
return dependencySolver;
}

@Override
public NutsSession setDependencySolver(String dependencySolver) {
this.dependencySolver = dependencySolver;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,14 @@ public static void parseNutsArguments(NutsSession session, String[] bootArgument
}
break;
}
case "--solver": {
a = cmdLine.nextString();
if (enabled) {
String s = a.getValue().getString();
options.setDependencySolver(s);
}
break;
}
case "--dry":
case "-D": {
a = cmdLine.nextBoolean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public NutsCommandLine getBootCommandLine() {
fillOption("--read-only", "-R", options.isReadOnly(), false, arguments, false);
fillOption("--trace", "-t", options.isTrace(), true, arguments, false);
fillOption("--progress", "-P", options.getProgressOptions(), arguments, false);
fillOption("--solver", null, options.getDependencySolver(), arguments, false);
fillOption("--skip-companions", "-k", options.isSkipCompanions(), false, arguments, false);
fillOption("--skip-welcome", "-K", options.isSkipWelcome(), false, arguments, false);
fillOption("--out-line-prefix", null, options.isSkipWelcome(), false, arguments, false);
Expand Down Expand Up @@ -234,6 +235,7 @@ public NutsCommandLine getBootCommandLine() {
if (runtimeOptions || isImplicitAll()) {
fillOption("--help", "-h", options.isCommandHelp(), false, arguments, false);
fillOption("--version", "-v", options.isCommandVersion(), false, arguments, false);

if (!(omitDefaults && (options.getOpenMode() == null || options.getOpenMode() == NutsOpenMode.OPEN_OR_CREATE))) {
fillOption(options.getOpenMode(), arguments, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import net.thevpc.nuts.runtime.standalone.solvers.NutsDependencySolvers;
import net.thevpc.nuts.runtime.standalone.util.NutsJavaSdkUtils;
import net.thevpc.nuts.runtime.core.util.CoreCommonUtils;
import net.thevpc.nuts.runtime.core.util.CoreTimeUtils;
Expand Down Expand Up @@ -271,7 +272,7 @@ private Map<String, Object> buildWorkspaceMap(boolean deep) {
props.put("nuts-runtime-classpath",
ws.text().builder().appendJoined(";",runtimeClassPath)
);
props.put("nuts-workspace-id", stringValue(ws.getWorkspace().getUuid()));
props.put("nuts-workspace-id", ws.text().ofStyled(stringValue(ws.getWorkspace().getUuid()),NutsTextStyle.path()));
props.put("nuts-store-layout", ws.locations().getStoreLocationLayout());
props.put("nuts-store-strategy", ws.locations().getStoreLocationStrategy());
props.put("nuts-repo-store-strategy", ws.locations().getRepositoryStoreLocationStrategy());
Expand All @@ -292,6 +293,23 @@ private Map<String, Object> buildWorkspaceMap(boolean deep) {
props.put("nuts-skip-companions", options.isSkipCompanions());
props.put("nuts-skip-welcome", options.isSkipWelcome());
props.put("nuts-skip-boot", options.isSkipBoot());
String ds = NutsDependencySolvers.resolveSolverName(options.getDependencySolver());
String[] allDs = ws.dependency().getSolverNames();
props.put("nuts-solver",
ws.text().ofStyled(
ds,
Arrays.stream(allDs).map(x->NutsDependencySolvers.resolveSolverName(x))
.anyMatch(x->x.equals(ds))
?NutsTextStyle.keyword() : NutsTextStyle.error())
);
props.put("nuts-solver-list",
ws.text().builder().appendJoined(";",
Arrays.stream(allDs)
.map(x->ws.text().ofStyled(x,NutsTextStyle.keyword()))
.collect(Collectors.toList())
)

);
props.put("java-version", ws.version().parser().parse(System.getProperty("java.version")));
props.put("platform", ws.env().getPlatform());
props.put("java-home", ws.io().path(System.getProperty("java.home")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public final class CoreNutsWorkspaceOptions implements Serializable, Cloneable,
*/
private String progressOptions = null;

/**
* option-type : exported (inherited in child workspaces)
*/
private String dependencySolver = null;

/**
* option-type : exported (inherited in child workspaces)
*/
Expand Down Expand Up @@ -1465,6 +1470,7 @@ public NutsWorkspaceOptionsBuilder setAll(NutsWorkspaceOptions other) {
this.setLocale(other.getLocale());
this.setTheme(other.getTheme());
this.setBootTerminal(other.getBootTerminal());
this.setDependencySolver(other.getDependencySolver());
return this;
}

Expand Down Expand Up @@ -1555,6 +1561,17 @@ public NutsWorkspaceOptions build() {
return c;
}

@Override
public String getDependencySolver() {
return dependencySolver;
}

@Override
public NutsWorkspaceOptionsBuilder setDependencySolver(String dependencySolver) {
this.dependencySolver = dependencySolver;
return this;
}

@Override
public String toString() {
return formatter().getBootCommandLine().toString();
Expand Down
Loading

0 comments on commit b02894a

Please sign in to comment.