Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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/1165[#1165]: Fix automatic project import for Eclipse
* https://github.com/devonfw/IDEasy/issues/2040[#2040]: Fixed buggy workspace selection in the GUI

The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/49?closed=1[milestone 2026.08.002].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ public void importRepository(Path repositoryPath) {
maven.getOrDownloadArtifact(groovyAnt);
this.groovyInstalled = true;
}
// -DdevonImportPath=\"${import_path}\" -DdevonImportWorkingSet=\"${importWorkingSets}\""
runTool(ProcessMode.DEFAULT, null, ProcessErrorHandling.THROW_CLI, List.of(VMARGS,
"-DrepositoryImportPath=\"" + repositoryPath + "\" -DrepositoryImportWorkingSet=\"" + "" + "\"", "-application", "org.eclipse.ant.core.antRunner",
"-buildfile", this.context.getIdeInstallationPath().resolve(IdeContext.FOLDER_INTERNAL).resolve("eclipse-import.xml").toString()));
Path buildFile = this.context.getIdeInstallationPath().resolve(IdeContext.FOLDER_INTERNAL).resolve("eclipse-import.xml");
// "-application" and "-buildfile" must come before "-vmargs" (added by super.configureToolArgs if ECLIPSE_VMARGS is set),
// as "-vmargs" and everything after it is passed to the JVM instead of being processed by eclipse itself.
runTool(ProcessMode.DEFAULT, null, ProcessErrorHandling.THROW_CLI,
List.of("-application", "org.eclipse.ant.core.antRunner", "-buildfile", buildFile.toString(), "-DrepositoryImportPath=" + repositoryPath,
"-DrepositoryImportWorkingSet="));
Comment thread
Ali-Shariati-Najafabadi marked this conversation as resolved.
}
}
2 changes: 1 addition & 1 deletion cli/src/main/package/internal/eclipse-import.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class MyWorkbenchAdvisor extends org.eclipse.ui.application.WorkbenchAdvisor {
public void preStartup() {
try {
// Get path from ant properties
String path = antProperties.get("devonImportPath");
String path = antProperties.get("repositoryImportPath");
if (path == null || path.equals("")) {
throw new IllegalStateException("Parameter repositoryImportPath must be set.");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.devonfw.tools.ide.tool.eclipse;

import java.io.IOException;
import java.lang.reflect.Field;
import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
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;
Expand Down Expand Up @@ -56,4 +60,35 @@ void testEclipse(String os) throws IOException {
assertThat(context).logAtDebug().hasMessageContaining("Version 2024-09 of tool eclipse is already installed");
}

/**
* Tests that {@link Eclipse#importRepository(Path)} invokes eclipse headlessly with the ant runner application and does not misplace "-application" behind
* "-vmargs" (see https://github.com/devonfw/IDEasy/issues/1165).
*/
@Test
void testImportRepository() throws Exception {

// arrange
IdeTestContext context = newContext(PROJECT_ECLIPSE, "eclipseproject");
context.setSystemInfo(SystemInfoMock.of("linux"));
context.getStartContext().setForceMode(true); // #663
Eclipse eclipse = context.getCommandletManager().getCommandlet(Eclipse.class);
eclipse.install();
// avoid downloading groovy-ant via maven in this test as it is not the concern of this test
Field groovyInstalledField = Eclipse.class.getDeclaredField("groovyInstalled");
groovyInstalledField.setAccessible(true);
groovyInstalledField.set(eclipse, true);
Path repositoryPath = context.getWorkspacePath().resolve("my-repo");

// act
eclipse.importRepository(repositoryPath);

// assert
Path buildFile = context.getIdeInstallationPath().resolve(IdeContext.FOLDER_INTERNAL).resolve("eclipse-import.xml");
assertThat(eclipse.getToolBinPath().resolve("eclipsetest")).hasContent(
"eclipse linux -data " + context.getWorkspacePath() + " -keyring " + context.getUserHome().resolve(".eclipse").resolve(".keyring")
+ " -configuration " + context.getPluginsPath().resolve("eclipse").resolve("configuration")
+ " -consoleLog -nosplash -application org.eclipse.ant.core.antRunner -buildfile " + buildFile + " -DrepositoryImportPath=" + repositoryPath
+ " -DrepositoryImportWorkingSet=");
}

}