1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.project.artifact;
20
21 import java.util.Collections;
22 import java.util.List;
23
24 import org.apache.maven.artifact.DefaultArtifact;
25 import org.apache.maven.artifact.handler.ArtifactHandler;
26 import org.apache.maven.model.Dependency;
27 import org.apache.maven.model.DependencyManagement;
28 import org.apache.maven.project.MavenProject;
29
30
31
32
33 public class ProjectArtifact extends DefaultArtifact implements ArtifactWithDependencies {
34 private MavenProject project;
35
36 public ProjectArtifact(MavenProject project) {
37 super(
38 project.getGroupId(),
39 project.getArtifactId(),
40 project.getVersion(),
41 null,
42 "pom",
43 null,
44 new PomArtifactHandler());
45 this.project = project;
46 setFile(project.getFile());
47 setResolved(true);
48 }
49
50 public MavenProject getProject() {
51 return project;
52 }
53
54 public List<Dependency> getDependencies() {
55 return project.getDependencies();
56 }
57
58 public List<Dependency> getManagedDependencies() {
59 DependencyManagement depMngt = project.getDependencyManagement();
60 return (depMngt != null)
61 ? Collections.unmodifiableList(depMngt.getDependencies())
62 : Collections.<Dependency>emptyList();
63 }
64
65 static class PomArtifactHandler implements ArtifactHandler {
66 public String getClassifier() {
67 return null;
68 }
69
70 public String getDirectory() {
71 return null;
72 }
73
74 public String getExtension() {
75 return "pom";
76 }
77
78 public String getLanguage() {
79 return "none";
80 }
81
82 public String getPackaging() {
83 return "pom";
84 }
85
86 public boolean isAddedToClasspath() {
87 return false;
88 }
89
90 public boolean isIncludesDependencies() {
91 return false;
92 }
93 }
94 }