Skip to content

Commit

Permalink
Merge branch 'main' into feature/188-fix-hacky-workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille authored Aug 8, 2024
2 parents 7bfb70e + ba83c94 commit 7b4e5d6
Show file tree
Hide file tree
Showing 63 changed files with 751 additions and 322 deletions.
6 changes: 4 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
root = true

[*]
charset = utf-8
end_of_line = crlf
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
Expand Down Expand Up @@ -95,7 +97,7 @@ ij_java_doc_align_param_comments = false
ij_java_doc_do_not_wrap_if_one_line = true
ij_java_doc_enable_formatting = true
ij_java_doc_enable_leading_asterisks = true
ij_java_doc_indent_on_continuation = false
ij_java_doc_indent_on_continuation = true
ij_java_doc_keep_empty_lines = true
ij_java_doc_keep_empty_parameter_tag = true
ij_java_doc_keep_empty_return_tag = true
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/check-for-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- cron: '0 2 * * *'

jobs:
# Checks if new commits since 24 hours of the last call of this workflow were found and adjusts the GITHUB_OUTPUT accordingly
verify_commit:
runs-on: ubuntu-latest
outputs:
Expand All @@ -15,11 +16,12 @@ jobs:
- id: verify_commit
run: |
if git log --since='24 hours ago' --oneline | grep '.'; then
echo "::set-output name=RUN_BUILD::true"
echo "RUN_BUILD=true" >> $GITHUB_OUTPUT
else
echo "::set-output name=RUN_BUILD::false"
echo "RUN_BUILD=false" >> $GITHUB_OUTPUT
fi
# Starts nightly_build workflow when new commits were found
trigger_build:
runs-on: ubuntu-latest
needs: verify_commit
Expand Down
22 changes: 0 additions & 22 deletions .github/workflows/nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,3 @@ jobs:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: mvn --settings .mvn/settings.xml -DskipTests=true -Darchetype.test.skip=true -Dmaven.install.skip=true -Dgpg.skip=true -Dstyle.color=always -B -ntp -Pdeploy deploy

