From d9f6e205f7fe67090c71d514e23c3f2c68553fdf Mon Sep 17 00:00:00 2001 From: kohsuke Date: Thu, 1 Feb 2007 07:15:31 +0000 Subject: [PATCH] location of the top-level pom.xml is now configurable. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2021 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/hudson/maven/MavenModuleSet.java | 15 +++++++++++++ .../hudson/maven/MavenModuleSetBuild.java | 22 +++++++++++++++---- .../maven/MavenModuleSet/configure.jelly | 6 +++++ war/resources/help/maven/root-pom.html | 7 ++++++ 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 war/resources/help/maven/root-pom.html diff --git a/core/src/main/java/hudson/maven/MavenModuleSet.java b/core/src/main/java/hudson/maven/MavenModuleSet.java index 93a8eda8e5..f354f898b0 100644 --- a/core/src/main/java/hudson/maven/MavenModuleSet.java +++ b/core/src/main/java/hudson/maven/MavenModuleSet.java @@ -2,6 +2,7 @@ package hudson.maven; import hudson.FilePath; import hudson.Launcher; +import hudson.Util; import hudson.triggers.Trigger; import hudson.model.AbstractProject; import hudson.model.DependencyGraph; @@ -48,6 +49,8 @@ public class MavenModuleSet extends AbstractProjectpom.xml relative to the workspace root. + */ + public String getRootPOM() { + if(rootPOM==null) return "pom.xml"; + return rootPOM; + } + + /*package*/ void setRootModule(ModuleName rootModule) throws IOException { if(this.rootModule!=null && this.rootModule.equals(rootModule)) return; // no change @@ -219,6 +231,9 @@ public class MavenModuleSet extends AbstractProject poms = project.getWorkspace().act(new PomParser(listener)); + List poms = project.getWorkspace().act(new PomParser(listener,project.getRootPOM())); // update the module list Map modules = project.modules; @@ -93,6 +93,9 @@ public final class MavenModuleSetBuild extends AbstractBuild> { private final BuildListener listener; + private final String rootPOM; - public PomParser(BuildListener listener) { + public PomParser(BuildListener listener, String rootPOM) { this.listener = listener; + this.rootPOM = rootPOM; } public List invoke(File ws, VirtualChannel channel) throws IOException { - // TODO: this logic needs to be smarter - File pom = new File(ws,"pom.xml"); + File pom = new File(ws,rootPOM); + + if(!pom.exists()) { + listener.getLogger().println("No such file "+pom); + listener.getLogger().println("Perhaps you need to specify the correct POM file path in the project configuration?"); + throw new AbortException(); + } try { MavenEmbedder embedder = MavenUtil.createEmbedder(listener); @@ -146,4 +156,8 @@ public final class MavenModuleSetBuild extends AbstractBuild + + + + + + diff --git a/war/resources/help/maven/root-pom.html b/war/resources/help/maven/root-pom.html new file mode 100644 index 0000000000..ebc25cd4cd --- /dev/null +++ b/war/resources/help/maven/root-pom.html @@ -0,0 +1,7 @@ +
+ If your workspace has the top-level pom.xml in somewhere other + than the root directory of the workspace, specify the path (relative to + the workspace root) here, such as parent/pom.xml. +
+ If left empty, treated as pom.xml +
\ No newline at end of file