1 6 package fr.jayasoft.ivy.ant; 7 8 import java.io.File ; 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 24 public class IvyInstall extends IvyTask { 25 private String _organisation; 26 private String _module; 27 private String _revision; 28 private File _cache; 29 private boolean _overwrite = false; 30 private String _from; 31 private String _to; 32 private boolean _transitive; 33 private String _type; 34 private String _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 e) { 64 throw new BuildException("impossible to install "+ mrid +": "+e, e); 65 } 66 } 67 68 public File getCache() { 69 return _cache; 70 } 71 public void setCache(File cache) { 72 _cache = cache; 73 } 74 public String getModule() { 75 return _module; 76 } 77 public void setModule(String module) { 78 _module = module; 79 } 80 public String getOrganisation() { 81 return _organisation; 82 } 83 public void setOrganisation(String organisation) { 84 _organisation = organisation; 85 } 86 public String getRevision() { 87 return _revision; 88 } 89 public void setRevision(String 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 getFrom() { 100 return _from; 101 } 102 public void setFrom(String from) { 103 _from = from; 104 } 105 public String getTo() { 106 return _to; 107 } 108 public void setTo(String 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 getType() { 118 return _type; 119 } 120 public void setType(String type) { 121 _type = type; 122 } 123 124 public String getMatcher() { 125 return _matcher; 126 } 127 128 public void setMatcher(String matcher) { 129 _matcher = matcher; 130 } 131 } 132 | Popular Tags |