1 19 20 package org.netbeans.modules.apisupport.project.queries; 21 22 import java.io.File ; 23 import java.net.URI ; 24 import java.net.URISyntaxException ; 25 import org.netbeans.api.java.project.JavaProjectConstants; 26 import org.netbeans.api.project.Project; 27 import org.netbeans.api.project.ant.AntArtifact; 28 import org.netbeans.modules.apisupport.project.NbModuleProject; 29 import org.netbeans.spi.project.ant.AntArtifactProvider; 30 import org.netbeans.spi.project.support.ant.AntProjectHelper; 31 import org.netbeans.spi.project.support.ant.PropertyEvaluator; 32 import org.netbeans.spi.project.support.ant.PropertyUtils; 33 34 37 public final class AntArtifactProviderImpl implements AntArtifactProvider { 38 39 private final NbModuleProject project; 40 private final PropertyEvaluator eval; 41 private final AntProjectHelper helper; 42 43 public AntArtifactProviderImpl(NbModuleProject project, AntProjectHelper helper, PropertyEvaluator eval) { 44 this.project = project; 45 this.eval = eval; 46 this.helper = helper; 47 } 48 49 public AntArtifact[] getBuildArtifacts() { 50 return new AntArtifact[] { 51 new NbmAntArtifact(), 52 }; 53 } 54 55 private final class NbmAntArtifact extends AntArtifact { 56 57 public NbmAntArtifact() {} 58 59 public String getID() { 60 return "module"; } 62 63 public File getScriptLocation() { 64 return helper.resolveFile("build.xml"); } 66 67 public String getType() { 68 return JavaProjectConstants.ARTIFACT_TYPE_JAR; 69 } 70 71 public URI [] getArtifactLocations() { 72 String jarloc = eval.evaluate("${cluster}/${module.jar}"); File jar = helper.resolveFile(jarloc); String reldir = PropertyUtils.relativizeFile(project.getProjectDirectoryFile(), jar); 75 if (reldir != null) { 76 try { 77 return new URI [] {new URI (null, null, reldir, null)}; 78 } catch (URISyntaxException e) { 79 throw new AssertionError (e); 80 } 81 } else { 82 return new URI [] {jar.toURI()}; 83 } 84 } 86 87 public String getTargetName() { 88 return "netbeans"; } 90 91 public String getCleanTargetName() { 92 return "clean"; } 94 95 public Project getProject() { 96 return project; 97 } 98 99 } 100 101 } 102 | Popular Tags |