KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > ant > IvyCachePath


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * #SNAPSHOT#
5  */

6 package fr.jayasoft.ivy.ant;
7
8 import java.util.Iterator JavaDoc;
9
10 import org.apache.tools.ant.BuildException;
11 import org.apache.tools.ant.Project;
12 import org.apache.tools.ant.types.Path;
13
14 import fr.jayasoft.ivy.Artifact;
15 import fr.jayasoft.ivy.Ivy;
16
17 /**
18  * Creates an ant path consisting in all artifacts found during a resolve.
19  *
20  * @author Xavier Hanin
21  */

22 public class IvyCachePath extends IvyCacheTask {
23     private String JavaDoc _pathid;
24     private String JavaDoc _id;
25
26     public String JavaDoc getPathid() {
27         return _pathid;
28     }
29     public void setPathid(String JavaDoc id) {
30         _pathid = id;
31     }
32     
33     /**
34      * @deprecated use setPathid instead
35      * @param id
36      */

37     public void setId(String JavaDoc id) {
38         _id = id;
39     }
40
41     public void execute() throws BuildException {
42         prepareAndCheck();
43         if (_pathid == null) {
44             if (_id != null) {
45                 _pathid = _id;
46                 log("ID IS DEPRECATED, PLEASE USE PATHID INSTEAD", Project.MSG_WARN);
47             } else {
48                 throw new BuildException("pathid is required in ivy classpath");
49             }
50         }
51         try {
52             Path path = new Path(getProject());
53             getProject().addReference(_pathid, path);
54             Ivy ivy = getIvyInstance();
55             for (Iterator JavaDoc iter = getArtifacts().iterator(); iter.hasNext();) {
56                 Artifact a = (Artifact) iter.next();
57                 path.createPathElement().setLocation(ivy.getArchiveFileInCache(getCache(), a, ivy.getSavedArtifactOrigin(getCache(), a), isUseOrigin()));
58             }
59         } catch (Exception JavaDoc ex) {
60             throw new BuildException("impossible to build ivy path: "+ex, ex);
61         }
62         
63     }
64
65 }
66
Popular Tags