• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 22300285724

23 Feb 2026 09:32AM UTC coverage: 70.754% (+0.3%) from 70.474%
22300285724

Pull #1714

github

web-flow
Merge caa980897 into 379acdc9d
Pull Request #1714: #404: #1713: advanced logging

4064 of 6348 branches covered (64.02%)

Branch coverage included in aggregate %.

10640 of 14434 relevant lines covered (73.71%)

3.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.29
cli/src/main/java/com/devonfw/tools/ide/tool/eclipse/Eclipse.java
1
package com.devonfw.tools.ide.tool.eclipse;
2

3
import java.io.File;
4
import java.io.RandomAccessFile;
5
import java.nio.channels.FileLock;
6
import java.nio.file.Files;
7
import java.nio.file.Path;
8
import java.util.List;
9
import java.util.Set;
10

11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13

14
import com.devonfw.tools.ide.cli.CliException;
15
import com.devonfw.tools.ide.common.Tag;
16
import com.devonfw.tools.ide.context.IdeContext;
17
import com.devonfw.tools.ide.log.IdeLogLevel;
18
import com.devonfw.tools.ide.process.ProcessContext;
19
import com.devonfw.tools.ide.process.ProcessErrorHandling;
20
import com.devonfw.tools.ide.process.ProcessMode;
21
import com.devonfw.tools.ide.process.ProcessResult;
22
import com.devonfw.tools.ide.step.Step;
23
import com.devonfw.tools.ide.tool.ide.IdeToolCommandlet;
24
import com.devonfw.tools.ide.tool.mvn.Mvn;
25
import com.devonfw.tools.ide.tool.mvn.MvnArtifact;
26
import com.devonfw.tools.ide.tool.plugin.ToolPluginDescriptor;
27

28
/**
29
 * {@link IdeToolCommandlet} for <a href="https://www.eclipse.org/">Eclipse</a>.
30
 */
