modified so as not to clobber the existing configuration of modules.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1969 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-01-29 03:46:50 +00:00
1 parent 1b9f71ce56
commit a06bcf8dbf
2 files changed
+36 -2

No files matched your search

@@ -53,6 +53,16 @@ public final class MavenModule extends AbstractProject<MavenModule,MavenBuild> i
/*package*/ MavenModule(MavenModuleSet parent, PomInfo pom) {
super(parent, pom.name.toFileSystemName());
reconfigure(pom);
}
/**
* Called to update the module with the new POM.
* <p>
* This method is invoked on {@link MavenModule} that has the matching
* {@link ModuleName}.
*/
/*package*/ final void reconfigure(PomInfo pom) {
this.displayName = pom.displayName;
this.relativePath = pom.relativePath;
this.dependencies = pom.dependencies;
@@ -142,4 +152,14 @@ public final class MavenModule extends AbstractProject<MavenModule,MavenBuild> i
// dependency setting might have been changed by the user, so rebuild.
Hudson.getInstance().rebuildDependencyGraph();
}
/**
* Marks this build as disabled.
*/
public void disable() throws IOException {
if(!disabled) {
disabled = true;
save();
}
}
}
@@ -263,12 +263,26 @@ public class MavenModuleSet extends AbstractItem implements TopLevelItem, ItemGr
});
synchronized(modules) {
Map<ModuleName,MavenModule> old = new HashMap<ModuleName, MavenModule>(modules);
modules.clear();
for (PomInfo pom : poms) {
MavenModule mm = new MavenModule(this,pom);
MavenModule mm = old.get(pom.name);
if(mm!=null) {// found an existing matching module
mm.reconfigure(pom);
modules.put(pom.name,mm);
} else {// this looks like a new module
mm = new MavenModule(this,pom);
modules.put(mm.getModuleName(),mm);
}
mm.save();
modules.put(mm.getModuleName(),mm);
}
// remaining modules are no longer active.
old.keySet().removeAll(modules.keySet());
for (MavenModule om : old.values())
om.disable();
modules.putAll(old);
}
Hudson.getInstance().rebuildDependencyGraph();