Skip to content

Commit dea2df6

Browse files
committed
First check file is already absolute before use basepath
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]>
1 parent 946c118 commit dea2df6

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenExecutionContext.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,13 @@ private static File getLocalRepositoryPath(Settings settings, File multiModulePr
264264
if(localRepositoryPath == null) {
265265
return RepositorySystem.defaultUserLocalRepository;
266266
}
267-
//Actually maven would resolve these against the current working directory,
268-
//as we have no such thing available the best we can use here is the root folder of the multimodule directory
269-
return new File(multiModuleProjectDirectory, localRepositoryPath).getAbsoluteFile();
267+
File configuredPath = new File(localRepositoryPath);
268+
if(configuredPath.isAbsolute()) {
269+
return configuredPath;
270+
}
271+
//Actually maven would resolve these against the current working directory,
272+
//as we have no such thing available the best we can use here is the root folder of the multimodule directory
273+
return new File(multiModuleProjectDirectory, localRepositoryPath).getAbsoluteFile();
270274
}
271275

272276
@Override

org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenProperties.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,22 @@ public MavenSettingsLocations getSettingsLocations(IMavenConfiguration configura
336336
if(alternateGlobalSettingsFile == null) {
337337
global = configurationLocations.globalSettings();
338338
} else {
339-
global = new File(baseDir, alternateGlobalSettingsFile);
339+
File gs = new File(alternateGlobalSettingsFile);
340+
if(gs.isAbsolute()) {
341+
global = gs;
342+
} else {
343+
global = new File(baseDir, alternateGlobalSettingsFile);
344+
}
340345
}
341346
if(alternateUserSettingsFile == null) {
342347
user = configurationLocations.userSettings();
343348
} else {
344-
user = new File(baseDir, alternateUserSettingsFile);
349+
File s = new File(alternateUserSettingsFile);
350+
if(s.isAbsolute()) {
351+
user = s;
352+
} else {
353+
user = new File(baseDir, alternateUserSettingsFile);
354+
}
345355
}
346356
return new MavenSettingsLocations(global, user);
347357
}

0 commit comments

Comments
 (0)