31
public class Eclipse extends IdeToolCommandlet {
32

33
  private static final Logger LOG = LoggerFactory.getLogger(Eclipse.class);
4✔
34

35
  // version must correspond to eclipse-import.xml
36
  private static final String GROOVY_VERSION = "3.0.23";
37

38
  /** Eclipse CLI option for Java virtual machine arguments. */
39
  public static final String VMARGS = "-vmargs";
40

41
  private boolean groovyInstalled;
42

43
  /**
44
   * The constructor.
45
   *
46
   * @param context the {@link IdeContext}.
47
   */
48
  public Eclipse(IdeContext context) {
49

50
    super(context, "eclipse", Set.of(Tag.ECLIPSE));
6✔
51
  }
1✔
52

53
  @Override
54
  protected void configureToolBinary(ProcessContext pc, ProcessMode processMode) {
55

56
    if (!processMode.isBackground() && this.context.getSystemInfo().isWindows()) {
8✔
57
      pc.executable(Path.of("eclipsec"));
8✔
58
    } else {
59
      super.configureToolBinary(pc, processMode);
4✔
60
    }
61
  }
1✔
62

63
  @Override
64
  protected void configureToolArgs(ProcessContext pc, ProcessMode processMode, List<String> args) {
65

66
    // configure workspace location
67
    pc.addArg("-data").addArg(this.context.getWorkspacePath());
8✔
68
    // use keyring from user home to keep secrets and share across projects and workspaces
69
    pc.addArg("-keyring").addArg(this.context.getUserHome().resolve(".eclipse").resolve(".keyring"));
12✔
70
    // use isolated plugins folder from project instead of modifying eclipse installation in software repo on plugin installation
71
    pc.addArg("-configuration").addArg(getPluginsInstallationPath().resolve("configuration"));
9✔
72
    if (processMode == ProcessMode.BACKGROUND) {
3✔
73
      // to start eclipse as GUI
74
      pc.addArg("gui").addArg("-showlocation").addArg(this.context.getIdeHome().getFileName());
12✔
75
    } else {
76
      pc.addArg("-consoleLog").addArg("-nosplash");
6✔
77
    }
78
    super.configureToolArgs(pc, processMode, args);
5✔
79
    if ((!args.isEmpty()) && !VMARGS.equals(args.getFirst())) {
8!
80
      String vmArgs = this.context.getVariables().get("ECLIPSE_VMARGS");
6✔
81
      if ((vmArgs != null) && !vmArgs.isEmpty()) {
2!
82
        pc.addArg(VMARGS).addArg(vmArgs);
×
83
      }
84
    }
85
  }
1✔
86

87
  @Override
88
  protected boolean isPluginUrlNeeded() {
89

90
    return true;
2✔
91
  }
92

93
  @Override
94
  public boolean installPlugin(ToolPluginDescriptor plugin, Step step, ProcessContext pc) {
95

96
    ProcessResult result = runTool(pc, ProcessMode.DEFAULT_CAPTURE, List.of("-application", "org.eclipse.equinox.p2.director",
10✔
97
        "-repository", plugin.url(), "-installIU", plugin.id()));
4✔
98
    if (result.isSuccessful()) {
3!
99
      for (String line : result.getOut()) {
11!
100
        if (line.contains("Overall install request is satisfiable")) {
4✔
101
          LOG.info(IdeLogLevel.SUCCESS.getSlf4jMarker(), "Successfully installed plugin: {}", plugin.name());
7✔
102
          step.success();
2✔
103
          return true;
2✔
104
        }
105
      }
1✔
106
    }
107
    result.log(IdeLogLevel.DEBUG, IdeLogLevel.ERROR);
×
108
    step.error("Failed to install plugin {} ({}): exit code was {}", plugin.name(), plugin.id(), result.getExitCode());
×
109
    return false;
×
110
  }
111

112
  @Override
113
  protected void configureWorkspace() {
114

115
    Path lockfile = this.context.getWorkspacePath().resolve(".metadata/.lock");
6✔
116
    if (isLocked(lockfile)) {
3!
117
      throw new CliException("Your workspace is locked at " + lockfile);
×
118
    }
119
    super.configureWorkspace();
2✔
120
  }
1✔
121

122
  /**
123
   * @param lockfile the {@link File} pointing to the lockfile to check.
124
   * @return {@code true} if the given {@link File} is locked, {@code false} otherwise.
125
   */
126
  private static boolean isLocked(Path lockfile) {
127

128
    if (Files.isRegularFile(lockfile)) {
5!
129
      try (RandomAccessFile raFile = new RandomAccessFile(lockfile.toFile(), "rw");
×
130
          FileLock fileLock = raFile.getChannel().tryLock(0, 1, false)) {
×
131
        // success, file was not locked so we immediately unlock again...
132
        fileLock.release();
×
133
        return false;
×
134
      } catch (Exception e) {
×
135
        return true;
×
136
      }
137
    }
138
    return false;
2✔
139
  }
140

141
  @Override
142
  public void importRepository(Path repositoryPath) {
143
    if (!this.groovyInstalled) {
×
144
      Mvn maven = this.context.getCommandletManager().getCommandlet(Mvn.class);
×
145
      MvnArtifact groovyAnt = new MvnArtifact("org.codehaus.groovy", "groovy-ant", GROOVY_VERSION);
×
146
      maven.getOrDownloadArtifact(groovyAnt);
×
147
      this.groovyInstalled = true;
×
148
    }
149
    // -DdevonImportPath=\"${import_path}\" -DdevonImportWorkingSet=\"${importWorkingSets}\""
150
    runTool(ProcessMode.DEFAULT, null, ProcessErrorHandling.THROW_CLI, List.of(VMARGS,
×
151
        "-DrepositoryImportPath=\"" + repositoryPath + "\" -DrepositoryImportWorkingSet=\"" + "" + "\"", "-application", "org.eclipse.ant.core.antRunner",
152
        "-buildfile", this.context.getIdeInstallationPath().resolve(IdeContext.FOLDER_INTERNAL).resolve("eclipse-import.xml").toString()));
×
153
  }
×
154
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc