Skip to content

Commit

Permalink
Merge branch 'devonfw:main' into devonfw#734-improve-process-result
Browse files Browse the repository at this point in the history
  • Loading branch information
alfeilex authored Dec 16, 2024
2 parents af6add1 + 52afdd7 commit 8491143
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-Drevision=2024.12.001-beta-SNAPSHOT
-Drevision=2024.12.002-beta-SNAPSHOT
11 changes: 10 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

This file documents all notable changes to https://github.com/devonfw/IDEasy[IDEasy].

== 2024.12.002

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/888[#888]: Removed gu update functionality (needs to be run manually for old versions now).
* https://github.com/devonfw/IDEasy/issues/885[#885]: Gcviewer starts in foreground fixed

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/17?closed=1[milestone 2024.12.002].

== 2024.12.001

NOTE: ATTENTION: When installing this release as an update, you need to manually remove IDEasy entries from `.bashrc` and if present also `.zshrc`.
Expand All @@ -26,7 +35,7 @@ Release with new features and bugfixes:
* https://github.com/devonfw/IDEasy/issues/737[#737]: Adds cd command to ide shell
* https://github.com/devonfw/IDEasy/issues/879[#879]: cannot omit default settings URL in ide create
* https://github.com/devonfw/IDEasy/issues/758[#758]: Create status commandlet
* https://github.com/devonfw/IDEasy/issues/824[#824]: ide create «settings-url»#«branch» not working
* https://github.com/devonfw/IDEasy/issues/824[#824]: ide create «settings-url»#«branch» not working
* https://github.com/devonfw/IDEasy/issues/875[#875]: lazydocker is not working
* https://github.com/devonfw/IDEasy/issues/754[#754]: Again messages break processable command output
* https://github.com/devonfw/IDEasy/issues/737[#739]: Improved error handling to show 'You are not inside an IDE installation' only when relevant.
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
<executions>
<execution>
<id>create-distribution</id>
<phase>install</phase>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public CliProcessException(ProcessResult processResult) {
/**
* The constructor.
*
* @param message the message to display.
* @param processResult the {@link #getProcessResult() process result}.
*/
public CliProcessException(String message, ProcessResult processResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,10 @@ private void logOnlineStatus() {
this.context.warning("You are offline. Check your internet connection and potential proxy settings.");
}
}

@Override
public boolean isIdeRootRequired() {

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,9 @@ private String addExecutable(String exec, List<String> args) {
private void performLogging(ProcessResult result, int exitCode, String interpreter) {

if (!result.isSuccessful() && (this.errorHandling != ProcessErrorHandling.NONE)) {
IdeLogLevel ideLogLevel;
IdeLogLevel ideLogLevel = this.errorHandling.getLogLevel();
String message = createCommandMessage(interpreter, "\nfailed with exit code " + exitCode + "!");

if (this.errorHandling == ProcessErrorHandling.LOG_ERROR) {
ideLogLevel = IdeLogLevel.ERROR;
} else if (this.errorHandling == ProcessErrorHandling.LOG_WARNING) {
ideLogLevel = IdeLogLevel.WARNING;
} else {
ideLogLevel = IdeLogLevel.ERROR;
this.context.error("Internal error: Undefined error handling {}", this.errorHandling);
}

context.level(ideLogLevel).log(message);
result.log(ideLogLevel, context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.devonfw.tools.ide.process;

import com.devonfw.tools.ide.log.IdeLogLevel;

/**
* {@link Enum} with the available handling if a {@link Process#exitValue() status code} was not {@link ProcessResult#SUCCESS successful}.
*/
Expand All @@ -26,6 +28,15 @@ public enum ProcessErrorHandling {
* Throw an exception if the status code was not successful. In this case the {@link ProcessContext#run() run} method will never return an exit code other
* than {@link ProcessResult#SUCCESS} as otherwise an exception is thrown preventing the method to return.
*/
THROW_ERR
THROW_ERR;

/**
* @return the matching {@link IdeLogLevel}.
*/
public IdeLogLevel getLogLevel() {
if (this.equals(LOG_WARNING)) {
return IdeLogLevel.WARNING;
}
return IdeLogLevel.ERROR;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.process.ProcessContext;
import com.devonfw.tools.ide.process.ProcessMode;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
import com.devonfw.tools.ide.tool.java.Java;
Expand Down Expand Up @@ -40,6 +41,6 @@ public void run() {
pc.executable("java");
pc.addArg("-jar");
pc.addArg("gcviewer-" + getInstalledVersion() + ".jar");
pc.run();
pc.run(ProcessMode.BACKGROUND_SILENT);
}
}
21 changes: 2 additions & 19 deletions cli/src/main/java/com/devonfw/tools/ide/tool/graalvm/GraalVm.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariables;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
import com.devonfw.tools.ide.process.ProcessErrorHandling;
import com.devonfw.tools.ide.process.ProcessMode;
import com.devonfw.tools.ide.step.Step;
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet;
import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor;
import com.devonfw.tools.ide.version.VersionIdentifier;

/**
* {@link LocalToolCommandlet} for <a href="https://www.graalvm.org/">GraalVM</a>, an advanced JDK with ahead-of-time Native Image compilation.
*/
public class GraalVm extends PluginBasedCommandlet {
public class GraalVm extends LocalToolCommandlet {

/**
* The constructor.
Expand Down Expand Up @@ -57,18 +54,4 @@ public void postInstall() {
super.postInstall();
}

@Override
public void installPlugin(ToolPluginDescriptor plugin, Step step) {
doGuPluginCommand(plugin, "install");
}

@Override
public void uninstallPlugin(ToolPluginDescriptor plugin) {
doGuPluginCommand(plugin, "remove");
}

private void doGuPluginCommand(ToolPluginDescriptor plugin, String command) {
this.context.newProcess().errorHandling(ProcessErrorHandling.THROW_CLI).executable(getToolPath().resolve("bin").resolve("gu")).addArgs(command, plugin.name()).run(ProcessMode.DEFAULT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.devonfw.tools.ide.cli.CliException;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.log.IdeLogLevel;
import com.devonfw.tools.ide.process.ProcessContext;
import com.devonfw.tools.ide.process.ProcessErrorHandling;
import com.devonfw.tools.ide.process.ProcessMode;
Expand All @@ -19,8 +20,8 @@
*/
public class LazyDocker extends LocalToolCommandlet {

public static final VersionIdentifier MIN_API_VERSION = VersionIdentifier.of("1.25");
public static final VersionIdentifier MIN_COMPOSE_VERSION = VersionIdentifier.of("1.23.2");
private static final VersionIdentifier MIN_API_VERSION = VersionIdentifier.of("1.25");
private static final VersionIdentifier MIN_COMPOSE_VERSION = VersionIdentifier.of("1.23.2");

/**
* The constructor.
Expand All @@ -38,21 +39,23 @@ protected void installDependencies() {
// TODO create lazydocker/lazydocker/dependencies.json file in ide-urls and delete this method
getCommandlet(Docker.class).install();
// verify docker API version requirements
ProcessContext pc = this.context.newProcess().errorHandling(ProcessErrorHandling.NONE).executable("docker")
.addArg("version").addArg("--format").addArg("'{{.Client.APIVersion}}'");
ProcessContext pc = this.context.newProcess().errorHandling(ProcessErrorHandling.NONE).executable("docker").addArg("version").addArg("--format")
.addArg("'{{.Client.APIVersion}}'");
ProcessResult result = pc.run(ProcessMode.DEFAULT_CAPTURE);
verifyDockerVersion(result, MIN_API_VERSION, "docker API");

// verify docker compose version requirements
pc = this.context.newProcess().errorHandling(ProcessErrorHandling.NONE).executable("docker-compose").addArg("version")
.addArg("--short");
pc = this.context.newProcess().errorHandling(ProcessErrorHandling.NONE).executable("docker-compose").addArg("version").addArg("--short");
result = pc.run(ProcessMode.DEFAULT_CAPTURE);
verifyDockerVersion(result, MIN_COMPOSE_VERSION, "docker-compose");
}

private static void verifyDockerVersion(ProcessResult result, VersionIdentifier minimumVersion, String kind) {
private void verifyDockerVersion(ProcessResult result, VersionIdentifier minimumVersion, String kind) {
// we have this pattern a lot that we want to get a single line output of a successful ProcessResult.
// we should create a generic method in ProcessResult for this use-case.
if (!result.isSuccessful()) {
result.log(IdeLogLevel.WARNING, this.context);
}
if (result.getOut().isEmpty()) {
throw new CliException("Docker is not installed, but required for lazydocker.\n" //
+ "To install docker, call the following command:\n" //
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.devonfw.tools.ide.commandlet;

import org.junit.jupiter.api.Test;

import com.devonfw.tools.ide.cli.CliArguments;
import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;

/**
* Test of {@link StatusCommandlet}.
*/
public class StatusCommandletTest extends AbstractIdeContextTest {

private static final String PROJECT_BASIC = "basic";

@Test
public void testStatusOutsideOfHome() {
//arrange
IdeTestContext context = new IdeTestContext();
CliArguments args = new CliArguments("status");
args.next();

//act
context.run(args);

//assert
assertThat(context).logAtWarning().hasMessageContaining("You are not inside an IDE installation: ");
}
}
1 change: 1 addition & 0 deletions gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<groupId>com.devonfw.tools.IDEasy</groupId>
<artifactId>ide-gui</artifactId>
<version>${revision}</version>
<name>${project.artifactId}</name>

<properties>
<mainClass>com.devonfw.ide.gui.AppLauncher</mainClass>
Expand Down

0 comments on commit 8491143

Please sign in to comment.