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.ModuleId; 7 import fr.jayasoft.ivy.ModuleRevisionId; 8 import fr.jayasoft.ivy.ResolvedModuleRevision; 9 10 16 public class IvyFindRevision extends IvyTask { 17 private String _organisation; 18 private String _module; 19 private String _branch; 20 private String _revision; 21 22 private String _property = "ivy.revision"; 23 24 public String getModule() { 25 return _module; 26 } 27 28 public void setModule(String module) { 29 _module = module; 30 } 31 32 public String getOrganisation() { 33 return _organisation; 34 } 35 36 public void setOrganisation(String organisation) { 37 _organisation = organisation; 38 } 39 40 public String getRevision() { 41 return _revision; 42 } 43 44 public void setRevision(String revision) { 45 _revision = revision; 46 } 47 48 49 public String getBranch() { 50 return _branch; 51 } 52 53 public void setBranch(String branch) { 54 _branch = branch; 55 } 56 57 public String getProperty() { 58 return _property; 59 } 60 61 public void setProperty(String prefix) { 62 _property = prefix; 63 } 64 65 66 public void execute() throws BuildException { 67 if (_organisation == null) { 68 throw new BuildException("no organisation provided for ivy findmodules"); 69 } 70 if (_module == null) { 71 throw new BuildException("no module name provided for ivy findmodules"); 72 } 73 if (_revision == null) { 74 throw new BuildException("no revision provided for ivy findmodules"); 75 } 76 77 Ivy ivy = getIvyInstance(); 78 if (_branch == null) { 79 ivy.getDefaultBranch(new ModuleId(_organisation, _module)); 80 } 81 ResolvedModuleRevision rmr = ivy.findModule(ModuleRevisionId.newInstance(_organisation, _module, _branch, _revision)); 82 if (rmr != null) { 83 getProject().setProperty(_property, rmr.getId().getRevision()); 84 } 85 } 86 } 87 | Popular Tags |