提交 75ec5aef 编写于 作者: A abayer

[FIXED HUDSON-4442] Empty or whitespace-only modules are now properly ignored by POM parser

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21610 71c3de6d-444a-0410-be80-ed276b4c234a
上级 60993d8b
......@@ -24,6 +24,7 @@
package hudson.maven;
import hudson.AbortException;
import hudson.Util;
import hudson.model.BuildListener;
import hudson.model.TaskListener;
import hudson.model.AbstractProject;
......@@ -166,21 +167,23 @@ public class MavenUtil {
List<MavenProject> modules = new ArrayList<MavenProject>();
for (String modulePath : (List<String>) 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;
MavenProject child = embedder.readProject(moduleFile);
resolveModules(embedder,child,relativePath,relativePathInfo,listener);
modules.add(child);
}
if (Util.fixEmptyAndTrim(modulePath)!=null) {
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;
MavenProject child = embedder.readProject(moduleFile);
resolveModules(embedder,child,relativePath,relativePathInfo,listener);
modules.add(child);
}
}
project.setCollectedProjects(modules);
}
......
package hudson.maven;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
import hudson.Launcher;
import hudson.model.BuildListener;
import hudson.model.Result;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author Andrew Bayer
*/
public class MavenEmptyModuleTest extends HudsonTestCase {
/**
* Verify that a build will work with a module <module></module> and a module <module> </module>
*/
@Bug(4442)
public void testEmptyModuleParsesAndBuilds() throws Exception {
configureDefaultMaven();
MavenModuleSet m = createMavenProject();
m.getReporters().add(new TestReporter());
m.setScm(new ExtractResourceSCM(getClass().getResource("maven-empty-mod.zip")));
assertBuildStatusSuccess(m.scheduleBuild2(0).get());
}
private static class TestReporter extends MavenReporter {
@Override
public boolean end(MavenBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
assertNotNull(build.getProject().getWorkspace());
assertNotNull(build.getWorkspace());
return true;
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册