-
Notifications
You must be signed in to change notification settings - Fork 330
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
Fix Maven cache move #3898
Conversation
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; |
There was a problem hiding this comment.
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
private void UpdateSettingsXML(string localRepositoryLocation) | ||
{ | ||
int index = ExistingCacheLocation.IndexOf("repository", StringComparison.OrdinalIgnoreCase); | ||
var settingsXMLPath = string.Concat(this.ExistingCacheLocation.AsSpan(0, index), "settings.xml"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
#Resolved
|
||
private void UpdateSettingsXML(string localRepositoryLocation) | ||
{ | ||
int index = ExistingCacheLocation.IndexOf("repository", StringComparison.OrdinalIgnoreCase); |
There was a problem hiding this comment.
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? #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code won't execute if index is -1 here. So we are good.
if (File.Exists(settingsXMLPath)) | ||
{ | ||
// Update settings.xml with the new repository path | ||
UpdateOrCreateSubkey(settingsXMLPath, key, subkey, localRepositoryLocation); |
There was a problem hiding this comment.
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. #ByDesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It updates or creates the subkey, not the file itself.
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.