diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7c28a1e05b..d8d21bf84b 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,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/1676[#1676]: Import extra sdks automatically into ide * https://github.com/devonfw/IDEasy/issues/2176[#2176]: Support 7z archive extraction * https://github.com/devonfw/IDEasy/issues/2100[#2100]: Fix Python not available for Mac x64 * https://github.com/devonfw/IDEasy/issues/2134[#2134]: Add auto-completion for icd command diff --git a/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java index 2874a0ef04..614771ee18 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/commandlet/AbstractUpdateCommandlet.java @@ -33,6 +33,7 @@ import com.devonfw.tools.ide.tool.extra.ExtraToolInstallation; import com.devonfw.tools.ide.tool.extra.ExtraTools; import com.devonfw.tools.ide.tool.extra.ExtraToolsMapper; +import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet; import com.devonfw.tools.ide.variable.IdeVariables; import com.devonfw.tools.ide.version.VersionIdentifier; @@ -349,6 +350,18 @@ private void doUpdateSoftwareStep(Step step) { List installations = extraTools.getExtraInstallations(tool); this.context.newStep("Install extra version(s) of " + tool).run(() -> installExtraToolInstallations(tool, installations)); } + + // After installing extra tools, synchronize them into all IDE workspaces + List ides = IdeVariables.CREATE_START_SCRIPTS.get(this.context); + if (ides != null) { + for (String ideName : ides) { + ToolCommandlet ideCommandlet = commandletManager.getToolCommandlet(ideName); + if (ideCommandlet instanceof IdeToolCommandlet) { + LOG.info("Synchronizing extra tools into {} workspace", ideName); + ((IdeToolCommandlet) ideCommandlet).configureWorkspace(); + } + } + } } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java b/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java index 3443b60d68..098cc180b4 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java +++ b/cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java @@ -30,8 +30,8 @@ import com.devonfw.tools.ide.tool.npm.Npm; import com.devonfw.tools.ide.tool.npm.NpmRepository; import com.devonfw.tools.ide.tool.pip.PipRepository; -import com.devonfw.tools.ide.tool.repository.ToolRepository; import com.devonfw.tools.ide.tool.python.PythonRepository; +import com.devonfw.tools.ide.tool.repository.ToolRepository; import com.devonfw.tools.ide.tool.uv.UvRepository; import com.devonfw.tools.ide.url.model.UrlMetadata; import com.devonfw.tools.ide.variable.IdeVariables; @@ -123,6 +123,9 @@ public interface IdeContext extends IdeStartContext { /** The name of the bin folder where executable files are found by default. */ String FOLDER_BIN = "bin"; + /** The name of the repository folder used to store repository data */ + String FOLDER_REPOSITORY = "repository"; + /** The name of the repositories folder where properties files are stores for each repository */ String FOLDER_REPOSITORIES = "repositories"; @@ -416,9 +419,9 @@ default void requireOnline(String purpose, boolean explicitOnlineCheck) { Path getIdeRoot(); /** - * @param ideRoot the new value of {@link #getIdeRoot() IDE_ROOT}. Typically detected automatically from the environment and working directory, but may need - * to be set explicitly (e.g. during the initial installation where the {@code IDE_ROOT} environment variable is not yet available but the installation - * target is already known). + * @param ideRoot the new value of {@link #getIdeRoot() IDE_ROOT}. Typically detected automatically from the environment and working directory, but may + * need to be set explicitly (e.g. during the initial installation where the {@code IDE_ROOT} environment variable is not yet available but the + * installation target is already known). */ void setIdeRoot(Path ideRoot); diff --git a/cli/src/main/java/com/devonfw/tools/ide/git/repository/RepositoryCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/git/repository/RepositoryCommandlet.java index 1b8dd0b611..9004c7779b 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/git/repository/RepositoryCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/git/repository/RepositoryCommandlet.java @@ -41,13 +41,13 @@ public RepositoryCommandlet(IdeContext context) { super(context); addKeyword(getName()); addKeyword("setup"); - this.repository = add(new RepositoryProperty("", false, "repository")); + this.repository = add(new RepositoryProperty("", false, IdeContext.FOLDER_REPOSITORY)); } @Override public String getName() { - return "repository"; + return IdeContext.FOLDER_REPOSITORY; } @Override diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java b/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java index 6b5ffdf5c1..77d426fadf 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java @@ -109,7 +109,7 @@ public boolean installPlugin(ToolPluginDescriptor plugin, Step step, ProcessCont } @Override - protected void configureWorkspace() { + public void configureWorkspace() { Path lockfile = this.context.getWorkspacePath().resolve(".metadata/.lock"); if (isLocked(lockfile)) { diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/extra/ExtraTools.java b/cli/src/main/java/com/devonfw/tools/ide/tool/extra/ExtraTools.java index 55f1de2777..e419459b37 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/extra/ExtraTools.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/extra/ExtraTools.java @@ -8,6 +8,9 @@ import java.util.Map.Entry; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.devonfw.tools.ide.json.JsonObject; /** @@ -20,6 +23,8 @@ public class ExtraTools implements JsonObject { private final Map> tool2installationsMap; + private static final Logger LOG = LoggerFactory.getLogger(ExtraTools.class); + /** * The constructor. */ @@ -51,6 +56,12 @@ public List getExtraInstallations(String tool) { */ public void addExtraInstallations(String tool, ExtraToolInstallation extraInstallation) { + if ((tool != null) && (extraInstallation != null) && tool.equalsIgnoreCase(extraInstallation.name())) { + LOG.warn("Invalid extra installation name '{}' for tool '{}': the extra installation name must not be the same as the tool name.", + extraInstallation.name(), tool); + return; + } + List list = this.tool2installationsMap.computeIfAbsent(tool, k -> new ArrayList<>()); list.add(extraInstallation); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java index 6f0256c581..a1ec03e89d 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeToolCommandlet.java @@ -2,15 +2,25 @@ import java.nio.file.Files; import java.nio.file.Path; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; import com.devonfw.tools.ide.common.Tag; import com.devonfw.tools.ide.context.IdeContext; +import com.devonfw.tools.ide.environment.AbstractEnvironmentVariables; +import com.devonfw.tools.ide.environment.ExtensibleEnvironmentVariables; import com.devonfw.tools.ide.io.FileAccess; +import com.devonfw.tools.ide.log.IdeLogLevel; +import com.devonfw.tools.ide.merge.xml.XmlMergeDocument; +import com.devonfw.tools.ide.merge.xml.XmlMerger; import com.devonfw.tools.ide.process.ProcessMode; import com.devonfw.tools.ide.process.ProcessResult; import com.devonfw.tools.ide.step.Step; @@ -18,6 +28,9 @@ import com.devonfw.tools.ide.tool.ToolInstallRequest; import com.devonfw.tools.ide.tool.ToolInstallation; import com.devonfw.tools.ide.tool.eclipse.Eclipse; +import com.devonfw.tools.ide.tool.extra.ExtraToolInstallation; +import com.devonfw.tools.ide.tool.extra.ExtraTools; +import com.devonfw.tools.ide.tool.extra.ExtraToolsMapper; import com.devonfw.tools.ide.tool.intellij.Intellij; import com.devonfw.tools.ide.tool.plugin.PluginBasedCommandlet; import com.devonfw.tools.ide.tool.vscode.Vscode; @@ -29,6 +42,8 @@ public abstract class IdeToolCommandlet extends PluginBasedCommandlet { private static final Logger LOG = LoggerFactory.getLogger(IdeToolCommandlet.class); + private final Map> extraSdkMap; + /** * The constructor. * @@ -40,6 +55,7 @@ public IdeToolCommandlet(IdeContext context, String tool, Set tags) { super(context, tool, tags); assert (hasIde(tags)); + this.extraSdkMap = new HashMap<>(); } private boolean hasIde(Set tags) { @@ -66,14 +82,13 @@ public ProcessResult runTool(List args) { @Override public ToolInstallation install(ToolInstallRequest request) { - configureWorkspace(); return super.install(request); } /** * Configure (initialize or update) the workspace for this IDE using the templates from the settings. */ - protected void configureWorkspace() { + public void configureWorkspace() { FileAccess fileAccess = this.context.getFileAccess(); Path workspaceFolder = this.context.getWorkspacePath(); @@ -91,6 +106,9 @@ private void doMergeWorkspaceStep(Step step, Path workspaceFolder) { errors = mergeWorkspace(this.context.getUserHomeIde(), workspaceFolder, errors); errors = mergeWorkspace(this.context.getSettingsPath(), workspaceFolder, errors); errors = mergeWorkspace(this.context.getConfPath(), workspaceFolder, errors); + + synchronizeExtraToolInstallations(); + if (errors == 0) { step.success(); } else { @@ -131,4 +149,86 @@ public void importRepository(Path repositoryPath) { throw new UnsupportedOperationException("Repository import is not yet implemented for IDE " + this.tool); } + + /** + * Registers support for synchronizing an extra SDK/template for this IDE. + * + *

+ * The registered template path must be relative to the IDE workspace root. During workspace synchronization, the generic extra-SDK handling in + * {@link #synchronizeExtraToolInstallations()} uses this mapping to locate the corresponding template file in the settings repository and merge it into the + * current workspace. + *

+ * + * @param sdk the name of the extra SDK/tool as configured in {@code ide-extra-tools.json}. + * @param relativeTemplatePath the workspace-relative path of the IDE-specific template file to merge. + */ + protected void registerExtraSdkTemplate(String sdk, Path relativeTemplatePath) { + Set templatePaths = this.extraSdkMap.computeIfAbsent(sdk, _ -> new HashSet<>()); + templatePaths.add(relativeTemplatePath); + } + + /** + * Synchronizes extra IDEasy tool installations into the current IDE workspace configuration if supported. + * + *

+ * By default, nothing will happen. Your IDE commandlet has to register one or more according templates in its constructor. + *

+ */ + protected void synchronizeExtraToolInstallations() { + ExtraTools extraTools = ExtraToolsMapper.get().loadJsonFromFolder(this.context.getSettingsPath()); + if (extraTools == null) { + return; + } + for (String sdk : extraTools.getSortedToolNames()) { + Set templatePaths = this.extraSdkMap.get(sdk); + if ((templatePaths == null) || templatePaths.isEmpty()) { + LOG.debug("Skipping import of extra tool {} into {} because not configured or supported.", sdk, this.tool); + continue; + } + List extraInstallations = extraTools.getExtraInstallations(sdk); + synchronizeExtraToolInstallation(sdk, templatePaths, extraInstallations); + } + } + + private void synchronizeExtraToolInstallation(String sdk, Set templatePaths, List extraInstallations) { + for (Path templatePath : templatePaths) { + Path workspaceFile = this.context.getWorkspacePath().resolve(templatePath); + Path templateFile = this.context.getSettingsPath().resolve(this.tool).resolve(IdeContext.FOLDER_WORKSPACE) + .resolve(IdeContext.FOLDER_REPOSITORY) + .resolve(templatePath); + if (Files.exists(templateFile)) { + for (ExtraToolInstallation extraInstallation : extraInstallations) { + synchronizeExtraToolInstallation(sdk, templateFile, workspaceFile, extraInstallation); + } + } else { + LOG.warn("You are missing a template file at {}.", templatePath); + IdeLogLevel.INTERACTION.log(LOG, "Please ask the IDEasy admin in your project to merge your settings with upstream."); + } + } + } + + private void synchronizeExtraToolInstallation(String sdk, Path templateFile, Path workspaceFile, ExtraToolInstallation installation) { + String name = installation.name(); + Path extraToolHome = this.context.getSoftwareExtraPath().resolve(sdk).resolve(name); + if (!Files.isDirectory(extraToolHome)) { + LOG.warn("Skipping extra tool installation import to {} because it is missing at {}", this.tool, extraToolHome); + IdeLogLevel.INTERACTION.log(LOG, "Please run the following command to fix:\nide update"); + return; + } + ExtensibleEnvironmentVariables environmentVariables = new ExtensibleEnvironmentVariables( + (AbstractEnvironmentVariables) this.context.getVariables().getParent(), this.context); + String variablePrefix = "EXTRA_" + sdk.toUpperCase(Locale.ROOT); + environmentVariables.setValue(variablePrefix + "_NAME", name); + environmentVariables.setValue(variablePrefix + "_HOME", extraToolHome.toString().replace('\\', '/')); + environmentVariables.setValue(variablePrefix + "_VERSION", installation.version().toString()); + if (installation.edition() != null) { + environmentVariables.setValue(variablePrefix + "_EDITION", installation.edition()); + } + + XmlMerger xmlMerger = new XmlMerger(this.context); + XmlMergeDocument workspaceDocument = xmlMerger.load(workspaceFile); + XmlMergeDocument templateDocument = xmlMerger.loadAndResolve(templateFile, environmentVariables); + Document mergedDocument = xmlMerger.merge(templateDocument, workspaceDocument, false); + xmlMerger.save(mergedDocument, workspaceFile); + } } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java index f80d00a4f3..17a8f3e670 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/ide/IdeaBasedIdeToolCommandlet.java @@ -84,6 +84,7 @@ protected String getIdeProductPrefix() { public ProcessResult runTool(ProcessContext pc, ProcessMode processMode, List args) { if (!args.contains("installPlugins")) { args.add(this.context.getWorkspacePath().toString()); + configureWorkspace(); } String variableName = getName().toUpperCase(Locale.ROOT).replace("-", "_") + VM_ARGS_ENV_SUFFIX; diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/intellij/Intellij.java b/cli/src/main/java/com/devonfw/tools/ide/tool/intellij/Intellij.java index f66ad3aa63..0e9823c485 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/intellij/Intellij.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/intellij/Intellij.java @@ -61,6 +61,7 @@ public class Intellij extends IdeaBasedIdeToolCommandlet { public Intellij(IdeContext context) { super(context, "intellij", Set.of(Tag.INTELLIJ)); + registerExtraSdkTemplate("java", Path.of(".intellij/config/options/jdk.table.xml")); } @Override @@ -97,7 +98,7 @@ protected ToolEditionAndVersion adjustRequestedEdition(ToolEditionAndVersion req ToolEdition edition = requested.getEdition(); // Check if edition is set as "ultimate" if ("ultimate".equals(edition.edition())) { - + VersionIdentifier version; if (requested.getVersion() != null) { version = VersionIdentifier.of(requested.getVersion().toString()); @@ -105,15 +106,18 @@ protected ToolEditionAndVersion adjustRequestedEdition(ToolEditionAndVersion req version = getConfiguredVersion(); } // Check whether set version warrants switching editions - if ((version.isGreater(INTELLIJ_LAST_SEPARATE_VERSION)) || // Specified version is > 2025.2.6.1 **OR** no specified version but configured version is > 2025.2.6.1 - (VersionIdentifier.LATEST.equals(version)) || // No version specified and no configured version - (VersionIdentifier.LATEST_UNSTABLE.equals(version))) { // No version specified and no configured version + if ((version.isGreater(INTELLIJ_LAST_SEPARATE_VERSION)) || + // Specified version is > 2025.2.6.1 **OR** no specified version but configured version is > 2025.2.6.1 + (VersionIdentifier.LATEST.equals(version)) || // No version specified and no configured version + (VersionIdentifier.LATEST_UNSTABLE.equals(version))) { // No version specified and no configured version // Switching to IntelliJ Standard edition LOG.warn(""" - Notice: You have configured IDEasy to use the IntelliJ Ultimate Edition. Since version 2025.3, the Ultimate and Community editions of IntelliJ have been unified into a single edition. - Since you are attempting to install a version of IntelliJ that is 2025.3 or newer, we are automatically switching your edition to the unified edition to ensure compatibility. - To specifically install the last true ultimate version of IntelliJ, please run "ide install intellij 2025.2.6.1". - Otherwise, we recommend permanently switching to the unified edition by running "ide set-edition intellij intellij"."""); + Notice: You have configured IDEasy to use the IntelliJ Ultimate Edition. + Since version 2025.3, the Ultimate and Community editions of IntelliJ have been unified into a single edition. + Since you are attempting to install a version of IntelliJ that is 2025.3 or newer, + we are automatically switching your edition to the unified edition to ensure compatibility. + To specifically install the last true ultimate version of IntelliJ, please run "ide install intellij 2025.2.6.1". + Otherwise, we recommend permanently switching to the unified edition by running "ide set-edition intellij intellij"."""); edition = new ToolEdition(this.tool, "intellij"); requested.replaceEdition(edition); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java b/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java index 83809e1a2b..3fbb48c61b 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java +++ b/cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java @@ -163,6 +163,6 @@ private static Path getMavenRepositoryPath(IdeContext context) { if (mvnConf == null) { return null; } - return mvnConf.resolve("repository"); + return mvnConf.resolve(IdeContext.FOLDER_REPOSITORY); } } diff --git a/cli/src/main/resources/META-INF/native-image/com.devonfw.tools.IDEasy/ide-cli/reflect-config.json b/cli/src/main/resources/META-INF/native-image/com.devonfw.tools.IDEasy/ide-cli/reflect-config.json index 5eb3b81a7d..cf0d9a2454 100644 --- a/cli/src/main/resources/META-INF/native-image/com.devonfw.tools.IDEasy/ide-cli/reflect-config.json +++ b/cli/src/main/resources/META-INF/native-image/com.devonfw.tools.IDEasy/ide-cli/reflect-config.json @@ -58,5 +58,19 @@ "allPublicConstructors": true, "allDeclaredFields": false, "allDeclaredMethods": false + }, + { + "name": "com.devonfw.tools.ide.tool.ide.IdeToolCommandlet", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredFields": true, + "allDeclaredMethods": true + }, + { + "name": "com.devonfw.tools.ide.tool.intellij.Intellij", + "allDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredFields": true, + "allDeclaredMethods": true } ] diff --git a/cli/src/test/java/com/devonfw/tools/ide/cli/CliAdvancedParsingTest.java b/cli/src/test/java/com/devonfw/tools/ide/cli/CliAdvancedParsingTest.java index 8f2966a717..3b915a75ce 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/cli/CliAdvancedParsingTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/cli/CliAdvancedParsingTest.java @@ -3,6 +3,7 @@ import org.junit.jupiter.api.Test; import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.context.IdeTestContext; /** @@ -38,7 +39,7 @@ void testRunRepositorySetupWithoutArgumentWillSucceed() { // arrange IdeTestContext context = newContext(PROJECT_MVN); - CliArguments args = new CliArguments("repository", "setup"); + CliArguments args = new CliArguments(IdeContext.FOLDER_REPOSITORY, "setup"); args.next(); // act int success = context.run(args); diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/RepositoryCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/RepositoryCommandletTest.java index 47826ef63e..310c73040b 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/RepositoryCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/RepositoryCommandletTest.java @@ -18,8 +18,6 @@ */ class RepositoryCommandletTest extends AbstractIdeContextTest { - private static final String PROJECT_REPOSITORY = "repository"; - private static final String PROPERTIES_FILE = "test.properties"; private static final String TEST_WORKSPACE = "test-workspace"; private static final String TEST_BRANCH = "test-branch"; @@ -62,7 +60,7 @@ private void saveProperties(IdeTestContext context, Properties properties, Strin void testSetupSpecificRepository() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); saveProperties(context, properties); @@ -78,7 +76,7 @@ void testSetupSpecificRepository() { void testSetupAllRepositoriesInactive() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); saveProperties(context, properties); @@ -92,7 +90,7 @@ void testSetupAllRepositoriesInactive() { void testSetupSpecificRepositoryWithoutPath() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); properties.setProperty("path", ""); RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); @@ -108,7 +106,7 @@ void testSetupSpecificRepositoryWithoutPath() { void testSetupSpecificRepositoryFailsWithoutGitUrl() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); properties.setProperty("git_url", ""); Path repositoryTestProperties = context.getSettingsPath().resolve(IdeContext.FOLDER_REPOSITORIES).resolve(PROPERTIES_FILE); @@ -127,7 +125,7 @@ void testSetupSpecificRepositoryFailsWithoutGitUrl() { void testRunNoRepositoriesOrProjectsFolderFound() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); Path repositoriesPath = context.getSettingsPath().resolve(IdeContext.FOLDER_REPOSITORIES); context.getFileAccess().delete(repositoriesPath); @@ -141,7 +139,7 @@ void testRunNoRepositoriesOrProjectsFolderFound() { void testSetupSpecificRepositoryWithForceOption() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); context.getStartContext().setForceRepositories(true); RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); @@ -162,7 +160,7 @@ void testSetupSpecificRepositoryWithForceOption() { void testSetupRepositoryWithMultipleWorkspaces() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); String workspace1 = "workspace1"; String workspace2 = "workspace2"; @@ -185,7 +183,7 @@ void testSetupRepositoryWithAllWorkspacesAndLinks() { // arrange String expectedSkillContent = "# dummy for testing link feature with AI use-case\n"; - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); context.setGitContext(new GitContextImplMock(context, context.getIdeHome().getParent().resolve("repository/ai-repo"))); Properties properties = createDefaultProperties(); String workspace1 = "workspace1"; @@ -221,7 +219,7 @@ void testSetupVirtualSettingsRepositoryWithoutGitUrlWithLinks() { // arrange String expectedSkillContent = "# dummy for testing virtual settings repository link feature\n"; - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); FileAccess fileAccess = context.getFileAccess(); Path settingsAiPath = context.getSettingsPath().resolve("ai"); fileAccess.mkdirs(settingsAiPath); @@ -246,7 +244,7 @@ void testSetupVirtualSettingsRepositoryWithoutGitUrlWithLinks() { void testSetupRepositoryWithMultipleWorkspacesWithSpaces() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); String workspace1 = "workspace1"; String workspace2 = "workspace2"; @@ -270,7 +268,7 @@ void testSetupRepositoryWithMultipleWorkspacesWithSpaces() { void testSetupRepositoryWithEmptyWorkspaceDefaultsToMain() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); properties.setProperty("workspace", ""); RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); @@ -289,7 +287,7 @@ void testSetupRepositoryWithEmptyWorkspaceDefaultsToMain() { void testSetupRepositoryWithoutActiveProperty() { // arrange - IdeTestContext context = newContext(PROJECT_REPOSITORY); + IdeTestContext context = newContext(IdeContext.FOLDER_REPOSITORY); Properties properties = createDefaultProperties(); properties.remove("active"); // Remove the active property to test default behavior RepositoryCommandlet rc = context.getCommandletManager().getCommandlet(RepositoryCommandlet.class); diff --git a/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java index 35232bb59a..626d0b0aa4 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/commandlet/UpdateCommandletTest.java @@ -118,7 +118,7 @@ void testRunUpdateSoftwareDoesNotFailOnFailedSoftwareInstallations() { IdeTestContext context = newContext(PROJECT_UPDATE); Path javaRepository = context.getToolRepositoryPath().resolve("default").resolve("java"); context.getFileAccess().delete(javaRepository); - Path javaDownload = context.getIdeRoot().resolve("repository").resolve("java"); + Path javaDownload = context.getIdeRoot().resolve(IdeContext.FOLDER_REPOSITORY).resolve("java"); context.getFileAccess().delete(javaDownload); UpdateCommandlet update = context.getCommandletManager().getCommandlet(UpdateCommandlet.class); diff --git a/cli/src/test/java/com/devonfw/tools/ide/context/AbstractIdeContextTest.java b/cli/src/test/java/com/devonfw/tools/ide/context/AbstractIdeContextTest.java index dcb5b626d7..dede9b9b53 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/context/AbstractIdeContextTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/context/AbstractIdeContextTest.java @@ -132,7 +132,7 @@ protected static IdeTestContext newContext(String testProject, String projectPat ToolRepositoryMock toolRepository = null; IdeTestContext context = new IdeTestContext(userDir, logLevel, wmRuntimeInfo); - Path repositoryFolder = ideRoot.resolve("repository"); + Path repositoryFolder = ideRoot.resolve(IdeContext.FOLDER_REPOSITORY); if (Files.isDirectory(repositoryFolder)) { toolRepository = new ToolRepositoryMock(context, repositoryFolder, wmRuntimeInfo); context.setDefaultToolRepository(toolRepository); diff --git a/cli/src/test/java/com/devonfw/tools/ide/context/MvnRepositoryMock.java b/cli/src/test/java/com/devonfw/tools/ide/context/MvnRepositoryMock.java index 071f69b0aa..09c00c8e91 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/context/MvnRepositoryMock.java +++ b/cli/src/test/java/com/devonfw/tools/ide/context/MvnRepositoryMock.java @@ -33,8 +33,7 @@ public class MvnRepositoryMock extends MvnRepository { private final WireMockRuntimeInfo wmRuntimeInfo; /** - * Maps artifact download path to its pre-computed SHA-256 checksum. - * Populated when the mock archive is compressed, queried during verification. + * Maps artifact download path to its pre-computed SHA-256 checksum. Populated when the mock archive is compressed, queried during verification. */ private final Map checksumByPath = new HashMap<>(); @@ -66,7 +65,8 @@ public Path download(MvnArtifactMetadata metadata) { String path = artifact.getDownloadUrl(); path = path.replace(MvnRepositoryMock.MAVEN_CENTRAL, ""); String url = this.wmRuntimeInfo.getHttpBaseUrl() + path; - Path archiveFolder = this.context.getIdeRoot().resolve("repository").resolve("mvn").resolve(artifact.getGroupId() + "/" + artifact.getArtifactId()); + Path archiveFolder = this.context.getIdeRoot().resolve(IdeContext.FOLDER_REPOSITORY).resolve("mvn") + .resolve(artifact.getGroupId() + "/" + artifact.getArtifactId()); try (ByteArrayOutputStream baos = new ByteArrayOutputStream(1024)) { this.context.getFileAccess().compress(archiveFolder, baos, artifact.getFilename()); byte[] body = baos.toByteArray(); @@ -107,8 +107,15 @@ private record SingleChecksumWrapper(String sha256) implements UrlChecksums { @Override public Iterator iterator() { UrlGenericChecksum entry = new UrlGenericChecksum() { - @Override public String getChecksum() { return sha256; } - @Override public String getHashAlgorithm() { return "SHA-256"; } + @Override + public String getChecksum() { + return sha256; + } + + @Override + public String getHashAlgorithm() { + return "SHA-256"; + } }; return Collections.singletonList(entry).iterator(); } @@ -128,7 +135,7 @@ private void mockMvnMetadataResponses(WireMockRuntimeInfo wireMockRuntimeInfo) { if (parent == null) { return; } - Path mvnRoot = parent.resolve("repository").resolve("mvn"); + Path mvnRoot = parent.resolve(IdeContext.FOLDER_REPOSITORY).resolve("mvn"); if (!Files.exists(mvnRoot)) { return; } diff --git a/cli/src/test/java/com/devonfw/tools/ide/context/NpmRepositoryMock.java b/cli/src/test/java/com/devonfw/tools/ide/context/NpmRepositoryMock.java index 8f2b485207..190c031069 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/context/NpmRepositoryMock.java +++ b/cli/src/test/java/com/devonfw/tools/ide/context/NpmRepositoryMock.java @@ -48,7 +48,7 @@ public String getRegistryUrl() { private void mockNpmPackageResponses(WireMockRuntimeInfo wireMockRuntimeInfo) { Path npmRoot = this.context.getIdeHome() .getParent() - .resolve("repository") + .resolve(IdeContext.FOLDER_REPOSITORY) .resolve("npmjs"); if (Files.isDirectory(npmRoot)) { diff --git a/cli/src/test/java/com/devonfw/tools/ide/context/PipRepositoryMock.java b/cli/src/test/java/com/devonfw/tools/ide/context/PipRepositoryMock.java index 6497f99b3b..9f0d5f90ef 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/context/PipRepositoryMock.java +++ b/cli/src/test/java/com/devonfw/tools/ide/context/PipRepositoryMock.java @@ -48,7 +48,7 @@ public String getRegistryUrl() { private void mockPypiPackageResponses(WireMockRuntimeInfo wireMockRuntimeInfo) { Path pypiRoot = this.context.getIdeHome() .getParent() - .resolve("repository") + .resolve(IdeContext.FOLDER_REPOSITORY) .resolve("pypi"); if (!Files.isDirectory(pypiRoot)) { diff --git a/cli/src/test/java/com/devonfw/tools/ide/context/UvRepositoryMock.java b/cli/src/test/java/com/devonfw/tools/ide/context/UvRepositoryMock.java index 95245a340c..0c7ce5257b 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/context/UvRepositoryMock.java +++ b/cli/src/test/java/com/devonfw/tools/ide/context/UvRepositoryMock.java @@ -5,7 +5,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -44,7 +43,7 @@ protected String getRegistryUrl() { * @param wireMockRuntimeInfo the {@link WireMockRuntimeInfo} providing the base URL. */ private void mockPypiPackageResponses(WireMockRuntimeInfo wireMockRuntimeInfo) { - Path pypiRoot = this.context.getIdeHome().getParent().resolve("repository").resolve("pypi"); + Path pypiRoot = this.context.getIdeHome().getParent().resolve(IdeContext.FOLDER_REPOSITORY).resolve("pypi"); if (!Files.isDirectory(pypiRoot)) { return; } @@ -52,7 +51,7 @@ private void mockPypiPackageResponses(WireMockRuntimeInfo wireMockRuntimeInfo) { files.filter(p -> Files.isRegularFile(p) && p.getFileName().toString().endsWith(".json")) .forEach(jsonFile -> { Path rel = pypiRoot.relativize(jsonFile); - String packageName = rel.toString().replace(File.separatorChar, '/').replaceAll("\\.json$", ""); + String packageName = rel.toString().replace('\\', '/').replaceAll("\\.json$", ""); String packagePath = "/" + packageName + "/json"; String body = IdeTestContext.readAndResolveBaseUrl(jsonFile, wireMockRuntimeInfo); stubFor(get(urlPathEqualTo(packagePath)) diff --git a/cli/src/test/java/com/devonfw/tools/ide/environment/EnvironmentVariablesTest.java b/cli/src/test/java/com/devonfw/tools/ide/environment/EnvironmentVariablesTest.java index 98619cb78f..2542b7a0fb 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/environment/EnvironmentVariablesTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/environment/EnvironmentVariablesTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.context.IdeTestContext; import com.devonfw.tools.ide.tool.mvn.Mvn; import com.devonfw.tools.ide.variable.IdeVariables; @@ -98,7 +99,7 @@ void testSpecificEnvironmentVariablesNotInheritedFromOtherProject() { assertThat(mavenArgs).isEqualTo("-s " + context.getConfPath().resolve(Mvn.MVN_CONFIG_FOLDER).resolve(Mvn.SETTINGS_FILE)); assertThat(javaHome).isNotEqualTo("/usr/share/java"); assertThat(npmVersion).isNull(); - assertThat(m2Repo).isEqualTo(context.getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER).resolve("repository")); + assertThat(m2Repo).isEqualTo(context.getUserHome().resolve(Mvn.MVN_CONFIG_LEGACY_FOLDER).resolve(IdeContext.FOLDER_REPOSITORY)); assertThat(otherVariable).isEqualTo("other value"); } @@ -131,8 +132,8 @@ void testUserDefinedMavenArgsIsMergedWithIdeasyDefaults() { } /** - * Test that IDEasy's {@code -s} and {@code -Dsettings.security=} arguments override any user-provided ones - * and that unrelated user arguments are correctly appended. + * Test that IDEasy's {@code -s} and {@code -Dsettings.security=} arguments override any user-provided ones and that unrelated user arguments are correctly + * appended. */ @Test void testMergeMavenArgsWithDefault() { diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java index 36c0b8ba39..0070b665ac 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/androidstudio/AndroidStudioTest.java @@ -14,6 +14,7 @@ import org.junit.jupiter.params.provider.ValueSource; import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.context.IdeTestContext; import com.devonfw.tools.ide.log.IdeLogEntry; import com.devonfw.tools.ide.log.IdeLogLevel; @@ -125,7 +126,7 @@ private void setupMockedPlugin(WireMockRuntimeInfo wmRuntimeInfo) throws IOExcep Files.writeString(this.context.getSettingsPath().resolve("android-studio").resolve("plugins").resolve("MockedPlugin.properties"), content); - Path mockedPlugin = this.context.getIdeRoot().resolve("repository").resolve(MOCKED_PLUGIN_JAR); + Path mockedPlugin = this.context.getIdeRoot().resolve(IdeContext.FOLDER_REPOSITORY).resolve(MOCKED_PLUGIN_JAR); byte[] contentBytes = Files.readAllBytes(mockedPlugin); int contentLength = contentBytes.length; diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/ide/IdeToolDummyCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/ide/IdeToolDummyCommandletTest.java index 5e957cf443..9fceae9930 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/ide/IdeToolDummyCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/ide/IdeToolDummyCommandletTest.java @@ -69,7 +69,7 @@ public static class IdeToolDummyCommandlet extends IdeToolCommandlet { } @Override - protected void configureWorkspace() { + public void configureWorkspace() { // disable workspace configuration since we have no IDE_HOME and therefore no settings } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java index 6bb4b2b706..c60accbf0a 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/intellij/IntellijTest.java @@ -1,5 +1,8 @@ package com.devonfw.tools.ide.tool.intellij; +import java.nio.file.Files; +import java.nio.file.Path; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -280,16 +283,144 @@ void testIntellijRunWithCustomJvmOptions(String os) { """); } + /** + * Tests that extra Java SDK installations configured via ide-extra-tools.json are imported into IntelliJ jdk.table.xml when IntelliJ is started through + * IDEasy. + */ + @Test + void testImportExtraJavaSdksIntoJdkTable() throws Exception { + + // arrange + IdeTestContext context = newContext("intellij"); + Intellij commandlet = context.getCommandletManager().getCommandlet(Intellij.class); + + Path extraJavaRoot = context.getSoftwareExtraPath().resolve("java"); + context.getFileAccess().mkdirs(extraJavaRoot.resolve("client")); + context.getFileAccess().mkdirs(extraJavaRoot.resolve("process-engine")); + + // act + commandlet.run(); + + // assert + Path jdkTable = context.getWorkspacePath() + .resolve(".intellij") + .resolve("config") + .resolve("options") + .resolve("jdk.table.xml"); + assertThat(jdkTable).exists(); + + String jdkTableContent = Files.readString(jdkTable); + assertThat(jdkTableContent).contains(""); + assertThat(jdkTableContent).contains(""); + assertThat(jdkTableContent).contains("software/extra/java/client"); + assertThat(jdkTableContent).contains("software/extra/java/process-engine"); + } + + /** + * Tests that an extra Java SDK using the reserved name "java" is skipped instead of being imported. + */ + @Test + void testSkipExtraJavaSdkWithReservedName() throws Exception { + + // arrange + IdeTestContext context = newContext("intellij"); + Path extraToolsFile = context.getSettingsPath().resolve("ide-extra-tools.json"); + context.getFileAccess().writeFileContent(""" + { + "java": { + "java": { + "version": "21" + } + } + } + """, + extraToolsFile); + + Intellij commandlet = context.getCommandletManager().getCommandlet(Intellij.class); + + Path extraJavaRoot = context.getSoftwareExtraPath().resolve("java"); + context.getFileAccess().mkdirs(extraJavaRoot.resolve("java")); + + // act + commandlet.run(); + + // assert + Path jdkTable = context.getWorkspacePath() + .resolve(".intellij") + .resolve("config") + .resolve("options") + .resolve("jdk.table.xml"); + assertThat(jdkTable).exists(); + + String jdkTableContent = Files.readString(jdkTable); + assertThat(jdkTableContent).doesNotContain("software/extra/java/java"); + assertThat(context).logAtWarning().hasNoMessageContaining("software/extra/java/java"); + } + + /** + * Tests that a configured extra Java SDK is skipped if the corresponding installation directory does not exist. + */ + @Test + void testSkipMissingExtraJavaSdkDirectory() throws Exception { + + // arrange + IdeTestContext context = newContext("intellij"); + Intellij commandlet = context.getCommandletManager().getCommandlet(Intellij.class); + + // do not create client/process-engine directories on purpose + + // act + commandlet.run(); + + // assert + Path jdkTable = context.getWorkspacePath() + .resolve(".intellij") + .resolve("config") + .resolve("options") + .resolve("jdk.table.xml"); + assertThat(jdkTable).exists(); + + String jdkTableContent = Files.readString(jdkTable); + assertThat(jdkTableContent).doesNotContain("software/extra/java/client"); + assertThat(jdkTableContent).doesNotContain("software/extra/java/process-engine"); + assertThat(context).logAtWarning() + .hasMessageContaining("Skipping extra tool installation import to intellij because it is missing at"); + } + + /** Tests that IntelliJ extra Java SDK import writes jdk.table.xml in the workspace options folder. */ + @Test + void testMissingExtraJavaTemplateFails() throws Exception { + + // arrange + IdeTestContext context = newContext("intellij"); + Intellij commandlet = context.getCommandletManager().getCommandlet(Intellij.class); + + Path extraJavaRoot = context.getSoftwareExtraPath().resolve("java"); + context.getFileAccess().mkdirs(extraJavaRoot.resolve("client")); + + // act + commandlet.run(); + + // assert + Path jdkTable = context.getWorkspacePath() + .resolve(".intellij") + .resolve("config") + .resolve("options") + .resolve("jdk.table.xml"); + assertThat(jdkTable).exists(); + + String jdkTableContent = Files.readString(jdkTable); + assertThat(jdkTableContent).contains("software/extra/java/client"); + } + private void checkInstallation(IdeTestContext context) { Intellij commandlet = context.getCommandletManager().getCommandlet(Intellij.class); assertThat(commandlet.getInstalledVersion().toString()).isEqualTo("2023.3.3"); - assertThat(context.getWorkspacePath().resolve("idea.properties")).exists(); assertThat(context).log().hasEntries( new IdeLogEntry(IdeLogLevel.SUCCESS, "Successfully installed java in version 17.0.10_7", true), new IdeLogEntry(IdeLogLevel.SUCCESS, "Successfully installed intellij in version 2023.3.3", true)); assertThat(context).logAtDebug().hasMessage("Omitting installation of inactive plugin InactivePlugin (inactivePlugin)."); assertThat(context).logAtSuccess().hasMessage("Successfully ended step 'Install plugin ActivePlugin (1/1)'."); } - } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/java/JavaTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/java/JavaTest.java index 3e01cd3693..f0dc50f332 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/java/JavaTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/java/JavaTest.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test; import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.context.IdeTestContext; import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; import com.github.tomakehurst.wiremock.junit5.WireMockTest; @@ -47,7 +48,7 @@ void testJavaInstallAndRun(WireMockRuntimeInfo wmRuntimeInfo) { private static void createFakedSrcJar(IdeTestContext context) { // create large dummy src.zip file to reproduce bug #1437 condition - Path fakedJavaLibDir = context.getIdeRoot().resolve("repository").resolve("java").resolve("java").resolve("default").resolve("lib"); + Path fakedJavaLibDir = context.getIdeRoot().resolve(IdeContext.FOLDER_REPOSITORY).resolve("java").resolve("java").resolve("default").resolve("lib"); context.getFileAccess().mkdirs(fakedJavaLibDir); Path srcZip = fakedJavaLibDir.resolve("src.zip"); Random random = new Random(1); diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/mvn/MvnTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/mvn/MvnTest.java index 7cf8e2d121..df94455172 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/mvn/MvnTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/mvn/MvnTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test; import com.devonfw.tools.ide.context.AbstractIdeContextTest; +import com.devonfw.tools.ide.context.IdeContext; import com.devonfw.tools.ide.context.IdeTestContext; import com.devonfw.tools.ide.io.FileAccess; import com.devonfw.tools.ide.variable.IdeVariables; @@ -107,7 +108,7 @@ private void checkInstallation(IdeTestContext context) throws IOException { Path settingsFile = context.getConfPath().resolve(Mvn.MVN_CONFIG_FOLDER).resolve(Mvn.SETTINGS_FILE); assertThat(settingsFile).exists(); - assertFileContent(settingsFile, List.of("${env.M2_REPO}", "repository", "testLogin", "testPassword")); + assertFileContent(settingsFile, List.of("${env.M2_REPO}", IdeContext.FOLDER_REPOSITORY, "testLogin", "testPassword")); Path settingsSecurityFile = context.getConfPath().resolve(Mvn.MVN_CONFIG_FOLDER).resolve(Mvn.SETTINGS_SECURITY_FILE); assertThat(settingsSecurityFile).exists(); @@ -125,7 +126,7 @@ void testMavenRepositoryPathFallsBackToUserHome() { String path = "project/workspaces"; // act IdeTestContext context = newContext(PROJECT_MVN, path, false); - Path mavenRepository = context.getUserHome().resolve(".m2").resolve("repository"); + Path mavenRepository = context.getUserHome().resolve(".m2").resolve(IdeContext.FOLDER_REPOSITORY); // assert assertThat(IdeVariables.M2_REPO.get(context)).isEqualTo(mavenRepository); } diff --git a/cli/src/test/resources/ide-projects/intellij/project/settings/ide-extra-tools.json b/cli/src/test/resources/ide-projects/intellij/project/settings/ide-extra-tools.json new file mode 100644 index 0000000000..e832adb715 --- /dev/null +++ b/cli/src/test/resources/ide-projects/intellij/project/settings/ide-extra-tools.json @@ -0,0 +1,16 @@ +{ + "java": { + "client": { + "version": "11.0.27_6", + "edition": "azul" + }, + "process-engine": { + "version": "21.*" + } + }, + "mvn": { + "m4": { + "version": "4.0.0-rc-5" + } + } +} diff --git a/cli/src/test/resources/ide-projects/intellij/project/settings/intellij/workspace/repository/.intellij/config/options/jdk.table.xml b/cli/src/test/resources/ide-projects/intellij/project/settings/intellij/workspace/repository/.intellij/config/options/jdk.table.xml new file mode 100644 index 0000000000..08edcfc49e --- /dev/null +++ b/cli/src/test/resources/ide-projects/intellij/project/settings/intellij/workspace/repository/.intellij/config/options/jdk.table.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cli/src/test/resources/ide-projects/intellij/project/workspaces/main/.intellij/config/options/jdk.table.xml b/cli/src/test/resources/ide-projects/intellij/project/workspaces/main/.intellij/config/options/jdk.table.xml new file mode 100644 index 0000000000..05b39dcf09 --- /dev/null +++ b/cli/src/test/resources/ide-projects/intellij/project/workspaces/main/.intellij/config/options/jdk.table.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file