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

devonfw / IDEasy / 14646105316

24 Apr 2025 03:57PM UTC coverage: 67.476% (+0.05%) from 67.429%
14646105316

Pull #1212

github

web-flow
Merge f7ff62046 into b3452f8b4
Pull Request #1212: #1037: Fix devonfw-ide compatibility with XML templates

3085 of 4974 branches covered (62.02%)

Branch coverage included in aggregate %.

7925 of 11343 relevant lines covered (69.87%)

3.06 hits per line

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

95.12
cli/src/main/java/com/devonfw/tools/ide/variable/IdeVariables.java
1
package com.devonfw.tools.ide.variable;
2

3
import java.nio.file.Path;
4
import java.util.Collection;
5
import java.util.List;
6

7
import com.devonfw.tools.ide.context.IdeContext;
8
import com.devonfw.tools.ide.git.GitUrlSyntax;
9

10
/**
11
 * Interface (mis)used to define all the available variables.
12
 */
13
public interface IdeVariables {
14

15
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getIdeHome() IDE_HOME}. */
16
  VariableDefinitionPath IDE_HOME = new VariableDefinitionPath("IDE_HOME", "DEVON_IDE_HOME", c -> c.getIdeHome(), true);
11✔
17

18
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getIdeRoot() IDE_ROOT}. */
19
  VariableDefinitionPath IDE_ROOT = new VariableDefinitionPath("IDE_ROOT", null, c -> c.getIdeRoot());
10✔
20

21
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getUserHome() HOME}. */
22
  VariableDefinitionPath HOME = new VariableDefinitionPath("HOME", null, c -> c.getUserHome(), true);
11✔
23

24
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getWorkspaceName() WORKSPACE}. */
25
  VariableDefinitionString WORKSPACE = new VariableDefinitionString("WORKSPACE", null, c -> c.getWorkspaceName(), true);
11✔
26

27
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getPath() PATH}. */
28
  VariableDefinitionSystemPath PATH = new VariableDefinitionSystemPath("PATH", null, c -> c.getPath(), true, true);
12✔
29

30
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getWorkspacePath() WORKSPACE_PATH}. */
31
  VariableDefinitionPath WORKSPACE_PATH = new VariableDefinitionPath("WORKSPACE_PATH", null, c -> c.getWorkspacePath(), true);
11✔
32

33
  /** {@link VariableDefinition} for list of tools to install by default. */
34
  VariableDefinitionStringList IDE_TOOLS = new VariableDefinitionStringList("IDE_TOOLS", "DEVON_IDE_TOOLS", c -> List.of("mvn", "npm"));
11✔
35

36
  /** {@link VariableDefinition} for list of IDE tools to create start scripts for. */
37
  VariableDefinitionStringList CREATE_START_SCRIPTS = new VariableDefinitionStringList("CREATE_START_SCRIPTS", "DEVON_CREATE_START_SCRIPTS");
6✔
38

39
  /** {@link VariableDefinition} for minimum IDE product version. */
40
  // TODO define initial IDEasy version as default value
41
  VariableDefinitionVersion IDE_MIN_VERSION = new VariableDefinitionVersion("IDE_MIN_VERSION", "DEVON_IDE_MIN_VERSION");
6✔
42

43
  /** {@link VariableDefinition} for version of maven (mvn). */
44
  VariableDefinitionVersion MVN_VERSION = new VariableDefinitionVersion("MVN_VERSION", "MAVEN_VERSION");
6✔
45

46
  /** {@link VariableDefinition} arguments for maven to locate the settings file. */
47
  VariableDefinitionString MAVEN_ARGS = new VariableDefinitionString("MAVEN_ARGS", null, IdeContext::getMavenArgs, false, true);
9✔
48

49
  /** {@link VariableDefinition} arguments for maven to set the m2 repo location. */
50
  VariableDefinitionPath M2_REPO = new VariableDefinitionPath("M2_REPO", null, IdeVariables::getMavenRepositoryPath, false, true);
9✔
51

52
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getWorkspaceName() WORKSPACE}. */
53
  VariableDefinitionString DOCKER_EDITION = new VariableDefinitionString("DOCKER_EDITION", null, c -> "rancher");
7✔
54

55
  /** {@link VariableDefinition} for default build options of mvn */
56
  VariableDefinitionString MVN_BUILD_OPTS = new VariableDefinitionString("MVN_BUILD_OPTS", null, c -> "clean install");
7✔
57

58
  /** {@link VariableDefinition} for default build options of npm */
59
  // TODO: add default build options, see: https://github.com/devonfw/IDEasy/issues/441
60
  VariableDefinitionString NPM_BUILD_OPTS = new VariableDefinitionString("NPM_BUILD_OPTS", null, c -> "");
9✔
61

62
  /** {@link VariableDefinition} for default build options of gradle */
