Skip to content

Commit

Permalink
First check file is already absolute before use basepath
Browse files Browse the repository at this point in the history
Currently the basepath is always used to resolve the local repository or
settings files but this is wrong if the path is already absoloute.

Fix #1695

Signed-off-by: Christoph Läubrich <[email protected]>
  • Loading branch information
laeubi committed Feb 20, 2024
1 parent 946c118 commit dea2df6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,13 @@ private static File getLocalRepositoryPath(Settings settings, File multiModulePr
if(localRepositoryPath == null) {
return RepositorySystem.defaultUserLocalRepository;
}
//Actually maven would resolve these against the current working directory,
//as we have no such thing available the best we can use here is the root folder of the multimodule directory
return new File(multiModuleProjectDirectory, localRepositoryPath).getAbsoluteFile();
File configuredPath = new File(localRepositoryPath);
if(configuredPath.isAbsolute()) {
return configuredPath;
}
//Actually maven would resolve these against the current working directory,
//as we have no such thing available the best we can use here is the root folder of the multimodule directory
return new File(multiModuleProjectDirectory, localRepositoryPath).getAbsoluteFile();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,22 @@ public MavenSettingsLocations getSettingsLocations(IMavenConfiguration configura
if(alternateGlobalSettingsFile == null) {
global = configurationLocations.globalSettings();
} else {
global = new File(baseDir, alternateGlobalSettingsFile);
File gs = new File(alternateGlobalSettingsFile);
if(gs.isAbsolute()) {
global = gs;
} else {
global = new File(baseDir, alternateGlobalSettingsFile);
}
}
if(alternateUserSettingsFile == null) {
user = configurationLocations.userSettings();
} else {
user = new File(baseDir, alternateUserSettingsFile);
File s = new File(alternateUserSettingsFile);
if(s.isAbsolute()) {
user = s;
} else {
user = new File(baseDir, alternateUserSettingsFile);
}
}
return new MavenSettingsLocations(global, user);
}
Expand Down

0 comments on commit dea2df6

Please sign in to comment.