1 19 20 package org.netbeans.modules.ruby.spi.project.support.rake; 21 22 import java.io.File ; 23 import java.net.URI ; 24 import java.net.URISyntaxException ; 25 import java.util.Collections ; 26 import org.netbeans.api.project.Project; 27 import org.netbeans.modules.ruby.api.project.rake.RakeArtifact; 28 import org.netbeans.modules.ruby.modules.project.rake.RakeBasedProjectFactorySingleton; 29 import org.openide.ErrorManager; 30 31 36 final class SimpleRakeArtifact extends RakeArtifact { 37 38 private final RakeProjectHelper h; 39 private final String type; 40 private final String locationProperty; 41 private final PropertyEvaluator eval; 42 private final String targetName; 43 private final String cleanTargetName; 44 45 48 public SimpleRakeArtifact(RakeProjectHelper helper, String type, String locationProperty, PropertyEvaluator eval, String targetName, String cleanTargetName) { 49 this.h = helper; 50 this.type = type; 51 this.locationProperty = locationProperty; 52 this.eval = eval; 53 this.targetName = targetName; 54 this.cleanTargetName = cleanTargetName; 55 } 56 57 private URI getArtifactLocation0() { 58 String locationResolved = eval.getProperty(locationProperty); 59 if (locationResolved == null) { 60 return URI.create("file:/UNDEFINED"); } 62 File locF = new File (locationResolved); 63 if (locF.isAbsolute()) { 64 return locF.toURI(); 65 } else { 66 try { 68 return new URI (null, null, locationResolved.replace(File.separatorChar, '/'), null); 69 } catch (URISyntaxException e) { 70 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 71 return URI.create("file:/BROKEN"); } 73 } 74 } 75 76 public URI [] getArtifactLocations() { 77 return new URI []{getArtifactLocation0()}; 78 } 79 80 public String getCleanTargetName() { 81 return cleanTargetName; 82 } 83 84 public File getScriptLocation() { 85 return h.resolveFile(GeneratedFilesHelper.BUILD_XML_PATH); 86 } 87 88 public String getTargetName() { 89 return targetName; 90 } 91 92 public String getType() { 93 return type; 94 } 95 96 public Project getProject() { 97 return RakeBasedProjectFactorySingleton.getProjectFor(h); 98 } 99 100 public String toString() { 101 return "SimpleRakeArtifact[helper=" + h + ",type=" + type + ",locationProperty=" + locationProperty + ",targetName=" + targetName + ",cleanTargetName=" + cleanTargetName + "]"; } 104 105 } 106 | Popular Tags |