1 19 20 package org.netbeans.modules.project.ant; 21 22 import java.io.File ; 23 import java.net.URI ; 24 import org.netbeans.api.project.FileOwnerQuery; 25 import org.netbeans.api.project.Project; 26 import org.netbeans.api.project.ant.AntArtifact; 27 import org.netbeans.spi.project.ant.AntArtifactProvider; 28 import org.netbeans.spi.project.ant.AntArtifactQueryImplementation; 29 30 35 public class StandardAntArtifactQueryImpl implements AntArtifactQueryImplementation { 36 37 38 public StandardAntArtifactQueryImpl() {} 39 40 public AntArtifact findArtifact(File file) { 41 Project p = FileOwnerQuery.getOwner(file.toURI()); 42 if (p == null) { 43 return null; 44 } 45 AntArtifactProvider prov = p.getLookup().lookup(AntArtifactProvider.class); 46 if (prov == null) { 47 return null; 48 } 49 AntArtifact[] artifacts = prov.getBuildArtifacts(); 50 for (int i = 0; i < artifacts.length; i++) { 51 URI uris[] = artifacts[i].getArtifactLocations(); 52 for (int y = 0; y < uris.length; y++) { 53 File testFile = new File (artifacts[i].getScriptLocation().toURI().resolve(uris[y])); 54 if (file.equals(testFile)) { 55 return artifacts[i]; 56 } 57 } 58 } 59 return null; 60 } 61 62 } 63 | Popular Tags |