1 package hudson.maven; 2 3 import hudson.scm.ChangeLogSet; 4 import hudson.scm.ChangeLogSet.Entry; 5 6 import java.util.Iterator ; 7 import java.util.List ; 8 import java.util.ArrayList ; 9 10 15 public class FilteredChangeLogSet extends ChangeLogSet<Entry> { 16 private final List <Entry> master = new ArrayList <Entry>(); 17 18 public final ChangeLogSet<? extends Entry> core; 19 20 FilteredChangeLogSet(MavenBuild build) { 21 super(build); 22 MavenModule mod = build.getParent(); 23 24 List <MavenModule> subsidiaries = null; 26 27 MavenModuleSetBuild parentBuild = build.getParentBuild(); 28 if(parentBuild==null) { 29 core = ChangeLogSet.createEmpty(build); 30 return; 31 } 32 33 core = parentBuild.getChangeSet(); 34 35 for (Entry e : core) { 36 boolean belongs = false; 37 38 for (String path : e.getAffectedPaths()) { 39 if(path.startsWith(mod.getRelativePath())) { 40 belongs = true; 41 break; 42 } 43 } 44 45 if(belongs) { 46 if(subsidiaries==null) { 49 subsidiaries = new ArrayList <MavenModule>(); 50 for (MavenModule mm : mod.getParent().getModules()) { 51 if(mm!=mod && mm.getRelativePath().startsWith(mod.getRelativePath())) 52 subsidiaries.add(mm); 53 } 54 } 55 56 belongs = false; 57 58 for (String path : e.getAffectedPaths()) { 59 if(!belongsToSubsidiary(subsidiaries, path)) { 60 belongs = true; 61 break; 62 } 63 } 64 65 if(belongs) 66 master.add(e); 67 } 68 } 69 } 70 71 private boolean belongsToSubsidiary(List <MavenModule> subsidiaries, String path) { 72 for (MavenModule sub : subsidiaries) 73 if(path.startsWith(sub.getRelativePath())) 74 return true; 75 return false; 76 } 77 78 public Iterator <Entry> iterator() { 79 return master.iterator(); 80 } 81 82 public boolean isEmptySet() { 83 return master.isEmpty(); 84 } 85 } 86 | Popular Tags |