提交 15f6a6f9 编写于 作者: A abayer

[HUDSON-4693] Systematized Maven alternate settings logic - consistent in both...

[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
上级 ba9fa3e0
......@@ -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()));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册