-
Notifications
You must be signed in to change notification settings - Fork 64
#1724: Create GUI commandlet #1782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
551f6f1
bbe114b
a109b88
6d291af
b6f79cf
3d2fe9f
4af27c0
87ebd01
8749556
87a1c9d
aa36f5b
81e6128
8436d4c
9336bb4
1252269
96d3fc8
3ab8402
3ba298f
a07f89c
2040cb5
00b5250
59f5097
6c2a675
af122cf
55303b7
91b84e7
4a67dee
893d4a7
7db63d8
ce8fef1
a5a778a
a399503
c209998
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,5 +303,4 @@ | |
| </build> | ||
| </profile> | ||
| </profiles> | ||
|
|
||
| </project> | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,87 @@ | ||||||
| package com.devonfw.tools.ide.tool.gui; | ||||||
|
|
||||||
| import java.nio.file.Files; | ||||||
| import java.nio.file.Path; | ||||||
| import java.util.List; | ||||||
|
|
||||||
| import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | ||||||
|
|
||||||
| import com.devonfw.tools.ide.commandlet.Commandlet; | ||||||
| import com.devonfw.tools.ide.context.IdeContext; | ||||||
| import com.devonfw.tools.ide.process.ProcessContext; | ||||||
| import com.devonfw.tools.ide.process.ProcessContextImpl; | ||||||
| import com.devonfw.tools.ide.process.ProcessMode; | ||||||
| import com.devonfw.tools.ide.tool.ToolEdition; | ||||||
| import com.devonfw.tools.ide.tool.ToolEditionAndVersion; | ||||||
| import com.devonfw.tools.ide.tool.ToolInstallRequest; | ||||||
| import com.devonfw.tools.ide.tool.java.Java; | ||||||
| import com.devonfw.tools.ide.tool.mvn.Mvn; | ||||||
| import com.devonfw.tools.ide.version.BoundaryType; | ||||||
| import com.devonfw.tools.ide.version.VersionIdentifier; | ||||||
| import com.devonfw.tools.ide.version.VersionRange; | ||||||
|
|
||||||
| /** | ||||||
| * {@link Commandlet} to launch the IDEasy GUI. | ||||||
| */ | ||||||
| public class Gui extends Commandlet { | ||||||
|
|
||||||
| private static final Logger LOG = LoggerFactory.getLogger(Gui.class); | ||||||
|
|
||||||
| /** | ||||||
| * @param context the {@link IdeContext}. | ||||||
| */ | ||||||
| public Gui(IdeContext context) { | ||||||
|
|
||||||
| super(context); | ||||||
| addKeyword(getName()); | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| public String getName() { | ||||||
|
|
||||||
| return "gui"; | ||||||
| } | ||||||
|
|
||||||
| @Override | ||||||
| protected void doRun() { | ||||||
|
|
||||||
| ProcessContext processContext = new ProcessContextImpl(this.context); | ||||||
|
|
||||||
| ToolInstallRequest toolInstallRequest = new ToolInstallRequest(true); | ||||||
| toolInstallRequest.setProcessContext(processContext); | ||||||
| toolInstallRequest.setRequested( | ||||||
| new ToolEditionAndVersion( | ||||||
| new ToolEdition("java", "25"), | ||||||
| VersionRange.of(VersionIdentifier.of("25"), VersionIdentifier.of(""), BoundaryType.RIGHT_OPEN) | ||||||
| ) | ||||||
| ); | ||||||
|
|
||||||
| Java java = this.context.getCommandletManager().getCommandlet(Java.class); | ||||||
| java.installAsDependency( | ||||||
| (VersionRange) toolInstallRequest.getRequested().getVersion(), | ||||||
| toolInstallRequest | ||||||
| ); | ||||||
|
|
||||||
| LOG.debug("Starting GUI via commandlet"); | ||||||
|
|
||||||
| Mvn mvn = context.getCommandletManager().getCommandlet(Mvn.class); | ||||||
|
|
||||||
| Path pomPath = context.getIdeInstallationPath().resolve("gui/pom.xml"); | ||||||
| if (!Files.exists(pomPath)) { | ||||||
| LOG.error("Fatal error: The pom.xml file required for launching the IDEasy GUI could not be found in expected location: {}", pomPath); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| List<String> args = List.of( | ||||||
| "-f", | ||||||
| pomPath.toString(), | ||||||
| "exec:exec", | ||||||
| "-Dexec.executable=java", | ||||||
| "-Dexec.classpathScope=compile", | ||||||
| "-Dexec.args=-classpath %classpath com.devonfw.ide.gui.AppLauncher" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KISS
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using exec:java with exec.mainClass will lead to a problem: When using exec:exec with -Dexec.executable=java and with defining the classpath manually, the class will be loaded correctly |
||||||
| ); | ||||||
|
|
||||||
| mvn.runTool(processContext, ProcessMode.DEFAULT, args); | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>com.devonfw.tools.IDEasy.dev</groupId> | ||
| <artifactId>ide</artifactId> | ||
| <version>dev-SNAPSHOT</version> | ||
| </parent> | ||
| <groupId>com.devonfw.tools.IDEasy</groupId> | ||
| <artifactId>ide-gui-launcher</artifactId> | ||
| <version>${revision}</version> | ||
| <packaging>pom</packaging> | ||
| <description>Launcher for IDEasy GUI</description> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.devonfw.tools.IDEasy</groupId> | ||
| <artifactId>ide-gui</artifactId> | ||
| <version>${revision}</version> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>assembly</id> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-antrun-plugin</artifactId> | ||
| <executions> | ||
| <execution> | ||
| <id>copy-gui-pom</id> | ||
| <phase>prepare-package</phase> | ||
| <goals> | ||
| <goal>run</goal> | ||
| </goals> | ||
| <configuration> | ||
| <target> | ||
| <mkdir dir="${project.basedir}/../cli/target/package/${gui.relative_pom_path}"/> | ||
|
|
||
| <copy | ||
| file="${project.basedir}/.flattened-pom.xml" | ||
| tofile="${project.basedir}/../cli/target/package/${gui.relative_pom_path}/pom.xml" | ||
| failonerror="true"/> | ||
| </target> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
| </project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's that?
IDEasy/cli/src/main/java/com/devonfw/tools/ide/tool/ToolEdition.java
Line 9 in c5ce977
You are providing
25as edition of Java - this can never work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I do this properly? Can I just put an empty string for the edition? Because if I want to use
i have to declare the Version and Edition via
ToolEditionAndVersion.