KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.File JavaDoc;
9
10 import org.apache.tools.ant.BuildException;
11
12 import fr.jayasoft.ivy.Ivy;
13 import fr.jayasoft.ivy.ModuleRevisionId;
14 import fr.jayasoft.ivy.filter.FilterHelper;
15 import fr.jayasoft.ivy.matcher.PatternMatcher;
16
17 /**
18  * Allow to install a module or a set of module from repository to another one.
19  *
20  *
21  * @author Xavier Hanin
22  *
23  */

24 public class IvyInstall extends IvyTask {
25     private String JavaDoc _organisation;
26     private String JavaDoc _module;
27     private String JavaDoc _revision;
28     private File JavaDoc _cache;
29     private boolean _overwrite = false;
30     private String JavaDoc _from;
31     private String JavaDoc _to;
32     private boolean _transitive;
33     private String JavaDoc _type;
34     private String JavaDoc _matcher = PatternMatcher.EXACT;
35     
36     public void execute() throws BuildException {
37         Ivy ivy = getIvyInstance();
38         if (_cache == null) {
39             _cache = ivy.getDefaultCache();
40         }
41         if (_organisation == null) {
42             throw new BuildException("no organisation provided for ivy publish task: It can either be set explicitely via the attribute 'organisation' or via 'ivy.organisation' property or a prior call to <resolve/>");
43         }
44         if (_module == null && PatternMatcher.EXACT.equals(_matcher)) {
45             throw new BuildException("no module name provided for ivy publish task: It can either be set explicitely via the attribute 'module' or via 'ivy.module' property or a prior call to <resolve/>");
46         } else if (_module == null && !PatternMatcher.EXACT.equals(_matcher)) {
47             _module = PatternMatcher.ANY_EXPRESSION;
48         }
49         if (_revision == null && PatternMatcher.EXACT.equals(_matcher)) {
50             throw new BuildException("no module revision provided for ivy publish task: It can either be set explicitely via the attribute 'revision' or via 'ivy.revision' property or a prior call to <resolve/>");
51         } else if (_revision == null && !PatternMatcher.EXACT.equals(_matcher)) {
52             _revision = PatternMatcher.ANY_EXPRESSION;
53         }
54         if (_from == null) {
55             throw new BuildException("no from resolver name: please provide it through parameter 'from'");
56         }
57         if (_to == null) {
58             throw new BuildException("no to resolver name: please provide it through parameter 'to'");
59         }
60         ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
61         try {
62             ivy.install(mrid, _from, _to, _transitive, doValidate(ivy), _overwrite, FilterHelper.getArtifactTypeFilter(_type), _cache, _matcher);
63         } catch (Exception JavaDoc e) {
64             throw new BuildException("impossible to install "+ mrid +": "+e, e);
65         }
66     }
67
68     public File JavaDoc getCache() {
69         return _cache;
70     }
71     public void setCache(File JavaDoc cache) {
72         _cache = cache;
73     }
74     public String JavaDoc getModule() {
75         return _module;
76     }
77     public void setModule(String JavaDoc module) {
78         _module = module;
79     }
80     public String JavaDoc getOrganisation() {
81         return _organisation;
82     }
83     public void setOrganisation(String JavaDoc organisation) {
84         _organisation = organisation;
85     }
86     public String JavaDoc getRevision() {
87         return _revision;
88     }
89     public void setRevision(String JavaDoc revision) {
90         _revision = revision;
91     }
92     
93     public boolean isOverwrite() {
94         return _overwrite;
95     }
96     public void setOverwrite(boolean overwrite) {
97         _overwrite = overwrite;
98     }
99     public String JavaDoc getFrom() {
100         return _from;
101     }
102     public void setFrom(String JavaDoc from) {
103         _from = from;
104     }
105     public String JavaDoc getTo() {
106         return _to;
107     }
108     public void setTo(String JavaDoc to) {
109         _to = to;
110     }
111     public boolean isTransitive() {
112         return _transitive;
113     }
114     public void setTransitive(boolean transitive) {
115         _transitive = transitive;
116     }
117     public String JavaDoc getType() {
118         return _type;
119     }
120     public void setType(String JavaDoc type) {
121         _type = type;
122     }
123
124     public String JavaDoc getMatcher() {
125         return _matcher;
126     }
127
128     public void setMatcher(String JavaDoc matcher) {
129         _matcher = matcher;
130     }
131 }
132
Popular Tags