Skip to content

Commit

Permalink
Merge branch 'main' into enhance/404-logging-concept
Browse files Browse the repository at this point in the history
# Conflicts:
#	cli/src/main/java/com/devonfw/tools/ide/log/AbstractIdeSubLogger.java
  • Loading branch information
jan-vcapgemini committed Feb 4, 2025
2 parents 98a0f2e + 62fa12b commit 19273ac
Show file tree
Hide file tree
Showing 62 changed files with 1,438 additions and 381 deletions.
2 changes: 1 addition & 1 deletion .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-Drevision=2025.01.003-beta-SNAPSHOT
-Drevision=2025.02.001-beta-SNAPSHOT
11 changes: 11 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

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

== 2025.01.003

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/993[#993] Creation of start scripts for IDEs
* https://github.com/devonfw/IDEasy/pull/1003[#1003] graalvm compatibility mode to make x86-64 releases work on arm-64
* https://github.com/devonfw/IDEasy/issues/954[#954] Improve repository support
* https://github.com/devonfw/IDEasy/issues/993[#993] Creation of start scripts for IDEs

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

== 2025.01.002

Release with important bugfixes:
Expand Down
1 change: 1 addition & 0 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
<buildArgs>
<arg>--enable-url-protocols=http,https</arg>
<arg>--initialize-at-build-time=org.apache.commons</arg>
<arg>-march=compatibility</arg>
</buildArgs>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package com.devonfw.tools.ide.commandlet;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;

import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.git.GitContext;
import com.devonfw.tools.ide.git.GitUrl;
import com.devonfw.tools.ide.git.repository.RepositoryCommandlet;
import com.devonfw.tools.ide.io.FileAccess;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.repo.CustomToolMetadata;
import com.devonfw.tools.ide.step.Step;
import com.devonfw.tools.ide.tool.CustomToolCommandlet;
import com.devonfw.tools.ide.tool.ToolCommandlet;
import com.devonfw.tools.ide.tool.repository.CustomToolMetadata;
import com.devonfw.tools.ide.variable.IdeVariables;

/**
Expand All @@ -24,10 +29,13 @@
public abstract class AbstractUpdateCommandlet extends Commandlet {

/** {@link StringProperty} for the settings repository URL. */
protected final StringProperty settingsRepo;
public final StringProperty settingsRepo;

/** {@link FlagProperty} for skipping installation/updating of tools */
protected final FlagProperty skipTools;
/** {@link FlagProperty} for skipping installation/updating of tools. */
public final FlagProperty skipTools;

/** {@link FlagProperty} for skipping the setup of git repositories. */
public final FlagProperty skipRepositories;

/**
* The constructor.
Expand All @@ -38,7 +46,8 @@ public AbstractUpdateCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
this.skipTools = add(new FlagProperty("--skip-tools", false, null));
this.skipTools = add(new FlagProperty("--skip-tools"));
this.skipRepositories = add(new FlagProperty("--skip-repositories"));
this.settingsRepo = new StringProperty("", false, "settingsRepository");
}

Expand All @@ -51,11 +60,9 @@ public void run() {
updateConf();
reloadContext();

if (this.skipTools.isTrue()) {
this.context.info("Skipping installation/update of tools as specified by the user.");
} else {
updateSoftware();
}
updateSoftware();
updateRepositories();
createStartScripts();
}

private void reloadContext() {
Expand Down Expand Up @@ -109,8 +116,8 @@ private void setupConf(Path template, Path conf) {
}

/**
* Updates the settings repository in IDE_HOME/settings by either cloning if no such repository exists or pulling
* if the repository exists then saves the latest current commit ID in the file ".commit.id".
* Updates the settings repository in IDE_HOME/settings by either cloning if no such repository exists or pulling if the repository exists then saves the
* latest current commit ID in the file ".commit.id".
*/
protected void updateSettings() {

Expand Down Expand Up @@ -149,9 +156,12 @@ protected void updateSettings() {

private void updateSoftware() {

if (this.skipTools.isTrue()) {
this.context.info("Skipping installation/update of tools as specified by the user.");
return;
}
try (Step step = this.context.newStep("Install or update software")) {
Set<ToolCommandlet> toolCommandlets = new HashSet<>();

// installed tools in IDE_HOME/software
List<Path> softwarePaths = this.context.getFileAccess().listChildren(this.context.getSoftwarePath(), Files::isDirectory);
for (Path softwarePath : softwarePaths) {
Expand Down Expand Up @@ -183,10 +193,86 @@ private void updateSoftware() {
} catch (Exception e) {
step.error(e, "Installation of {} failed!", toolCommandlet.getName());
}

}
step.success();
}
}

private void updateRepositories() {

if (this.skipRepositories.isTrue()) {
this.context.info("Skipping setup of repositories as specified by the user.");
return;
}
RepositoryCommandlet repositoryCommandlet = this.context.getCommandletManager().getCommandlet(RepositoryCommandlet.class);
repositoryCommandlet.reset();
repositoryCommandlet.run();
}

private void createStartScripts() {

List<String> ides = IdeVariables.CREATE_START_SCRIPTS.get(this.context);
if (ides == null) {
this.context.info("Variable CREATE_START_SCRIPTS is undefined - skipping start script creation.");
return;
}
for (String ide : ides) {
ToolCommandlet tool = this.context.getCommandletManager().getToolCommandlet(ide);
if (tool == null) {
this.context.error("Undefined IDE '{}' configured in variable CREATE_START_SCRIPTS.");
} else {
createStartScript(ide);
}
}
}

private void createStartScript(String ide) {

this.context.info("Creating start scripts for {}", ide);
Path workspaces = this.context.getIdeHome().resolve(IdeContext.FOLDER_WORKSPACES);
try (Stream<Path> childStream = Files.list(workspaces)) {
Iterator<Path> iterator = childStream.iterator();
while (iterator.hasNext()) {
Path child = iterator.next();
if (Files.isDirectory(child)) {
createStartScript(ide, child.getFileName().toString());
}
}
} catch (IOException e) {
throw new RuntimeException("Failed to list children of directory " + workspaces, e);
}
}

private void createStartScript(String ide, String workspace) {

Path ideHome = this.context.getIdeHome();
String scriptName = ide + "-" + workspace;
boolean windows = this.context.getSystemInfo().isWindows();
if (windows) {
scriptName = scriptName + ".bat";
} else {
scriptName = scriptName + ".sh";
}
Path scriptPath = ideHome.resolve(scriptName);
if (Files.exists(scriptPath)) {
return;
}
String scriptContent;
if (windows) {
scriptContent = "@echo off\r\n"
+ "pushd %~dp0\r\n"
+ "cd workspaces/" + workspace + "\r\n"
+ "call ide " + ide + "\r\n"
+ "popd\r\n";
} else {
scriptContent = "#!/usr/bin/env bash\n"
+ "cd \"$(dirname \"$0\")\"\n"
+ "cd workspaces/" + workspace + "\n"
+ "ide " + ide + "\n";
}
FileAccess fileAccess = this.context.getFileAccess();
fileAccess.writeFileContent(scriptContent, scriptPath);
fileAccess.makeExecutable(scriptPath);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.devonfw.tools.ide.cli.CliArguments;
import com.devonfw.tools.ide.completion.CompletionCandidateCollector;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.git.repository.RepositoryCommandlet;
import com.devonfw.tools.ide.property.KeywordProperty;
import com.devonfw.tools.ide.property.Property;
import com.devonfw.tools.ide.tool.androidstudio.AndroidStudio;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public class CreateCommandlet extends AbstractUpdateCommandlet {
/** {@link StringProperty} for the name of the new project */
public final StringProperty newProject;

/** {@link FlagProperty} for skipping the setup of git repositories */
public final FlagProperty skipRepositories;

/** {@link FlagProperty} for creating a project with settings inside a code repository */
public final FlagProperty codeRepositoryFlag;

Expand All @@ -32,7 +29,6 @@ public CreateCommandlet(IdeContext context) {

super(context);
this.newProject = add(new StringProperty("", true, "project"));
this.skipRepositories = add(new FlagProperty("--skip-repositories"));
this.codeRepositoryFlag = add(new FlagProperty("--code"));
add(this.settingsRepo);
}
Expand Down Expand Up @@ -65,14 +61,7 @@ public void run() {
initializeProject(newProjectPath);
this.context.setIdeHome(newProjectPath);
super.run();

if (this.skipRepositories.isTrue()) {
this.context.info("Skipping the cloning of project repositories as specified by the user.");
} else {
updateRepositories();
}
this.context.success("Successfully created new project '{}'.", newProjectName);

}

private void initializeCodeRepository(String repoUrl) {
Expand Down Expand Up @@ -101,23 +90,18 @@ private void initializeProject(Path newInstancePath) {
fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_WORKSPACES).resolve(IdeContext.WORKSPACE_MAIN));
}

private void updateRepositories() {

this.context.getCommandletManager().getCommandlet(RepositoryCommandlet.class).run();
}

@Override
protected void updateSettings() {

if (codeRepositoryFlag.isTrue()) {
if (this.codeRepositoryFlag.isTrue()) {
String codeRepository = this.settingsRepo.getValue();
if (codeRepository == null || codeRepository.isBlank()) {
String message = """
No code repository was given after '--code'.
Please give the code repository below that includes your settings folder.
Further details can be found here: https://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc
Code repository URL:
""";
No code repository was given after '--code'.
Please give the code repository below that includes your settings folder.
Further details can be found here: https://github.com/devonfw/IDEasy/blob/main/documentation/settings.adoc
Code repository URL:
""";
codeRepository = this.context.askForInput(message);
}
initializeCodeRepository(codeRepository);
Expand Down

This file was deleted.

Loading

0 comments on commit 19273ac

Please sign in to comment.