1 4 package com.inversoft.savant.ant.taskdefs; 5 6 7 import java.io.File ; 8 import java.util.ArrayList ; 9 import java.util.List ; 10 11 import org.apache.tools.ant.BuildException; 12 import org.apache.tools.ant.types.FileSet; 13 import org.apache.tools.ant.types.PatternSet; 14 15 import com.inversoft.savant.Artifact; 16 import com.inversoft.savant.ArtifactGroup; 17 import com.inversoft.savant.LocalCacheStore; 18 import com.inversoft.savant.SavantException; 19 import com.inversoft.savant.ant.types.ArtifactGroupType; 20 import com.inversoft.savant.ant.types.ArtifactType; 21 22 23 31 public class ArtifactUncopyTask extends UncopyTask { 32 33 private File localCache; 34 private final List artifacts = new ArrayList (); 35 private final List groups = new ArrayList (); 36 38 39 45 public void setLocalcache(File localCache) { 46 this.localCache = localCache; 47 } 48 49 54 public void addArtifact(ArtifactType artifact) { 55 artifacts.add(artifact.getProxy()); 56 } 57 58 63 public void addArtifactgroup(ArtifactGroupType group) { 64 groups.add(group.getProxy()); 65 } 66 67 70 public void execute() { 71 LocalCacheStore lcs; 72 try { 73 lcs = new LocalCacheStore(localCache); 74 } catch (SavantException se) { 75 log("Invalid local cache location [" + localCache.getAbsolutePath() + "]"); 76 throw new BuildException(se); 77 } 78 79 FileSet fs = new FileSet(); 80 fs.setProject(getProject()); 81 fs.setDir(lcs.getLocation()); 82 addIncludes(fs, artifacts); 83 84 for (int i = 0; i < groups.size(); i++) { 85 ArtifactGroup artifactGroup = (ArtifactGroup) groups.get(i); 86 addIncludes(fs, artifactGroup.getArtifacts()); 87 } 88 89 super.addFileset(fs); 90 super.execute(); 91 92 } 94 95 99 private void addIncludes(FileSet fs, List artifacts) { 100 for (int i = 0; i < artifacts.size(); i++) { 101 Artifact artifact = (Artifact) artifacts.get(i); 102 PatternSet.NameEntry ne = fs.createInclude(); 103 ne.setName(artifact.getArtifactFile()); 104 } 105 } 106 }
| Popular Tags
|