diff --git a/core/src/main/java/hudson/maven/MavenModuleSetBuild.java b/core/src/main/java/hudson/maven/MavenModuleSetBuild.java index 8e4fa8aa47..95b4c17f8c 100644 --- a/core/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/core/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -58,35 +58,7 @@ public final class MavenModuleSetBuild extends AbstractBuild poms = project.getWorkspace().act(new FileCallable>() { - public List invoke(File ws, VirtualChannel channel) throws IOException { - // TODO: this logic needs to be smarter - File pom = new File(ws,"pom.xml"); - - try { - MavenEmbedder embedder = MavenUtil.createEmbedder(listener); - MavenProject mp = embedder.readProject(pom); - Map relPath = new HashMap(); - MavenUtil.resolveModules(embedder,mp,"",relPath); - - List infos = new ArrayList(); - toPomInfo(mp,relPath,infos); - return infos; - } catch (MavenEmbedderException e) { - // TODO: better error handling needed - throw new IOException2(e); - } catch (ProjectBuildingException e) { - throw new IOException2(e); - } - } - - private void toPomInfo(MavenProject mp, Map relPath, List infos) { - infos.add(new PomInfo(mp,relPath.get(mp))); - for (MavenProject child : (List)mp.getCollectedProjects()) - toPomInfo(child,relPath,infos); - } - }); + List poms = project.getWorkspace().act(new PomParser(listener)); // update the module list Map modules = project.modules; @@ -137,4 +109,41 @@ public final class MavenModuleSetBuild extends AbstractBuild> { + private final BuildListener listener; + + public PomParser(BuildListener listener) { + this.listener = listener; + } + + public List invoke(File ws, VirtualChannel channel) throws IOException { + // TODO: this logic needs to be smarter + File pom = new File(ws,"pom.xml"); + + try { + MavenEmbedder embedder = MavenUtil.createEmbedder(listener); + MavenProject mp = embedder.readProject(pom); + Map relPath = new HashMap(); + MavenUtil.resolveModules(embedder,mp,"",relPath); + + List infos = new ArrayList(); + toPomInfo(mp,relPath,infos); + return infos; + } catch (MavenEmbedderException e) { + // TODO: better error handling needed + throw new IOException2(e); + } catch (ProjectBuildingException e) { + throw new IOException2(e); + } + } + + private void toPomInfo(MavenProject mp, Map relPath, List infos) { + infos.add(new PomInfo(mp,relPath.get(mp))); + for (MavenProject child : (List)mp.getCollectedProjects()) + toPomInfo(child,relPath,infos); + } + + private static final long serialVersionUID = 1L; + } }