File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\tasks\BuildStepCompatibilityLayer.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.tasks;
25
26 import hudson.model.Build;
27 import hudson.model.BuildListener;
28 import hudson.model.Action;
29 import hudson.model.Project;
30 import hudson.model.AbstractBuild;
31 import hudson.model.AbstractProject;
32 import hudson.Launcher;
33
34 import java.io.IOException;
35 import java.util.Collection;
36 import java.util.Collections;
37
38 /**
39 * Provides compatibility with {@link BuildStep} before 1.150
40 * so that old plugin binaries can continue to function with new Hudson.
41 *
42 * @author Kohsuke Kawaguchi
43 * @since 1.150
44 * @deprecated since 1.150
45 */
46 public abstract class BuildStepCompatibilityLayer implements BuildStep {
47 //
48 // new definitions >= 1.150
49 //
50 public boolean prebuild(AbstractBuild<?,?> build, BuildListener listener) {
51 if (build instanceof Build)
52 return prebuild((Build)build,listener);
53 else
54 return true;
55 }
56
57 public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
58 if (build instanceof Build)
59 return perform((Build)build,launcher,listener);
60 else
61 return true;
62 }
63
64 public Action getProjectAction(AbstractProject<?, ?> project) {
65 if (project instanceof Project)
66 return getProjectAction((Project) project);
67 else
68 return null;
69 }
70
71 public Collection<? extends Action> getProjectActions(AbstractProject<?, ?> project) {
72 // delegate to getJobAction (singular) for backward compatible behavior
73 Action a = getProjectAction(project);
74 if (a==null) return Collections.emptyList();
75 return Collections.singletonList(a);
76 }
77
78
79 //
80 // old definitions < 1.150
81 //
82 /**
83 * @deprecated
84 * Use {@link #prebuild(AbstractBuild, BuildListener)} instead.
85 */
86 public boolean prebuild(Build<?,?> build, BuildListener listener) {
87 return true;
88 }
89
90 /**
91 * @deprecated
92 * Use {@link #perform(AbstractBuild, Launcher, BuildListener)} instead.
93 */
94 public boolean perform(Build<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
95 throw new UnsupportedOperationException();
96 }
97
98 /**
99 * @deprecated
100 * Use {@link #getProjectAction(AbstractProject)} instead.
101 */
102 public Action getProjectAction(Project<?,?> project) {
103 return null;
104 }
105 }
106