1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.nuxeo.build.ant.artifact;
18
19 import java.io.File;
20
21 import org.apache.tools.ant.types.resources.FileResource;
22
23 import org.nuxeo.build.maven.AntBuildMojo;
24 import org.nuxeo.build.maven.ArtifactDescriptor;
25 import org.nuxeo.build.maven.graph.Graph;
26 import org.nuxeo.build.maven.graph.Node;
27
28
29
30
31 public class ArtifactFile extends FileResource {
32
33 protected Graph graph = AntBuildMojo.getInstance().getGraph();
34
35 protected Node node;
36
37 public String key;
38
39 public ArtifactDescriptor ad = new ArtifactDescriptor();
40
41 public void setKey(String key) {
42 this.key = key;
43 ad = ArtifactDescriptor.parseQuietly(key);
44 }
45
46 public void setArtifactId(String artifactId) {
47 ad.setArtifactId(artifactId);
48 }
49
50 public void setGroupId(String groupId) {
51 ad.setGroupId(groupId);
52 }
53
54 public void setType(String type) {
55 ad.setType(type);
56 }
57
58 public void setVersion(String version) {
59 ad.setVersion(version);
60 }
61
62 public void setClassifier(String classifier) {
63 ad.setClassifier(classifier);
64 }
65
66 public Node getNode() {
67 if (node == null) {
68 node = graph.findNode(key, ad);
69 }
70 return node;
71 }
72
73 @Override
74 public File getFile() {
75 if (isReference()) {
76 return ((FileResource) getCheckedRef()).getFile();
77 }
78 return getNode().getFile();
79 }
80
81 @Override
82 public File getBaseDir() {
83 return isReference() ? ((FileResource) getCheckedRef()).getBaseDir() : getFile().getParentFile();
84 }
85
86 }