Record fingerprints for MavenModuleSetBuild as well so that the dependencies can be tracked among MMSBs, not just among MavenBuilds.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8300 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2008-04-06 01:48:04 +00:00
1 parent 0d61f87e20
commit 7a7b3a6a11
3 files changed
+44 -2

No files matched your search

@@ -6,6 +6,7 @@ import hudson.FilePath.FileCallable;
import hudson.Launcher;
import hudson.Util;
import hudson.maven.MavenBuild.ProxyImpl2;
import hudson.maven.reporters.MavenFingerprinter;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Action;
@@ -393,6 +394,14 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
performAllBuildStep(listener, project.getPublishers(), true);
performAllBuildStep(listener, project.getProperties(), true);
// aggregate all module fingerprints to us,
// so that dependencies between module builds can be understood as
// dependencies between module set builds.
// TODO: we really want to implement this as a publisher,
// but we don't want to ask for a user configuration, nor should it
// show up in the persisted record.
MavenFingerprinter.aggregate(MavenModuleSetBuild.this);
}
@Override
@@ -8,6 +8,7 @@ import hudson.maven.MavenModule;
import hudson.maven.MavenReporter;
import hudson.maven.MavenReporterDescriptor;
import hudson.maven.MojoInfo;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.BuildListener;
import hudson.model.FingerprintMap;
import hudson.model.Hudson;
@@ -23,6 +24,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.List;
/**
* Records fingerprints of the builds to keep track of dependencies.
@@ -139,5 +141,26 @@ public class MavenFingerprinter extends MavenReporter {
}
}
/**
* Creates {@link FingerprintAction} for {@link MavenModuleSetBuild}
* by aggregating all fingerprints from module builds.
*/
public static void aggregate(MavenModuleSetBuild mmsb) throws IOException {
Map<String,String> records = new HashMap<String, String>();
for (List<MavenBuild> builds : mmsb.getModuleBuilds().values()) {
for (MavenBuild build : builds) {
FingerprintAction fa = build.getAction(FingerprintAction.class);
if(fa!=null)
records.putAll(fa.getRecords());
}
}
if(!records.isEmpty()) {
FingerprintMap map = Hudson.getInstance().getFingerprintMap();
for (Entry<String, String> e : records.entrySet())
map.getOrCreate(null, e.getKey(), e.getValue()).add(mmsb);
mmsb.addAction(new FingerprintAction(mmsb,records));
}
}
private static final long serialVersionUID = 1L;
}
@@ -244,6 +244,13 @@ public class Fingerprinter extends Publisher implements Serializable {
return build;
}
/**
* Obtains the raw data.
*/
public Map<String,String> getRecords() {
return Collections.unmodifiableMap(record);
}
/**
* Map from file names of the fingerprinted file to its fingerprint record.
*/
@@ -283,11 +290,14 @@ public class Fingerprinter extends Publisher implements Serializable {
BuildPtr bp = fp.getOriginal();
if(bp==null) continue; // outside Hudson
if(bp.is(build)) continue; // we are the owner
AbstractProject job = bp.getJob();
if(job!=null && job.getParent()==build.getParent())
continue; // we are the parent of the build owner, that is almost like we are the owner
Integer existing = r.get(bp.getJob());
Integer existing = r.get(job);
if(existing!=null && existing>bp.getNumber())
continue; // the record in the map is already up to date
r.put(bp.getJob(),bp.getNumber());
r.put(job,bp.getNumber());
}
return r;