mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
[HUDSON-4693] Systematized Maven alternate settings logic - consistent in both POM parsing and actual Maven command line.
Current behavior as of this change: - If project.getAlternateSettings() is absolute, just use the absolute path - this may not actually work through the configuration UI, but I put it in to be safe. - else, if project.getAlternateSettings() exists in getWorkspace(), use that - else, if project.getAlternateSettings() exists in getModuleRoot(), use that - else null - don't use an alternate settings location git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@34950 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
ba9fa3e095
commit
15f6a6f901
1 file changed
+25
-3
@@ -455,7 +455,16 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
}
|
||||
|
||||
if (project.getAlternateSettings() != null) {
|
||||
margs.add("-s").add(getWorkspace().child(project.getAlternateSettings()));
|
||||
if (IOUtils.isAbsolute(project.getAlternateSettings())) {
|
||||
margs.add("-s").add(project.getAlternateSettings());
|
||||
} else {
|
||||
FilePath mrSettings = getModuleRoot().child(project.getAlternateSettings());
|
||||
FilePath wsSettings = getWorkspace().child(project.getAlternateSettings());
|
||||
if (!wsSettings.exists() && mrSettings.exists())
|
||||
wsSettings = mrSettings;
|
||||
|
||||
margs.add("-s").add(wsSettings.getRemote());
|
||||
}
|
||||
}
|
||||
|
||||
margs.addTokenized(envVars.expand(project.getGoals()));
|
||||
@@ -861,8 +870,21 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
+ (nonRecursive ? "non-recursively " : "recursively ")
|
||||
+ pom);
|
||||
|
||||
File settingsLoc = (alternateSettings == null) ? null
|
||||
: new File(workspaceProper, alternateSettings);
|
||||
File settingsLoc;
|
||||
|
||||
if (alternateSettings == null) {
|
||||
settingsLoc = null;
|
||||
} else if (IOUtils.isAbsolute(alternateSettings)) {
|
||||
settingsLoc = new File(alternateSettings);
|
||||
} else {
|
||||
// Check for settings.xml first in the workspace proper, and then in the current directory,
|
||||
// which is getModuleRoot().
|
||||
// This is backwards from the order the root POM logic uses, but it's to be consistent with the Maven execution logic.
|
||||
settingsLoc = new File(workspaceProper, alternateSettings);
|
||||
File mrSettingsLoc = new File(workspaceProper, alternateSettings);
|
||||
if (!settingsLoc.exists() && mrSettingsLoc.exists())
|
||||
settingsLoc = mrSettingsLoc;
|
||||
}
|
||||
|
||||
if ((settingsLoc != null) && (!settingsLoc.exists())) {
|
||||
throw new AbortException(Messages.MavenModuleSetBuild_NoSuchAlternateSettings(settingsLoc.getAbsolutePath()));
|
||||
|
||||
Reference in new issue
Block a user