提交 883f77b9 编写于 作者: K kohsuke

fixed #364.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2553 71c3de6d-444a-0410-be80-ed276b4c234a
上级 a862578a
......@@ -192,7 +192,11 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
MavenUtil.resolveModules(embedder,mp,getRootPath(),relPath);
List<PomInfo> infos = new ArrayList<PomInfo>();
toPomInfo(mp,relPath,infos);
toPomInfo(mp,null,relPath,infos);
for (PomInfo pi : infos)
pi.cutCycle();
return infos;
} catch (MavenEmbedderException e) {
// TODO: better error handling needed
......@@ -202,10 +206,11 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
}
}
private void toPomInfo(MavenProject mp, Map<MavenProject,String> relPath, List<PomInfo> infos) {
infos.add(new PomInfo(mp,relPath.get(mp)));
private void toPomInfo(MavenProject mp, PomInfo parent, Map<MavenProject,String> relPath, List<PomInfo> infos) {
PomInfo pi = new PomInfo(mp, parent, relPath.get(mp));
infos.add(pi);
for (MavenProject child : (List<MavenProject>)mp.getCollectedProjects())
toPomInfo(child,relPath,infos);
toPomInfo(child,pi,relPath,infos);
}
private static final long serialVersionUID = 1L;
......
......@@ -52,18 +52,24 @@ final class PomInfo implements Serializable {
*/
public final String defaultGoal;
public PomInfo(MavenProject project, String relPath) {
/**
* Parent module.
*/
public final PomInfo parent;
public PomInfo(MavenProject project, PomInfo parent, String relPath) {
this.name = new ModuleName(project);
this.displayName = project.getName();
this.defaultGoal = project.getDefaultGoal();
this.relativePath = relPath;
this.parent = parent;
for (Dependency dep : (List<Dependency>)project.getDependencies())
dependencies.add(new ModuleName(dep));
MavenProject parent = project.getParent();
if(parent!=null)
dependencies.add(new ModuleName(parent));
MavenProject parentProject = project.getParent();
if(parentProject!=null)
dependencies.add(new ModuleName(parentProject));
addPluginsAsDependencies(project.getBuildPlugins(),dependencies);
addReportPluginsAsDependencies(project.getReportPlugins(),dependencies);
......@@ -86,5 +92,20 @@ final class PomInfo implements Serializable {
dependencies.add(new ModuleName(p));
}
/**
* Avoids dependency cycles.
*
* <p>
* People often write configuration in parent POMs that use the plugin
* which is a part of the build. To avoid this kind of dependency,
* make sure parent POMs don't depend on a child module.
*/
/*package*/ void cutCycle() {
for(PomInfo p=parent; p!=null; p=p.parent) {
if(p.dependencies.contains(name))
p.dependencies.remove(name);
}
}
private static final long serialVersionUID = 1L;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册