File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\maven-plugin\src\main\java\hudson\maven\reporters\MavenAggregatedArtifactRecord.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.maven.reporters;
25
26 import hudson.maven.MavenAggregatedReport;
27 import hudson.maven.MavenBuild;
28 import hudson.maven.MavenEmbedder;
29 import hudson.maven.MavenEmbedderException;
30 import hudson.maven.MavenModule;
31 import hudson.maven.MavenModuleSet;
32 import hudson.maven.MavenModuleSetBuild;
33 import hudson.model.Action;
34 import hudson.model.TaskListener;
35
36 import java.io.IOException;
37 import java.util.ArrayList;
38 import java.util.List;
39 import java.util.Map;
40
41 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
42 import org.apache.maven.artifact.repository.ArtifactRepository;
43 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
44 import org.kohsuke.stapler.export.Exported;
45 import org.kohsuke.stapler.export.ExportedBean;
46
47 /**
48 * Redeploy action for the entire {@link MavenModuleSetBuild}.
49 *
50 * @author Kohsuke Kawaguchi
51 */
52 @ExportedBean
53 public class MavenAggregatedArtifactRecord extends MavenAbstractArtifactRecord<MavenModuleSetBuild> implements MavenAggregatedReport {
54 public final MavenModuleSetBuild parent;
55
56 public MavenAggregatedArtifactRecord(MavenModuleSetBuild build) {
57 this.parent = build;
58 }
59
60 public MavenModuleSetBuild getBuild() {
61 return parent;
62 }
63
64 public void update(Map<MavenModule,List<MavenBuild>> moduleBuilds, MavenBuild newBuild) {
65 }
66
67 public Class<MavenArtifactRecord> getIndividualActionType() {
68 return MavenArtifactRecord.class;
69 }
70
71 public Action getProjectAction(MavenModuleSet moduleSet) {
72 return null;
73 }
74
75 /**
76 * {@link MavenArtifactRecord}s of every module build contributed to {@link #parent}.
77 */
78 @Exported(inline=true)
79 public List<MavenArtifactRecord> getModuleRecords() {
80 List<MavenArtifactRecord> r = new ArrayList<MavenArtifactRecord>();
81 for (MavenBuild build : parent.getModuleLastBuilds().values()) {
82 MavenArtifactRecord mar = build.getAction(MavenArtifactRecord.class);
83 if(mar!=null) r.add(mar);
84 }
85 return r;
86 }
87
88 public void deploy(MavenEmbedder embedder, ArtifactRepository deploymentRepository, TaskListener listener) throws MavenEmbedderException, IOException, ComponentLookupException, ArtifactDeploymentException {
89 if(debug)
90 listener.getLogger().println("Redeploying artifacts of "+parent+" timestamp="+parent.getTimestamp());
91
92 for (MavenArtifactRecord mar : getModuleRecords()) {
93 if(debug)
94 listener.getLogger().println("Deploying module: "+mar.parent+" timestamp="+mar.parent.getTimestamp());
95 mar.deploy(embedder,deploymentRepository,listener);
96 }
97 }
98 }
99