1 19 20 package org.netbeans.modules.xml.catalogsupport.util; 21 22 import java.net.URI ; 23 import org.netbeans.api.project.Project; 24 import org.netbeans.api.project.ProjectInformation; 25 import org.netbeans.api.project.ProjectUtils; 26 import org.netbeans.api.project.ant.AntArtifact; 27 import org.netbeans.spi.project.ant.AntArtifactProvider; 28 import org.netbeans.spi.project.support.ant.PropertyUtils; 29 import org.netbeans.spi.project.support.ant.ReferenceHelper; 30 31 35 public class ProjectReferenceUtility { 36 37 38 private ProjectReferenceUtility() { 39 } 40 41 52 public static void addProjectReference(ReferenceHelper refHelper, Project refProject) { 53 AntArtifactProvider prov = (AntArtifactProvider)refProject. 54 getLookup().lookup(AntArtifactProvider.class); 55 if(prov!=null) { 56 AntArtifact[] antArtifacts = prov.getBuildArtifacts(); 57 for(AntArtifact artifact:antArtifacts) { 58 for(URI uri:artifact.getArtifactLocations()) { 59 refHelper.addReference(artifact,uri); 60 } 61 } 62 } 63 } 64 74 public static void removeProjectReference(ReferenceHelper refHelper, Project refProject) { 75 AntArtifactProvider prov = (AntArtifactProvider)refProject. 76 getLookup().lookup(AntArtifactProvider.class); 77 if(prov!=null) { 78 ProjectInformation pInfo = ProjectUtils.getInformation(refProject); 79 String refPrefix = "${reference."+PropertyUtils. 80 getUsablePropertyName(pInfo.getName()).replace('.', '_')+"."; 81 AntArtifact[] antArtifacts = prov.getBuildArtifacts(); 82 for(AntArtifact artifact:antArtifacts) { 83 refHelper.destroyReference(refPrefix+PropertyUtils. 84 getUsablePropertyName(artifact.getID()).replace('.', '_')+"}"); 85 } 86 } 87 } 88 } 89 | Popular Tags |