63
  VariableDefinitionString GRADLE_BUILD_OPTS = new VariableDefinitionString("GRADLE_BUILD_OPTS", null, c -> "clean dist");
9✔
64

65
  /** {@link VariableDefinition} for default build options of yarn */
66
  // TODO: add default build options, see: https://github.com/devonfw/IDEasy/issues/441
67
  VariableDefinitionString YARN_BUILD_OPTS = new VariableDefinitionString("YARN_BUILD_OPTS", null, c -> "");
7✔
68

69
  /** {@link VariableDefinition} for options of jasypt */
70
  VariableDefinitionString JASYPT_OPTS = new VariableDefinitionString("JASYPT_OPTS", null,
7✔
71
      c -> "algorithm=PBEWITHHMACSHA512ANDAES_256 ivGeneratorClassName=org.jasypt.iv.RandomIvGenerator");
2✔
72

73
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getProjectName() PROJECT_NAME}. */
74
  VariableDefinitionString PROJECT_NAME = new VariableDefinitionString("PROJECT_NAME", null, c -> c.getProjectName());
10✔
75

76
  /** Preferred Git protocol (HTTPS/SSH) as defined by {@link GitUrlSyntax}. */
77
  VariableDefinitionEnum<GitUrlSyntax> PREFERRED_GIT_PROTOCOL = new VariableDefinitionEnum<>("PREFERRED_GIT_PROTOCOL", null, GitUrlSyntax.class,
8✔
78
      c -> GitUrlSyntax.DEFAULT);
2✔
79

80
  /**
81
   * {@link VariableDefinition} for support of legacy variable syntax when
82
   * {@link com.devonfw.tools.ide.environment.EnvironmentVariables#resolve(String, Object, boolean) resolving variables} in configuration templates.
83
   */
84
  VariableDefinitionBoolean IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED = new VariableDefinitionBoolean("IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED", null,
7✔
85
      c -> Boolean.TRUE);
2✔
86

87
  /**
88
   * {@link VariableDefinition} for support of legacy xml templates without XML merge namespace
89
   */
90
  VariableDefinitionBoolean IDE_XML_MERGE_LEGACY_SUPPORT_ENABLED = new VariableDefinitionBoolean("IDE_XML_MERGE_LEGACY_SUPPORT_ENABLED", null,
7✔
91
      c -> Boolean.FALSE);
2✔
92

93
  /** {@link VariableDefinition} for {@link com.devonfw.tools.ide.context.IdeContext#getProjectName() DEVON_IDE_CUSTOM_TOOLS}. */
94
  VariableDefinitionString DEVON_IDE_CUSTOM_TOOLS = new VariableDefinitionString("DEVON_IDE_CUSTOM_TOOLS");
5✔
95

96
  /** A {@link Collection} with all pre-defined {@link VariableDefinition}s. */
97
  Collection<VariableDefinition<?>> VARIABLES = List.of(PATH, HOME, WORKSPACE_PATH, IDE_HOME, IDE_ROOT, WORKSPACE, IDE_TOOLS, CREATE_START_SCRIPTS,
89✔
98
      IDE_MIN_VERSION, MVN_VERSION, M2_REPO, DOCKER_EDITION, MVN_BUILD_OPTS, NPM_BUILD_OPTS, GRADLE_BUILD_OPTS, YARN_BUILD_OPTS, JASYPT_OPTS, MAVEN_ARGS,
99
      PROJECT_NAME, IDE_VARIABLE_SYNTAX_LEGACY_SUPPORT_ENABLED, PREFERRED_GIT_PROTOCOL);
100

101
  /**
102
   * @param name the name of the requested {@link VariableDefinition}.
103
   * @return the {@link VariableDefinition} for the given {@code name} or {@code null} if not defined.
104
   * @see VariableDefinition#getName()
105
   * @see VariableDefinition#getLegacyName()
106
   */
107
  static VariableDefinition<?> get(String name) {
108

109
    return IdeVariablesList.get(name);
3✔
110
  }
111

112
  /**
113
   * @param name the name of the variable.
114
   * @return {@code true} if a {@link VariableDefinition#getLegacyName() legacy variable}, {@code false} otherwise.
115
   */
116
  static boolean isLegacyVariable(String name) {
117
    VariableDefinition<?> variableDefinition = IdeVariablesList.get(name);
3✔
118
    if (variableDefinition != null) {
2✔
119
      return name.equals(variableDefinition.getLegacyName());
5✔
120
    }
121
    return false;
2✔
122
  }
123

124
  private static Path getMavenRepositoryPath(IdeContext context) {
125
    Path mvnConf = context.getMavenConfigurationFolder();
3✔
126
    if (mvnConf == null) {
2!
127
      return null;
×
128
    }
129
    return mvnConf.resolve("repository");
4✔
130
  }
131
}
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

© 2025 Coveralls, Inc