Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Maven cache move #3898

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

SohamDas2021
Copy link
Contributor

@SohamDas2021 SohamDas2021 commented Sep 24, 2024

Summary of the pull request

Dev drive documentation initially suggested moving all contents of %userprofile%/.m2 to dev drive for optimization. However we only need to move contents of %userprofile%/.m2/repository to dev drive and set MAVEN_OPTS="-Dmaven.repo.local=<dev drive location for .m2\repository>"

References and relevant issues

#3336

Detailed description of the pull request / Additional comments

Validation steps performed

Manual tests. Tested with real Maven cache and repository.

if (string.Equals(variableName, "MAVEN_OPTS", StringComparison.OrdinalIgnoreCase))
{
var existingValue = Environment.GetEnvironmentVariable(variableName, EnvironmentVariableTarget.User);
var newValue = (!string.IsNullOrEmpty(existingValue) ? existingValue + " " : string.Empty) + "-Dmaven.repo.local = " + value;
Copy link
Contributor

@dhoehna dhoehna Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Consider making -Dmaven.repo.local = a const string in a common location. #WontFix

@SohamDas2021 SohamDas2021 marked this pull request as draft September 27, 2024 21:20
private void UpdateSettingsXML(string localRepositoryLocation)
{
int index = ExistingCacheLocation.IndexOf("repository", StringComparison.OrdinalIgnoreCase);
var settingsXMLPath = string.Concat(this.ExistingCacheLocation.AsSpan(0, index), "settings.xml");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this


private void UpdateSettingsXML(string localRepositoryLocation)
{
int index = ExistingCacheLocation.IndexOf("repository", StringComparison.OrdinalIgnoreCase);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if -1 is returned?

if (File.Exists(settingsXMLPath))
{
// Update settings.xml with the new repository path
UpdateOrCreateSubkey(settingsXMLPath, key, subkey, localRepositoryLocation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment says Update... but the method name is UpdateOrCreate please update the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants