Skip to content
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

#759: upgrade settings commandlet #820

Merged
Merged
Show file tree
Hide file tree
Changes from 114 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
7af9fc5
#765: Fix typos in DoD asciidoc
Oct 2, 2024
aeae1dd
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Oct 17, 2024
e520d16
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Oct 25, 2024
29403d3
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Oct 25, 2024
5bff5eb
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Oct 28, 2024
890c107
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Oct 29, 2024
c55af62
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Oct 31, 2024
3be67d0
#737: Added cd command to shell commandlet
leonrohne27 Nov 6, 2024
60f2e8a
Merge branch 'main' into implement/737-add-cd-command-to-shell-comman…
leonrohne27 Nov 6, 2024
5224bf9
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 7, 2024
02cdeb0
Merge branch 'main' into implement/737-add-cd-command-to-shell-comman…
jan-vcapgemini Nov 7, 2024
d925977
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 8, 2024
2d41161
Merge branch 'main' into implement/737-add-cd-command-to-shell-comman…
jan-vcapgemini Nov 11, 2024
4a8f60b
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 12, 2024
1a6cdb8
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 13, 2024
bad672f
Merge branch 'main' into implement/737-add-cd-command-to-shell-comman…
jan-vcapgemini Nov 14, 2024
f79c030
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 14, 2024
3d2b190
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 14, 2024
e1854bb
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 15, 2024
b85ca18
Merge branch 'main' into implement/737-add-cd-command-to-shell-comman…
jan-vcapgemini Nov 18, 2024
51dd0c2
Update cli/src/main/java/com/devonfw/tools/ide/commandlet/ShellComman…
leonrohne27 Nov 19, 2024
0bd754c
Update cli/src/main/java/com/devonfw/tools/ide/commandlet/ShellComman…
leonrohne27 Nov 19, 2024
0302acf
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 19, 2024
1af2948
#737: optimized cd command
leonrohne27 Nov 19, 2024
ec4d5f6
#737: optimized cd command
leonrohne27 Nov 19, 2024
06e9b8a
#737: Added Changelog entry
leonrohne27 Nov 19, 2024
4602866
#759:
leonrohne27 Nov 19, 2024
7bb5674
kian ist der best
KianRolf Nov 19, 2024
50b9fb2
#759: listchildrenrecursive
KianRolf Nov 20, 2024
07ae66e
#759: rename
leonrohne27 Nov 20, 2024
709cb34
#759: check
KianRolf Nov 20, 2024
ad841a9
#759: delete devon.properties
leonrohne27 Nov 20, 2024
1410aaa
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 21, 2024
09ecb53
#759
leonrohne27 Nov 21, 2024
9a6d662
#759
leonrohne27 Nov 21, 2024
0ab3f49
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 22, 2024
bb75cf9
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 22, 2024
72a720c
#759: Added CheckIfLegacyFolderExists() method
leonrohne27 Nov 25, 2024
47b8ead
#759: combine
KianRolf Nov 25, 2024
a2e3ca9
#759
KianRolf Nov 25, 2024
374a059
#759:
leonrohne27 Nov 25, 2024
af2842e
#759: Added recursive variable replacement
leonrohne27 Nov 25, 2024
78c2fad
#759: Added method that deletes file
leonrohne27 Nov 25, 2024
c51ef83
#759: merge
KianRolf Nov 25, 2024
c5c4324
#759:small fix
KianRolf Nov 25, 2024
bb0c401
#759
leonrohne27 Nov 25, 2024
d8d2a81
#759: Added checkForXMLNameSpace()-method
leonrohne27 Nov 26, 2024
1a55e15
#759
leonrohne27 Nov 26, 2024
8fad8d0
#759: custom-json-file
KianRolf Nov 27, 2024
3668654
Merge branch 'main' of https://github.com/KianRolf/IDEasy
KianRolf Nov 27, 2024
b41dcc7
#759: small changes
leonrohne27 Nov 27, 2024
79c2ff3
#759: Added documentation
leonrohne27 Nov 27, 2024
23b24b5
#759:
leonrohne27 Nov 27, 2024
44bfb40
#759: clean up
leonrohne27 Nov 27, 2024
ba49f5f
#759:clean up and reformat
KianRolf Nov 27, 2024
3c5a53e
#759
leonrohne27 Nov 27, 2024
a6d4e94
#759: performance improvement
KianRolf Nov 28, 2024
0f34d7d
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
KianRolf Nov 28, 2024
27f317c
#759: remove
KianRolf Nov 28, 2024
5159b15
#759: remove
KianRolf Nov 28, 2024
2733362
#759
leonrohne27 Nov 28, 2024
a5817db
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
leonrohne27 Nov 28, 2024
195f190
#759: Add help properties
KianRolf Nov 29, 2024
1126b60
Merge branch 'implement/759-UpgradeSettingsCommandlet' of https://git…
KianRolf Nov 29, 2024
f6277b4
Update ShellCommandlet.java
KianRolf Nov 29, 2024
a6fdcca
Update ShellCommandlet.java
KianRolf Nov 29, 2024
fa91325
Rename ide.properties to devon.properties
KianRolf Nov 29, 2024
c980055
#759: Test beginning
KianRolf Nov 29, 2024
587ebb9
Update CHANGELOG.adoc
leonrohne27 Nov 29, 2024
b919d35
#759: fixed documention link
leonrohne27 Nov 29, 2024
cd751e1
Merge branch 'implement/759-UpgradeSettingsCommandlet' of https://git…
leonrohne27 Nov 29, 2024
db2a4a7
#759: use getSettingsPath() for resolving settings directories
leonrohne27 Nov 29, 2024
d7f60da
#759: file_path to filePath
leonrohne27 Nov 29, 2024
6f3229e
#759: Changed method name
leonrohne27 Nov 29, 2024
afaa4f7
#759: changed checkForXmlNamespace() method
leonrohne27 Nov 29, 2024
3322aa2
Merge branch 'implement/759-UpgradeSettingsCommandlet' of https://git…
KianRolf Nov 29, 2024
589eb25
#759: Test for commandlet
KianRolf Nov 29, 2024
97cae94
#759: Javadoc
KianRolf Nov 29, 2024
1801808
#759: clean up
KianRolf Nov 29, 2024
694a7b8
#759: changed structure for XmlNamespace() method
leonrohne27 Nov 29, 2024
84ed5a4
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
jan-vcapgemini Dec 16, 2024
1383b7b
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
jan-vcapgemini Dec 18, 2024
b614c6d
#759: optimized parsing of custom tools
jan-vcapgemini Dec 18, 2024
6408d55
#759: added missing changes
jan-vcapgemini Dec 18, 2024
1902729
#759: fixed test
jan-vcapgemini Dec 18, 2024
3c85ec1
#759: rewritten implementation to upgrade variable expressions in wor…
hohwille Dec 19, 2024
7f2d622
#759: implemented requested changes
jan-vcapgemini Dec 20, 2024
c4f3aa5
#759: push changes of DirectoryMergerTest
hohwille Dec 20, 2024
9960940
#759: implemented requested changes
jan-vcapgemini Dec 20, 2024
517892b
#759: implemented requested changes
jan-vcapgemini Jan 6, 2025
dac39d9
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
jan-vcapgemini Jan 7, 2025
d607fa6
#759: refactored updateProperties and custom-tools.json
hohwille Jan 7, 2025
a4d685b
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
hohwille Jan 8, 2025
6e087c3
#759: fix NPE
hohwille Jan 8, 2025
8545343
#759: cleanup to resolve review feedback
hohwille Jan 8, 2025
a3154b9
Update CHANGELOG.adoc
hohwille Jan 8, 2025
d37a005
#759: final fixes and test improvements
hohwille Jan 8, 2025
730d826
#759: fixed test
jan-vcapgemini Jan 8, 2025
b4f9e4a
#820: trying to debug test problem
hohwille Jan 9, 2025
e1f6071
#759: also update legacy editions
hohwille Jan 9, 2025
52e98b8
#759: fixed test by adding missing conf due to .gitignore
hohwille Jan 9, 2025
cb81b78
#759: optimized tests
jan-vcapgemini Jan 9, 2025
1307d33
#759: completed last things (*.properties in ~)
hohwille Jan 9, 2025
323bcc4
#759: replacement-patterns.properties was deleted and then tried to m…
hohwille Jan 9, 2025
1ee9951
#759: fix log message
hohwille Jan 9, 2025
db02a0c
#759: completed (.m2 to mvn)
hohwille Jan 9, 2025
d78dbc2
#759: added more tests
jan-vcapgemini Jan 10, 2025
87eac3e
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
jan-vcapgemini Jan 10, 2025
60e0901
#759: adjusted changelog
jan-vcapgemini Jan 10, 2025
7126cf9
#759: optimized tests
jan-vcapgemini Jan 10, 2025
5c9c80b
#759: fixed typo
jan-vcapgemini Jan 10, 2025
0056345
#759: implemented requested changes
jan-vcapgemini Jan 13, 2025
2632801
#759: cleanup
jan-vcapgemini Jan 13, 2025
488d5b9
#759: cleanup
jan-vcapgemini Jan 13, 2025
b4660a6
#759: implemented requested changes
jan-vcapgemini Jan 13, 2025
b7b0d10
#759: implemented requested changes
jan-vcapgemini Jan 13, 2025
3db4692
#759: review rework (JavaDoc)
hohwille Jan 13, 2025
0eac439
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
hohwille Jan 13, 2025
e2ff421
Merge branch 'main' into implement/759-UpgradeSettingsCommandlet
jan-vcapgemini Jan 14, 2025
0ebdb62
#759: implemented requested changes
jan-vcapgemini Jan 14, 2025
115768c
#759: implemented requested changes
jan-vcapgemini Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE
Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/894[#894]: Fix ide.bat printing for initialization and error output
* https://github.com/devonfw/IDEasy/issues/759[#759]: Add UpgradeSettingsCommandlet for the upgrade of legacy devonfw-ide settings to IDEasy

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.devonfw.tools.ide.git.GitUrl;
import com.devonfw.tools.ide.property.FlagProperty;
import com.devonfw.tools.ide.property.StringProperty;
import com.devonfw.tools.ide.repo.CustomTool;
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;
Expand Down Expand Up @@ -164,7 +164,7 @@ private void updateSoftware() {
}

// custom tools in ide-custom-tools.json
for (CustomTool customTool : this.context.getCustomToolRepository().getTools()) {
for (CustomToolMetadata customTool : this.context.getCustomToolRepository().getTools()) {
CustomToolCommandlet customToolCommandlet = new CustomToolCommandlet(this.context, customTool);
toolCommandlets.add(customToolCommandlet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public CommandletManagerImpl(IdeContext context) {
add(new RepositoryCommandlet(context));
add(new UninstallCommandlet(context));
add(new UpdateCommandlet(context));
add(new UpgradeSettingsCommandlet(context));
add(new CreateCommandlet(context));
add(new BuildCommandlet(context));
add(new InstallPluginCommandlet(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void run() {
return;
}

List<Path> propertiesFiles = this.context.getFileAccess().listChildren(repositories, path -> path.getFileName().toString().endsWith(".properties"));
List<Path> propertiesFiles = this.context.getFileAccess()
.listChildren(repositories, path -> path.getFileName().toString().endsWith(".properties"));

boolean forceMode = this.context.isForceMode();
for (Path propertiesFile : propertiesFiles) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package com.devonfw.tools.ide.commandlet;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.function.Function;

import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariables;
import com.devonfw.tools.ide.environment.EnvironmentVariablesPropertiesFile;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
import com.devonfw.tools.ide.merge.DirectoryMerger;
import com.devonfw.tools.ide.repo.CustomToolsJson;
import com.devonfw.tools.ide.repo.CustomToolsJsonMapper;
import com.devonfw.tools.ide.tool.mvn.Mvn;
import com.devonfw.tools.ide.variable.IdeVariables;
import com.devonfw.tools.ide.variable.VariableDefinition;

/**
* {@link Commandlet} to upgrade settings after a migration from devonfw-ide to IDEasy.
*/
public class UpgradeSettingsCommandlet extends Commandlet {

/**
* The constructor.
*
* @param context the {@link IdeContext}.
*/
public UpgradeSettingsCommandlet(IdeContext context) {

super(context);
addKeyword(getName());
}

@Override
public String getName() {

return "upgrade-settings";
}

@Override
public void run() {
updateLegacyFolders();
updateProperties();
updateWorkspaceTemplates();
}

void updateLegacyFolders() {
jan-vcapgemini marked this conversation as resolved.
Show resolved Hide resolved
this.context.info("Updating legacy folders if present...");
Path settingsPath = context.getSettingsPath();
updateLegacyFolder(settingsPath, IdeContext.FOLDER_LEGACY_REPOSITORIES, IdeContext.FOLDER_REPOSITORIES);
updateLegacyFolder(settingsPath, IdeContext.FOLDER_LEGACY_TEMPLATES, IdeContext.FOLDER_TEMPLATES);
updateLegacyFolder(settingsPath.resolve(IdeContext.FOLDER_TEMPLATES).resolve(IdeContext.FOLDER_CONF), Mvn.MVN_CONFIG_LEGACY_FOLDER, Mvn.MVN_CONFIG_FOLDER);
}

private void updateLegacyFolder(Path folder, String legacyName, String newName) {

Path legacyFolder = folder.resolve(legacyName);
Path newFolder = folder.resolve(newName);
if (Files.isDirectory(legacyFolder)) {
try {
if (!Files.exists(newFolder)) {
Files.move(legacyFolder, newFolder, StandardCopyOption.REPLACE_EXISTING);
jan-vcapgemini marked this conversation as resolved.
Show resolved Hide resolved
this.context.success("Successfully renamed folder '{}' to '{}' in {}.", legacyName, newName, folder);
}
} catch (IOException e) {
this.context.error(e, "Error renaming folder {} to {} in {}", legacyName, newName, folder);
}
}
}

void updateWorkspaceTemplates() {
this.context.info("Updating workspace templates (replace legacy variables and change variable syntax)...");

DirectoryMerger merger = this.context.getWorkspaceMerger();
Path settingsDir = this.context.getSettingsPath();
Path workspaceDir = settingsDir.resolve(IdeContext.FOLDER_WORKSPACE);
if (Files.isDirectory(workspaceDir)) {
merger.upgrade(workspaceDir);
}
this.context.getFileAccess().listChildrenMapped(settingsDir, child -> {
Path childWorkspaceDir = child.resolve(IdeContext.FOLDER_WORKSPACE);
if (Files.isDirectory(childWorkspaceDir)) {
merger.upgrade(childWorkspaceDir);
}
return null;
});
}

void updateProperties() {
// updates DEVON_IDE_CUSTOM_TOOLS to new ide-custom-tools.json
String devonCustomTools = IdeVariables.DEVON_IDE_CUSTOM_TOOLS.get(this.context);
if (devonCustomTools != null) {
CustomToolsJson customToolsJson = CustomToolsJsonMapper.parseCustomToolsFromLegacyConfig(devonCustomTools, context);
if (customToolsJson != null) {
CustomToolsJsonMapper.saveJson(customToolsJson, this.context.getSettingsPath().resolve(IdeContext.FILE_CUSTOM_TOOLS));
}
}

// update properties (devon.properties -> ide.properties, convert legacy properties)
EnvironmentVariables environmentVariables = context.getVariables();
while (environmentVariables != null) {
if (environmentVariables instanceof EnvironmentVariablesPropertiesFile environmentVariablesProperties) {
updateProperties(environmentVariablesProperties);
}
environmentVariables = environmentVariables.getParent();
}
Path templatePropertiesDir = this.context.getSettingsTemplatePath().resolve(IdeContext.FOLDER_CONF);
if (Files.exists(templatePropertiesDir)) {
EnvironmentVariablesPropertiesFile environmentVariablesProperties = new EnvironmentVariablesPropertiesFile(null, EnvironmentVariablesType.CONF,
templatePropertiesDir, null, this.context);
updateProperties(environmentVariablesProperties);
}
}

private void updateProperties(EnvironmentVariablesPropertiesFile environmentVariables) {
Path propertiesFilePath = environmentVariables.getPropertiesFilePath();
if (environmentVariables.getLegacyConfiguration() != null) {
if (environmentVariables.getType() == EnvironmentVariablesType.SETTINGS) {
// adds disabled legacySupportEnabled variable if missing in ide.properties
environmentVariables.set(IdeVariables.IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED.getName(), "false", false);
}
environmentVariables.remove(IdeVariables.DEVON_IDE_CUSTOM_TOOLS.getName());
for (VariableDefinition<?> var : IdeVariables.VARIABLES) {
String legacyName = var.getLegacyName();
if (legacyName != null) {
String value = environmentVariables.get(legacyName);
if (value != null) {
String name = var.getName();
String newValue = environmentVariables.get(name);
if (newValue == null) {
environmentVariables.set(name, value, environmentVariables.isExported(name));
}
}
environmentVariables.remove(legacyName);
}
}
updatePropertiesLegacyEdition(environmentVariables, "INTELLIJ_EDITION_TYPE", "INTELLIJ_EDITION", this::mapLegacyIntellijEdition);
updatePropertiesLegacyEdition(environmentVariables, "ECLIPSE_EDITION_TYPE", "ECLIPSE_EDITION", this::mapLegacyIntellijEdition);
environmentVariables.save();
this.context.getFileAccess().backup(environmentVariables.getLegacyPropertiesFilePath());
}
}

private String mapLegacyIntellijEdition(String legacyEdition) {

return switch (legacyEdition) {
case "U" -> "ultimate";
case "C" -> "intellij";
default -> {
this.context.warning("Undefined legacy edition {}", legacyEdition);
yield "intellij";
}
};
}

private String mapLegacyEclipseEdition(String legacyEdition) {

return switch (legacyEdition) {
case "java" -> "eclipse";
case "jee" -> "jee";
case "cpp" -> "cpp";
default -> {
this.context.warning("Undefined legacy edition {}", legacyEdition);
yield "eclipse";
}
};
}

private static void updatePropertiesLegacyEdition(EnvironmentVariablesPropertiesFile environmentVariables, String legacyEditionVariable,
String newEditionVariable, Function<String, String> editionMapper) {

String legacyEdition = environmentVariables.get(legacyEditionVariable);
if (legacyEdition != null) {
String newEdition = environmentVariables.get(newEditionVariable);
if (newEdition == null) {
environmentVariables.set(newEditionVariable, editionMapper.apply(legacyEdition), false);
}
environmentVariables.remove(legacyEditionVariable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public abstract class AbstractIdeContext implements IdeContext {

private Path softwareExtraPath;

private Path softwareRepositoryPath;
private final Path softwareRepositoryPath;

protected Path pluginsPath;

Expand All @@ -91,15 +91,15 @@ public abstract class AbstractIdeContext implements IdeContext {

protected Path urlsPath;

private Path tempPath;
private final Path tempPath;

private Path tempDownloadPath;
private final Path tempDownloadPath;

private Path cwd;

private Path downloadPath;

private Path toolRepositoryPath;
private final Path toolRepositoryPath;

protected Path userHome;

Expand Down Expand Up @@ -308,11 +308,10 @@ private boolean isIdeHome(Path dir) {
private EnvironmentVariables createVariables() {

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?
AbstractEnvironmentVariables workspace = extendVariables(settings, this.workspacePath, EnvironmentVariablesType.WORKSPACE);
AbstractEnvironmentVariables conf = extendVariables(workspace, this.confPath, EnvironmentVariablesType.CONF);
AbstractEnvironmentVariables user = system.extend(this.userHomeIde, EnvironmentVariablesType.USER);
AbstractEnvironmentVariables settings = user.extend(this.settingsPath, EnvironmentVariablesType.SETTINGS);
AbstractEnvironmentVariables workspace = settings.extend(this.workspacePath, EnvironmentVariablesType.WORKSPACE);
AbstractEnvironmentVariables conf = workspace.extend(this.confPath, EnvironmentVariablesType.CONF);
return conf.resolved();
}

Expand All @@ -321,26 +320,6 @@ protected AbstractEnvironmentVariables createSystemVariables() {
return EnvironmentVariables.ofSystem(this);
}

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

Path propertiesFile = null;
if (propertiesPath == null) {
trace("Configuration directory for type {} does not exist.", type);
} else if (Files.isDirectory(propertiesPath)) {
propertiesFile = propertiesPath.resolve(EnvironmentVariables.DEFAULT_PROPERTIES);
boolean legacySupport = (type != EnvironmentVariablesType.USER);
if (legacySupport && !Files.exists(propertiesFile)) {
Path legacyFile = propertiesPath.resolve(EnvironmentVariables.LEGACY_PROPERTIES);
if (Files.exists(legacyFile)) {
propertiesFile = legacyFile;
}
}
} else {
debug("Configuration directory {} does not exist.", propertiesPath);
}
return envVariables.extend(propertiesFile, type);
}

@Override
public SystemInfo getSystemInfo() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public interface IdeContext extends IdeStartContext {
/** Legacy folder name used as compatibility fallback if {@link #FOLDER_TEMPLATES} does not exist. */
String FOLDER_LEGACY_TEMPLATES = "devon";

/** The filename of the configuration file in the settings for this {@link CustomToolRepository}. */
String FILE_CUSTOM_TOOLS = "ide-custom-tools.json";

/**
* @return {@code true} if {@link #isOfflineMode() offline mode} is active or we are NOT {@link #isOnline() online}, {@code false} otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ public VariableSource getSource() {
protected boolean isExported(String name) {

if (this.parent != null) {
if (this.parent.isExported(name)) {
return true;
}
return this.parent.isExported(name);
}
return false;
}
Expand Down Expand Up @@ -144,13 +142,14 @@ protected VariableLine createVariableLine(String name, boolean onlyExported, Abs
}

/**
* @param propertiesFilePath the {@link #getPropertiesFilePath() propertiesFilePath} of the child {@link EnvironmentVariables}.
* @param propertiesFolderPath the {@link Path} to the folder containing the {@link #getPropertiesFilePath() properties file} of the child
* {@link EnvironmentVariables}.
* @param type the {@link #getType() type}.
* @return the new {@link EnvironmentVariables}.
*/
public AbstractEnvironmentVariables extend(Path propertiesFilePath, EnvironmentVariablesType type) {
public AbstractEnvironmentVariables extend(Path propertiesFolderPath, EnvironmentVariablesType type) {

return new EnvironmentVariablesPropertiesFile(this, type, propertiesFilePath, this.context);
return new EnvironmentVariablesPropertiesFile(this, type, propertiesFolderPath, null, this.context);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ default EnvironmentVariables getParent() {
return null;
}

/**
* @param name the {@link com.devonfw.tools.ide.variable.VariableDefinition#getName() name} of the variable to set.
* @param value the new {@link #get(String) value} of the variable to set. May be {@code null} to unset the variable.
* @return the old variable value.
*/
default String set(String name, String value) {

throw new UnsupportedOperationException();
}

/**
* @param name the {@link com.devonfw.tools.ide.variable.VariableDefinition#getName() name} of the variable to set.
* @param value the new {@link #get(String) value} of the variable to set. May be {@code null} to unset the variable.
Expand Down Expand Up @@ -264,4 +274,12 @@ static String getToolEditionVariable(String tool) {
return tool.toUpperCase(Locale.ROOT) + "_EDITION";
}

/**
* Removes a property.
*
* @param string name of the property to remove.
*/
default void remove(String string) {
throw new UnsupportedOperationException("Not yet implemented!");
}
}
Loading
Loading