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

devonfw / IDEasy / 25167683820

30 Apr 2026 01:19PM UTC coverage: 70.487% (-0.2%) from 70.671%
25167683820

Pull #1878

github

web-flow
Merge 154ff6c85 into 12d5f877f
Pull Request #1878: #1695: Clone settings to temporary directory, analyse, and then move

4366 of 6846 branches covered (63.77%)

Branch coverage included in aggregate %.

11275 of 15344 relevant lines covered (73.48%)

3.11 hits per line

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

92.68
cli/src/main/java/com/devonfw/tools/ide/commandlet/CreateCommandlet.java
1
package com.devonfw.tools.ide.commandlet;
2

3
import java.nio.file.Files;
4
import java.nio.file.Path;
5
import java.util.function.Predicate;
6

7
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
9

10
import com.devonfw.tools.ide.context.IdeContext;
11
import com.devonfw.tools.ide.io.FileAccess;
12
import com.devonfw.tools.ide.log.IdeLogLevel;
13
import com.devonfw.tools.ide.property.FlagProperty;
14
import com.devonfw.tools.ide.property.StringProperty;
15
import com.devonfw.tools.ide.version.IdeVersion;
16

17
/**
18
 * {@link Commandlet} to create a new IDEasy instance
19
 */
20
public class CreateCommandlet extends AbstractUpdateCommandlet {
21

22
  private static final Logger LOG = LoggerFactory.getLogger(CreateCommandlet.class);
4✔
23

24
  /** {@link StringProperty} for the name of the new project */
25
  public final StringProperty newProject;
26

27
  /**
28
   * The constructor.
29
   *
30
   * @param context the {@link IdeContext}.
31
   */
32
  public CreateCommandlet(IdeContext context) {
33

34
    super(context);
3✔
35
    this.newProject = add(new StringProperty("", true, "project"));
11✔
36
    add(this.settingsRepo);
5✔
37
  }
1✔
38

39
  @Override
40
  public String getName() {
41

42
    return "create";
2✔
43
  }
44

45
  @Override
46
  public boolean isIdeHomeRequired() {
47

48
    return false;
2✔
49
  }
50

51
  @Override
52
  protected void doRun() {
53

54
    String newProjectName = this.newProject.getValue();
5✔
55
    Path newProjectPath = this.context.getIdeRoot().resolve(newProjectName);
6✔
56
    Path tempProjectPath = this.context.getIdeRoot().resolve("_ide/tmp/projects").resolve(newProjectName);
8✔
57

58
    LOG.info("Creating new IDEasy project in {}", newProjectPath);
4✔
59
    if (!this.context.getFileAccess().isEmptyDir(newProjectPath)) {
6!
60
      this.context.askToContinue("Directory {} already exists. Do you want to continue?", newProjectPath);
×
61
    }
62

63
    initializeProject(tempProjectPath);
3✔
64
    this.context.setIdeHome(tempProjectPath);
4✔
65
    this.context.verifyIdeMinVersion(true);
4✔
66
    super.doRun();
2✔
67
    this.context.verifyIdeMinVersion(true);
4✔
68
    this.context.getFileAccess().writeFileContent(IdeVersion.getVersionString(), newProjectPath.resolve(IdeContext.FILE_SOFTWARE_VERSION));
8✔
69
    IdeLogLevel.SUCCESS.log(LOG, "Successfully created new project '{}'.", newProjectName);
10✔
70

71
    logWelcomeMessage();
2✔
72
  }
1✔
73

74
  private void initializeProject(Path newInstancePath) {
75

76
    FileAccess fileAccess = this.context.getFileAccess();
4✔
77
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_SOFTWARE));
5✔
78
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_PLUGINS));
5✔
79
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_WORKSPACES).resolve(IdeContext.WORKSPACE_MAIN));
7✔
80
  }
1✔
81

82
  @Override
83
  protected String getStepMessage() {
84

85
    return "Creating (Cloning) repository";
2✔
86
  }
87

88
  private void logWelcomeMessage() {
89
    Path settingsFolder = this.context.getSettingsPath();
4✔
90
    if (Files.exists(settingsFolder)) {
5!
91
      Predicate<Path> welcomePredicate = path -> String.valueOf(path.getFileName()).startsWith("welcome.");
8✔
92
      Path welcomeFilePath = this.context.getFileAccess().findFirst(settingsFolder, welcomePredicate, false);
8✔
93
      if (welcomeFilePath != null) {
2✔
94
        LOG.info(this.context.getFileAccess().readFileContent(welcomeFilePath));
7✔
95
      }
96
    }
97
  }
1✔
98
}
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