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 ; 10 import java.util.Set ; 11 import java.util.HashSet ; 12 import java.util.List ; 13 14 23 final class PomInfo implements Serializable { 24 25 public final ModuleName name; 26 27 33 public final String displayName; 34 35 41 public final String relativePath; 42 43 48 public final Set <ModuleName> dependencies = new HashSet <ModuleName>(); 49 50 53 public final String defaultGoal; 54 55 public PomInfo(MavenProject project, String 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 <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 <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 <Plugin> plugins, Set <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 <ReportPlugin> plugins, Set <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 |