Index: maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java =================================================================== --- maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java (revision 21536) +++ maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java (working copy) @@ -548,7 +548,24 @@ return args; } + private boolean isSetMavenOption(String shortForm, String longForm) { + for (String t : Util.tokenize(getGoals())) { + if(t.equals(shortForm) || t.equals(longForm)) { + return true; + } + } + return false; + } + /** + * If the list of configured goals contain the "-N" or "--non-recursive" + * option, return true. Otherwise false. + */ + public boolean isNonRecursive() { + return isSetMavenOption("-N", "--non-recursive"); + } + + /** * Gets the workspace-relative path to an alternative Maven settings.xml file. */ public String getAlternateSettings() { Index: maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java =================================================================== --- maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java (revision 21536) +++ maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java (working copy) @@ -423,11 +423,11 @@ // we act as if incrementalBuild is not set if there are no changes. if (!MavenModuleSetBuild.this.getChangeSet().isEmptySet() && project.isIncrementalBuild()) { - // If there are changes for this module, add it. + // If there are changes for this module, add it. if ((!getChangeSetFor(m).isEmpty()) - // If the last actually-built build of this module wasn't a success, - // add it - i.e., rebuild anything that failed/was unstable in the past. - || (mb.getPreviousBuiltBuild().getResult().isWorseThan(Result.SUCCESS))) { + // If the last actually-built build of this module wasn't a success, + // add it - i.e., rebuild anything that failed/was unstable in the past. + || (mb.getPreviousBuiltBuild().getResult().isWorseThan(Result.SUCCESS))) { changedModules.add(m.getModuleName().toString()); } } @@ -784,6 +784,7 @@ private final Properties properties; private final String privateRepository; private final String alternateSettings; + private final boolean nonRecursive; public PomParser(BuildListener listener, MavenInstallation mavenHome, MavenModuleSet project) { // project cannot be shipped to the remote JVM, so all the relevant properties need to be captured now. @@ -792,6 +793,7 @@ this.rootPOM = project.getRootPOM(); this.profiles = project.getProfiles(); this.properties = project.getMavenProperties(); + this.nonRecursive = project.isNonRecursive(); if (project.usesPrivateRepository()) { this.privateRepository = project.getWorkspace().child(".repository").getRemote(); } @@ -829,7 +831,7 @@ throw new AbortException(Messages.MavenModuleSetBuild_NoSuchPOMFile(pom)); if(verbose) - logger.println("Parsing "+pom); + logger.println("Parsing " + (nonRecursive ? "non-recursively " : "recursively ") + pom); File settingsLoc = (alternateSettings == null) ? null : new File(ws, alternateSettings); @@ -844,7 +846,7 @@ properties, privateRepository, settingsLoc); MavenProject mp = embedder.readProject(pom); Map relPath = new HashMap(); - MavenUtil.resolveModules(embedder,mp,getRootPath(),relPath,listener); + MavenUtil.resolveModules(embedder,mp,getRootPath(),relPath,listener,nonRecursive); if(verbose) { for (Entry e : relPath.entrySet()) Index: maven-plugin/src/main/java/hudson/maven/MavenUtil.java =================================================================== --- maven-plugin/src/main/java/hudson/maven/MavenUtil.java (revision 21536) +++ maven-plugin/src/main/java/hudson/maven/MavenUtil.java (working copy) @@ -158,31 +158,32 @@ * @throws AbortException * errors will be reported to the listener and the exception thrown. */ - public static void resolveModules(MavenEmbedder embedder, MavenProject project, String rel, Map relativePathInfo, BuildListener listener) throws ProjectBuildingException, AbortException { + public static void resolveModules(MavenEmbedder embedder, MavenProject project, String rel, Map relativePathInfo, BuildListener listener, boolean nonRecursive) throws ProjectBuildingException, AbortException { File basedir = project.getFile().getParentFile(); relativePathInfo.put(project,rel); - List modules = new ArrayList(); + if (!nonRecursive) { + List modules = new ArrayList(); - for (String modulePath : (List) project.getModules()) { - File moduleFile = new File(basedir, modulePath); - if (moduleFile.exists() && moduleFile.isDirectory()) { - moduleFile = new File(basedir, modulePath + "/pom.xml"); - } - if(!moduleFile.exists()) - throw new AbortException(moduleFile+" is referenced from "+project.getFile()+" but it doesn't exist"); + for (String modulePath : (List) project.getModules()) { + File moduleFile = new File(basedir, modulePath); + if (moduleFile.exists() && moduleFile.isDirectory()) { + moduleFile = new File(basedir, modulePath + "/pom.xml"); + } + if(!moduleFile.exists()) + throw new AbortException(moduleFile+" is referenced from "+project.getFile()+" but it doesn't exist"); - String relativePath = rel; - if(relativePath.length()>0) relativePath+='/'; - relativePath+=modulePath; + String relativePath = rel; + if(relativePath.length()>0) relativePath+='/'; + relativePath+=modulePath; - MavenProject child = embedder.readProject(moduleFile); - resolveModules(embedder,child,relativePath,relativePathInfo,listener); - modules.add(child); + MavenProject child = embedder.readProject(moduleFile); + resolveModules(embedder,child,relativePath,relativePathInfo,listener,nonRecursive); + modules.add(child); + } + project.setCollectedProjects(modules); } - - project.setCollectedProjects(modules); } /**