提交 7a7b3a6a 编写于 作者: K kohsuke

Record fingerprints for MavenModuleSetBuild as well so that the dependencies...

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
上级 0d61f87e
...@@ -6,6 +6,7 @@ import hudson.FilePath.FileCallable; ...@@ -6,6 +6,7 @@ import hudson.FilePath.FileCallable;
import hudson.Launcher; import hudson.Launcher;
import hudson.Util; import hudson.Util;
import hudson.maven.MavenBuild.ProxyImpl2; import hudson.maven.MavenBuild.ProxyImpl2;
import hudson.maven.reporters.MavenFingerprinter;
import hudson.model.AbstractBuild; import hudson.model.AbstractBuild;
import hudson.model.AbstractProject; import hudson.model.AbstractProject;
import hudson.model.Action; import hudson.model.Action;
...@@ -393,6 +394,14 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave ...@@ -393,6 +394,14 @@ public final class MavenModuleSetBuild extends AbstractBuild<MavenModuleSet,Mave
performAllBuildStep(listener, project.getPublishers(), true); performAllBuildStep(listener, project.getPublishers(), true);
performAllBuildStep(listener, project.getProperties(), 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 @Override
......
...@@ -8,6 +8,7 @@ import hudson.maven.MavenModule; ...@@ -8,6 +8,7 @@ import hudson.maven.MavenModule;
import hudson.maven.MavenReporter; import hudson.maven.MavenReporter;
import hudson.maven.MavenReporterDescriptor; import hudson.maven.MavenReporterDescriptor;
import hudson.maven.MojoInfo; import hudson.maven.MojoInfo;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.BuildListener; import hudson.model.BuildListener;
import hudson.model.FingerprintMap; import hudson.model.FingerprintMap;
import hudson.model.Hudson; import hudson.model.Hudson;
...@@ -23,6 +24,7 @@ import java.util.HashSet; ...@@ -23,6 +24,7 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.List;
/** /**
* Records fingerprints of the builds to keep track of dependencies. * Records fingerprints of the builds to keep track of dependencies.
...@@ -139,5 +141,26 @@ public class MavenFingerprinter extends MavenReporter { ...@@ -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; private static final long serialVersionUID = 1L;
} }
...@@ -244,6 +244,13 @@ public class Fingerprinter extends Publisher implements Serializable { ...@@ -244,6 +244,13 @@ public class Fingerprinter extends Publisher implements Serializable {
return build; 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. * Map from file names of the fingerprinted file to its fingerprint record.
*/ */
...@@ -283,11 +290,14 @@ public class Fingerprinter extends Publisher implements Serializable { ...@@ -283,11 +290,14 @@ public class Fingerprinter extends Publisher implements Serializable {
BuildPtr bp = fp.getOriginal(); BuildPtr bp = fp.getOriginal();
if(bp==null) continue; // outside Hudson if(bp==null) continue; // outside Hudson
if(bp.is(build)) continue; // we are the owner 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()) if(existing!=null && existing>bp.getNumber())
continue; // the record in the map is already up to date continue; // the record in the map is already up to date
r.put(bp.getJob(),bp.getNumber()); r.put(job,bp.getNumber());
} }
return r; return r;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册