check_status:
runs-on: ubuntu-latest
steps:
- name: Check last workflow status
id: check_status
run: |
workflow_filename="nightly-build.yml"
last_workflow=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/$workflow_filename/runs?per_page=1" | jq -r '.workflow_runs[0]')
conclusion=$(echo $last_workflow | jq -r '.conclusion')
echo "conclusion=$conclusion" >> $GITHUB_ENV
- name: Print and handle the status
run: |
echo "The status of the last workflow run is: ${{ env.conclusion }}"
if [ "${{ env.conclusion }}" != "success" ]; then
echo "The last workflow did not succeed. Failing this workflow."
exit 1
else
echo "The last workflow succeeded. This workflow will succeed."
fi
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void initKeyValue() {

/**
* @return a {@link String} representing all arguments from this {@link CliArgument} recursively along is {@link #getNext(boolean) next} arguments to the
* {@link #isEnd() end}.
* {@link #isEnd() end}.
*/
public String getArgs() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public boolean isSuppressStepSuccess() {

/**
* @return {@code true} if the output of this commandlet is (potentially) processed automatically from outside, {@code false} otherwise. For example
* {@link CompleteCommandlet} logs the suggestions for auto-completion to a bash script. Also the {@link EnvironmentCommandlet} logs the environment variables
* for the {@code ide} wrapper script. In such scenarios these logs shall not be spammed with warnings like "IDE_ROOT is not set" that would break the
* processing of the output.
* {@link CompleteCommandlet} logs the suggestions for auto-completion to a bash script. Also the {@link EnvironmentCommandlet} logs the environment
* variables for the {@code ide} wrapper script. In such scenarios these logs shall not be spammed with warnings like "IDE_ROOT is not set" that would
* break the processing of the output.
*/
public boolean isProcessableOutput() {

Expand Down Expand Up @@ -252,7 +252,7 @@ public String toString() {

/**
* @return the {@link ToolCommandlet} set in a {@link Property} of this commandlet used for auto-completion of a {@link VersionIdentifier} or {@code null} if
* not exists or not configured.
* not exists or not configured.
*/
public ToolCommandlet getToolForVersionCompletion() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface CommandletManager {
/**
* @param keyword the first keyword argument.
* @return a {@link Commandlet} having the first {@link Property} {@link Property#isRequired() required} and a {@link KeywordProperty} with the given
* {@link Property#getName() name} or {@code null} if no such {@link Commandlet} is registered.
* {@link Property#getName() name} or {@code null} if no such {@link Commandlet} is registered.
*/
Commandlet getCommandletByFirstKeyword(String keyword);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.devonfw.tools.ide.commandlet;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
import com.devonfw.tools.ide.environment.VariableLine;
import com.devonfw.tools.ide.os.WindowsPathSyntax;
import com.devonfw.tools.ide.property.FlagProperty;
Expand Down Expand Up @@ -50,32 +53,51 @@ public boolean isProcessableOutput() {
@Override
public void run() {

boolean winCmd = false;
WindowsPathSyntax pathSyntax = null;
if (this.context.getSystemInfo().isWindows()) {
if (this.bash.isTrue()) {
pathSyntax = WindowsPathSyntax.MSYS;
} else {
winCmd = true;
pathSyntax = WindowsPathSyntax.WINDOWS;
}
}
((AbstractIdeContext) this.context).setPathSyntax(pathSyntax);
Collection<VariableLine> variables = this.context.getVariables().collectVariables();
List<VariableLine> variables = this.context.getVariables().collectVariables();
if (this.context.debug().isEnabled()) {
for (String source : variables.stream().map(VariableLine::getSource).collect(Collectors.toSet())) {
this.context.debug("from {}:", source);
for (VariableLine line : variables) {
if (line.getSource().equals(source)) {
Map<EnvironmentVariablesType, List<VariableLine>> type2lines = variables.stream().collect(Collectors.groupingBy(l -> l.getSource().type()));
for (EnvironmentVariablesType type : EnvironmentVariablesType.values()) {
List<VariableLine> lines = type2lines.get(type);
if (lines != null) {
boolean sourcePrinted = false;
sortVariables(lines);
for (VariableLine line : lines) {
if (!sourcePrinted) {
this.context.debug("from {}:", line.getSource());
sourcePrinted = true;
}
printEnvLine(line);
}
}
}
} else {
sortVariables(variables);
for (VariableLine line : variables) {
printEnvLine(line);
if (winCmd) {
// MS-Dos (aka CMD) has no concept of exported variables
this.context.info(line.getName() + "=" + line.getValue() + "");
} else {
printEnvLine(line);
}
}
}
}

private static void sortVariables(List<VariableLine> lines) {
Collections.sort(lines, (c1, c2) -> c1.getName().compareTo(c2.getName()));
}

private void printEnvLine(VariableLine line) {
String lineValue = line.getValue();
lineValue = "\"" + lineValue + "\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private int runCommand(String args) {
* @param argument the current {@link CliArgument} (position) to match.
* @param commandlet the potential {@link Commandlet} to match.
* @return {@code true} if the given {@link Commandlet} matches to the given {@link CliArgument}(s) and those have been applied (set in the {@link Commandlet}
* and {@link Commandlet#validate() validated}), {@code false} otherwise (the {@link Commandlet} did not match and we have to try a different candidate).
* and {@link Commandlet#validate() validated}), {@code false} otherwise (the {@link Commandlet} did not match and we have to try a different candidate).
*/
private boolean apply(CliArgument argument, Commandlet commandlet) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ public void run() {
if (installedVersion == null) {
this.context.info("No installation of tool {} was found.", commandlet.getName());
toolInstallInfo(commandlet.getName(), configuredVersion);
} else {
this.context.info(installedVersion.toString());
}
this.context.info(installedVersion.toString());

} else if (!this.installed.isTrue() && this.configured.isTrue()) {// get configured version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
public interface JsonVersionItem {

/**
* @return the {@link com.devonfw.tools.ide.version.VersionIdentifier version}.
*/
String version();

}
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,12 @@ private static String getTool(Path path, Path ideRoot) {
return null;
}
if (path.startsWith(ideRoot)) {
int i = ideRoot.getNameCount();
if (path.getNameCount() > i) {
return path.getName(i).toString();
Path relativized = ideRoot.relativize(path);
int count = relativized.getNameCount();
if (count >= 3) {
if (relativized.getName(1).toString().equals("software")) {
return relativized.getName(2).toString();
}
}
}
return null;
Expand Down
6 changes: 3 additions & 3 deletions cli/src/main/java/com/devonfw/tools/ide/common/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ public Tag getParent() {

/**
* @param i the index of the requested parent. Should be in the range from {@code 0} to
* <code>{@link #getParentCount()}-1</code>.
* <code>{@link #getParentCount()}-1</code>.
* @return the requested {@link Tag}.
*/
public Tag getParent(int i) {
Expand Down Expand Up @@ -404,9 +404,9 @@ public boolean isAncestorOf(Tag tag) {
/**
* @param tag the {@link Tag} to check.
* @param includeAdditionalParents - {@code true} if {@link #getParent(int) additional parents} should be included, {@code false} otherwise (only consider
* {@link #getParent() primary parent}).
* {@link #getParent() primary parent}).
* @return {@code true} if the given {@link Tag} is an ancestor of this tag, {@code false} otherwise. An ancestor is a direct or indirect
* {@link #getParent() parent}. Therefore, if {@link #ROOT} is given as {@link Tag} parameter, this method should always return {@code true}.
* {@link #getParent() parent}. Therefore, if {@link #ROOT} is given as {@link Tag} parameter, this method should always return {@code true}.
*/
public boolean isAncestorOf(Tag tag, boolean includeAdditionalParents) {

Expand Down
2 changes: 1 addition & 1 deletion cli/src/main/java/com/devonfw/tools/ide/common/Tags.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public interface Tags {

/**
* @return a {@link Set} with the tags classifying this object. E.g. for mvn (maven) the tags {@link Tag#JAVA java} and {@link Tag#BUILD build} could be
* associated.
* associated.
*/
Set<Tag> getTags();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ public abstract class AbstractIdeContext implements IdeContext {
* @param minLogLevel the minimum {@link IdeLogLevel} to enable. Should be {@link IdeLogLevel#INFO} by default.
* @param factory the {@link Function} to create {@link IdeSubLogger} per {@link IdeLogLevel}.
* @param userDir the optional {@link Path} to current working directory.
* @param toolRepository @param toolRepository the {@link ToolRepository} of the context. If it is set to {@code null} {@link DefaultToolRepository} will be
* used.
* @param toolRepository @param toolRepository the {@link ToolRepository} of the context. If it is set to {@code null} {@link DefaultToolRepository} will
* be used.
*/
public AbstractIdeContext(IdeLogLevel minLogLevel, Function<IdeLogLevel, IdeSubLogger> factory, Path userDir, ToolRepository toolRepository) {

Expand Down Expand Up @@ -320,7 +320,7 @@ public boolean isMock() {
return false;
}

private SystemPath computeSystemPath() {
protected SystemPath computeSystemPath() {

return new SystemPath(this);
}
Expand Down Expand Up @@ -352,7 +352,7 @@ private Path getParentPath(Path dir) {

private EnvironmentVariables createVariables() {

AbstractEnvironmentVariables system = EnvironmentVariables.ofSystem(this);
AbstractEnvironmentVariables system = createSystemVariables();
AbstractEnvironmentVariables user = extendVariables(system, this.userHomeIde, EnvironmentVariablesType.USER);
AbstractEnvironmentVariables settings = extendVariables(user, this.settingsPath, EnvironmentVariablesType.SETTINGS);
// TODO should we keep this workspace properties? Was this feature ever used?
Expand All @@ -361,7 +361,12 @@ private EnvironmentVariables createVariables() {
return conf.resolved();
}

private AbstractEnvironmentVariables extendVariables(AbstractEnvironmentVariables envVariables, Path propertiesPath, EnvironmentVariablesType type) {
protected AbstractEnvironmentVariables createSystemVariables() {

return EnvironmentVariables.ofSystem(this);
}

protected AbstractEnvironmentVariables extendVariables(AbstractEnvironmentVariables envVariables, Path propertiesPath, EnvironmentVariablesType type) {

Path propertiesFile = null;
if (propertiesPath == null) {
Expand Down Expand Up @@ -894,9 +899,9 @@ public int run(CliArguments arguments) {

/**
* @param cmd the potential {@link Commandlet} to {@link #apply(CliArguments, Commandlet, CompletionCandidateCollector) apply} and
* {@link Commandlet#run() run}.
* {@link Commandlet#run() run}.
* @return {@code true} if the given {@link Commandlet} matched and did {@link Commandlet#run() run} successfully, {@code false} otherwise (the
* {@link Commandlet} did not match and we have to try a different candidate).
* {@link Commandlet} did not match and we have to try a different candidate).
*/
private boolean applyAndRun(CliArguments arguments, Commandlet cmd) {

Expand Down Expand Up @@ -966,11 +971,11 @@ public List<CompletionCandidate> complete(CliArguments arguments, boolean includ

/**
* @param arguments the {@link CliArguments} to apply. Will be {@link CliArguments#next() consumed} as they are matched. Consider passing a
* {@link CliArguments#copy() copy} as needed.
* {@link CliArguments#copy() copy} as needed.
* @param cmd the potential {@link Commandlet} to match.
* @param collector the {@link CompletionCandidateCollector}.
* @return {@code true} if the given {@link Commandlet} matches to the given {@link CliArgument}(s) and those have been applied (set in the {@link Commandlet}
* and {@link Commandlet#validate() validated}), {@code false} otherwise (the {@link Commandlet} did not match and we have to try a different candidate).
* and {@link Commandlet#validate() validated}), {@code false} otherwise (the {@link Commandlet} did not match and we have to try a different candidate).
*/
public boolean apply(CliArguments arguments, Commandlet cmd, CompletionCandidateCollector collector) {

Expand Down
Loading

0 comments on commit 7b4e5d6

Please sign in to comment.