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

devonfw / IDEasy / 22241505980

20 Feb 2026 09:16PM UTC coverage: 70.656% (+0.2%) from 70.474%
22241505980

Pull #1710

github

web-flow
Merge 04e4bdacd into 379acdc9d
Pull Request #1710: #404: allow logging via SLF4J

4121 of 6440 branches covered (63.99%)

Branch coverage included in aggregate %.

10704 of 14542 relevant lines covered (73.61%)

3.13 hits per line

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

93.33
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
  /** {@link FlagProperty} for creating a project with settings inside a code repository */
28
  public final FlagProperty codeRepositoryFlag;
29

30
  /**
31
   * The constructor.
32
   *
33
   * @param context the {@link IdeContext}.
34
   */
35
  public CreateCommandlet(IdeContext context) {
36

37
    super(context);
3✔
38
    this.newProject = add(new StringProperty("", true, "project"));
11✔
39
    this.codeRepositoryFlag = add(new FlagProperty("--code"));
9✔
40
    add(this.settingsRepo);
5✔
41
  }
1✔
42

43
  @Override
44
  public String getName() {
45

46
    return "create";
2✔
47
  }
48

49
  @Override
50
  public boolean isIdeHomeRequired() {
51

52
    return false;
2✔
53
  }
54

55
  @Override
56
  protected void doRun() {
57

58
    String newProjectName = this.newProject.getValue();
5✔
59
    Path newProjectPath = this.context.getIdeRoot().resolve(newProjectName);
6✔
60

61
    LOG.info("Creating new IDEasy project in {}", newProjectPath);
4✔
62
    if (!this.context.getFileAccess().isEmptyDir(newProjectPath)) {
6!
63
      this.context.askToContinue("Directory " + newProjectPath + " already exists. Do you want to continue?");
×
64
    } else {
65
      this.context.getFileAccess().mkdirs(newProjectPath);
5✔
66
    }
67

68
    initializeProject(newProjectPath);
3✔
69
    this.context.setIdeHome(newProjectPath);
4✔
70
    this.context.verifyIdeMinVersion(true);
4✔
71
    super.doRun();
2✔
72
    this.context.verifyIdeMinVersion(true);
4✔
73
    this.context.getFileAccess().writeFileContent(IdeVersion.getVersionString(), newProjectPath.resolve(IdeContext.FILE_SOFTWARE_VERSION));
8✔
74
    LOG.info(IdeLogLevel.SUCCESS.getSlf4jMarker(), "Successfully created new project '{}'.", newProjectName);
6✔
75

76
    logWelcomeMessage();
2✔
77
  }
1✔
78

79
  private void initializeProject(Path newInstancePath) {
80

81
    FileAccess fileAccess = this.context.getFileAccess();
4✔
82
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_SOFTWARE));
5✔
83
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_PLUGINS));
5✔
84
    fileAccess.mkdirs(newInstancePath.resolve(IdeContext.FOLDER_WORKSPACES).resolve(IdeContext.WORKSPACE_MAIN));
7✔
85
  }
1✔
86

87
  @Override
88
  protected boolean isCodeRepository() {
89
    return this.codeRepositoryFlag.isTrue();
4✔
90
  }
91

92
  @Override
93
  protected String getStepMessage() {
94

95
    return "Create (clone) " + (isCodeRepository() ? "code" : "settings") + " repository";
8✔
96
  }
97

98
  private void logWelcomeMessage() {
99
    Path settingsFolder = this.context.getSettingsPath();
4✔
100
    if (Files.exists(settingsFolder)) {
5✔
101
      Predicate<Path> welcomePredicate = path -> String.valueOf(path.getFileName()).startsWith("welcome.");
8✔
102
      Path welcomeFilePath = this.context.getFileAccess().findFirst(settingsFolder, welcomePredicate, false);
8✔
103
      if (welcomeFilePath != null) {
2!
104
        LOG.info(this.context.getFileAccess().readFileContent(welcomeFilePath));
7✔
105
      }
106
    }
107
  }
1✔
108
}
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