1 package fr.jayasoft.ivy.ant; 2 3 import org.apache.tools.ant.BuildException; 4 5 import fr.jayasoft.ivy.Ivy; 6 import fr.jayasoft.ivy.ModuleRevisionId; 7 import fr.jayasoft.ivy.matcher.PatternMatcher; 8 import fr.jayasoft.ivy.util.IvyPatternHelper; 9 10 16 public class IvyListModules extends IvyTask { 17 private String _organisation; 18 private String _module; 19 private String _branch = PatternMatcher.ANY_EXPRESSION; 20 private String _revision; 21 private String _matcher = PatternMatcher.EXACT_OR_REGEXP; 22 23 private String _property; 24 private String _value; 25 26 public String getMatcher() { 27 return _matcher; 28 } 29 30 public void setMatcher(String matcher) { 31 _matcher = matcher; 32 } 33 34 public String getModule() { 35 return _module; 36 } 37 38 public void setModule(String module) { 39 _module = module; 40 } 41 42 public String getProperty() { 43 return _property; 44 } 45 46 public void setProperty(String name) { 47 _property = name; 48 } 49 50 public String getOrganisation() { 51 return _organisation; 52 } 53 54 public void setOrganisation(String organisation) { 55 _organisation = organisation; 56 } 57 58 public String getRevision() { 59 return _revision; 60 } 61 62 public void setRevision(String revision) { 63 _revision = revision; 64 } 65 66 public String getValue() { 67 return _value; 68 } 69 70 public void setValue(String value) { 71 _value = value; 72 } 73 74 public String getBranch() { 75 return _branch; 76 } 77 78 public void setBranch(String branch) { 79 _branch = branch; 80 } 81 82 public void execute() throws BuildException { 83 if (_organisation == null) { 84 throw new BuildException("no organisation provided for ivy findmodules"); 85 } 86 if (_module == null) { 87 throw new BuildException("no module name provided for ivy findmodules"); 88 } 89 if (_revision == null) { 90 throw new BuildException("no revision provided for ivy findmodules"); 91 } 92 if (_property == null) { 93 throw new BuildException("no property provided for ivy findmodules"); 94 } 95 if (_value == null) { 96 throw new BuildException("no value provided for ivy findmodules"); 97 } 98 Ivy ivy = getIvyInstance(); 99 ModuleRevisionId[] mrids = ivy.listModules(ModuleRevisionId.newInstance(_organisation, _module, _branch, _revision), ivy.getMatcher(_matcher)); 100 for (int i = 0; i < mrids.length; i++) { 101 String name = IvyPatternHelper.substitute(ivy.substitute(_property), mrids[i]); 102 String value = IvyPatternHelper.substitute(ivy.substitute(_value), mrids[i]); 103 getProject().setProperty(name, value); 104 } 105 } 106 } 107 | Popular Tags |