Skip to content

Commit

Permalink
set M2_REPO variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mvomiero committed Jun 4, 2024
1 parent 81bb8bb commit f2eebcc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 13 additions & 0 deletions cli/src/main/java/com/devonfw/tools/ide/context/IdeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,19 @@ default String getMavenArgs() {

}

/**
* @return the String value for the variable M2_REPO, or null if called outside an IDEasy installation.
*/
default String getMavenRepoEnvVariable() {

if (getIdeHome() != null) {
Path m2Repo = getConfPath().resolve(Mvn.M2_CONFIG_FOLDER).resolve("repository");
return m2Repo.toString();
}
return null;

}

/**
* Updates the current working directory (CWD) and configures the environment paths according to the specified parameters. This method is central to changing
* the IDE's notion of where it operates, affecting where configurations, workspaces, settings, and other resources are located or loaded from.
Expand Down
3 changes: 2 additions & 1 deletion cli/src/main/java/com/devonfw/tools/ide/tool/mvn/Mvn.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class Mvn extends PluginBasedCommandlet {
/** The name of the settings.xml */
public static final String SETTINGS_FILE = "settings.xml";

private static final String M2_CONFIG_FOLDER = ".m2";
/** The name of the m2 repository */
public static final String M2_CONFIG_FOLDER = ".m2";

private static final String SETTINGS_SECURITY_FILE = "settings-security.xml";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ public interface IdeVariables {
/** {@link VariableDefinition} for version of maven (mvn). */
VariableDefinitionVersion MVN_VERSION = new VariableDefinitionVersion("MVN_VERSION", "MAVEN_VERSION");

/** {@link VariableDefinition} arguments for maven to set the m2 repo location. */
/** {@link VariableDefinition} arguments for maven to locate the settings file. */
VariableDefinitionString MAVEN_ARGS = new VariableDefinitionString("MAVEN_ARGS", null, c -> c.getMavenArgs(), false, true);

/** {@link VariableDefinition} arguments for maven to set the m2 repo location. */
VariableDefinitionString M2_REPO = new VariableDefinitionString("M2_REPO", null, c -> c.getMavenRepoEnvVariable(), false, true);

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

Expand All @@ -58,7 +61,7 @@ public interface IdeVariables {

/** A {@link Collection} with all pre-defined {@link VariableDefinition}s. */
Collection<VariableDefinition<?>> VARIABLES = List.of(PATH, HOME, WORKSPACE_PATH, IDE_HOME, IDE_ROOT, WORKSPACE, IDE_TOOLS, CREATE_START_SCRIPTS,
IDE_MIN_VERSION, MVN_VERSION, DOCKER_EDITION, JASYPT_OPTS, MAVEN_ARGS, PROJECT_NAME);
IDE_MIN_VERSION, MVN_VERSION, M2_REPO, DOCKER_EDITION, JASYPT_OPTS, MAVEN_ARGS, PROJECT_NAME);

/**
* @param name the name of the requested {@link VariableDefinition}.
Expand Down

0 comments on commit f2eebcc

Please sign in to comment.