File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\maven\ModuleDependencyLocator.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;
25
26 import hudson.ExtensionPoint;
27 import hudson.ExtensionList;
28 import hudson.Extension;
29 import jenkins.model.Jenkins;
30 import org.apache.maven.project.MavenProject;
31
32 import java.util.Collection;
33 import java.util.HashSet;
34 import java.util.Set;
35
36 /**
37 * Extension point in Hudson to find additional dependencies from {@link MavenProject}.
38 *
39 * <p>
40 * Maven plugin configurations often have additional configuration entries to specify
41 * artifacts that a build depends on. Plugins can contribute an implementation of
42 * this interface to find such hidden dependencies.
43 *
44 * <p>
45 * To register implementations, put {@link Extension} on your subclass.
46 *
47 * @author Kohsuke Kawaguchi
48 * @since 1.264
49 * @see HUDSON-2685
50 */
51 public abstract class ModuleDependencyLocator implements ExtensionPoint {
52 /**
53 * Discovers hidden dependencies.
54 *
55 * @param project
56 * In memory representation of Maven project, from which the hidden dependencies will be extracted.
57 * Never null.
58 * @param pomInfo
59 * Partially filled {@link PomInfo} object. Dependencies returned from this method will be
60 * added to this object by the caller.
61 */
62 public abstract Collection<ModuleDependency> find(MavenProject project, PomInfo pomInfo);
63
64 /**
65 * Returns all the registered {@link ModuleDependencyLocator} descriptors.
66 */
67 public static ExtensionList<ModuleDependencyLocator> all() {
68 return Jenkins.getInstance().getExtensionList(ModuleDependencyLocator.class);
69 }
70
71 /**
72 * Facade of {@link ModuleDependencyLocator}.
73 */
74 /*package*/ static class ModuleDependencyLocatorFacade extends ModuleDependencyLocator {
75 @Override
76 public Collection<ModuleDependency> find(MavenProject project, PomInfo pomInfo) {
77 Set<ModuleDependency> r = new HashSet<ModuleDependency>();
78 for (ModuleDependencyLocator m : all())
79 r.addAll(m.find(project,pomInfo));
80 return r;
81 }
82 }
83 }
84