KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > maven > PomInfo


1 package hudson.maven;
2
3 import org.apache.maven.project.MavenProject;
4 import org.apache.maven.model.Dependency;
5 import org.apache.maven.model.Plugin;
6 import org.apache.maven.model.Extension;
7 import org.apache.maven.model.ReportPlugin;
8
9 import java.io.Serializable JavaDoc;
10 import java.util.Set JavaDoc;
11 import java.util.HashSet JavaDoc;
12 import java.util.List JavaDoc;
13
14 /**
15  * Serializable representation of the key information obtained from Maven POM.
16  *
17  * <p>
18  * This is used for the master to introspect POM, which is only available
19  * as {@link MavenProject} object on slaves.
20  *
21  * @author Kohsuke Kawaguchi
22  */

23 final class PomInfo implements Serializable JavaDoc {
24
25     public final ModuleName name;
26
27     /**
28      * This is a human readable name of the POM. Not necessarily unique
29      * or file system safe.
30      *
31      * @see MavenProject#getName()
32      */

33     public final String JavaDoc displayName;
34
35     /**
36      * Relative path from the root directory of the root POM to
37      * the root directory of this module.
38      *
39      * Strings like "" (if this is the root), "abc", "foo/bar/zot".
40      */

41     public final String JavaDoc relativePath;
42
43     /**
44      * Dependency of this project.
45      *
46      * See Maven's ProjectSorter class for the definition of the 'dependencies' in Maven.
47      */

48     public final Set JavaDoc<ModuleName> dependencies = new HashSet JavaDoc<ModuleName>();
49
50     /**
51      * The default goal specified in POM or null.
52      */

53     public final String JavaDoc defaultGoal;
54
55     public PomInfo(MavenProject project, String JavaDoc relPath) {
56         this.name = new ModuleName(project);
57         this.displayName = project.getName();
58         this.defaultGoal = project.getDefaultGoal();
59         this.relativePath = relPath;
60
61         for (Dependency dep : (List JavaDoc<Dependency>)project.getDependencies())
62             dependencies.add(new ModuleName(dep));
63
64         MavenProject parent = project.getParent();
65         if(parent!=null)
66             dependencies.add(new ModuleName(parent));
67
68         addPluginsAsDependencies(project.getBuildPlugins(),dependencies);
69         addReportPluginsAsDependencies(project.getReportPlugins(),dependencies);
70
71         List JavaDoc<Extension> extensions = project.getBuildExtensions();
72         if(extensions!=null)
73             for (Extension ext : extensions)
74                 dependencies.add(new ModuleName(ext));
75     }
76
77     private void addPluginsAsDependencies(List JavaDoc<Plugin> plugins, Set JavaDoc<ModuleName> dependencies) {
78         if(plugins==null) return;
79         for (Plugin p : plugins)
80             dependencies.add(new ModuleName(p));
81     }
82
83     private void addReportPluginsAsDependencies(List JavaDoc<ReportPlugin> plugins, Set JavaDoc<ModuleName> dependencies) {
84         if(plugins==null) return;
85         for (ReportPlugin p : plugins)
86             dependencies.add(new ModuleName(p));
87     }
88
89     private static final long serialVersionUID = 1L;
90 }
91
Popular Tags