/** * Set an URL to get. * * @param u URL for the file. */ public void setSrc(final URL u) { add(new URLResource(u)); }
private Resource getFileAttributeResource() { // Paths are relative to the build file they're imported from, // *not* the current directory (same as entity includes). if (file != null) { if (isExistingAbsoluteFile(file)) { return new FileResource(FILE_UTILS.normalize(file)); } File buildFile = new File(getLocation().getFileName()).getAbsoluteFile(); if (buildFile.exists()) { File buildFileParent = new File(buildFile.getParent()); File importedFile = FILE_UTILS.resolveFile(buildFileParent, file); return new FileResource(importedFile); } // maybe this import tasks is inside an imported URL? try { URL buildFileURL = new URL(getLocation().getFileName()); URL importedFile = new URL(buildFileURL, file); return new URLResource(importedFile); } catch (MalformedURLException ex) { log(ex.toString(), Project.MSG_VERBOSE); } throw new BuildException("failed to resolve %s relative to %s", file, getLocation().getFileName()); } return null; }
private Resource parse(final String line) { PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(getProject()); Object expanded = propertyHelper.parseProperties(line); if (expanded instanceof Resource) { return (Resource) expanded; } String expandedLine = expanded.toString(); if (expandedLine.contains(":")) { // could be an URL or an absolute file on an OS with drives try { return new URLResource(expandedLine); } catch (BuildException mfe) { // a translated MalformedURLException // probably it's an absolute path fall back to file // resource } } if (baseDir != null) { FileResource fr = new FileResource(baseDir, expandedLine); fr.setProject(getProject()); return fr; } return new FileResource(getProject(), expandedLine); }
ComponentHelper.getComponentHelper(project); helper.enterAntLib(uri); URLResource antlibResource = new URLResource(antlibUrl); try {
/** * access the stylesheet to be used as a resource. * @return stylesheet as a resource */ protected Resource getStylesheet() { final String xslname = getXslName(); if (styleDir == null) { // If style dir is not specified we have to retrieve // the stylesheet from the classloader URL stylesheetURL = getClass().getClassLoader().getResource( "org/apache/tools/ant/taskdefs/optional/junit/xsl/" + xslname); return new URLResource(stylesheetURL); } // If we are here, then the style dir is here and we // should read the stylesheet from the filesystem return new FileResource(new File(styleDir, xslname)); }
/** * Access the stylesheet to be used as a resource. * * @return stylesheet as a resource */ @Override protected Resource getStylesheet() { String xslname = "junit-frames.xsl"; if (NOFRAMES.equals(format)) xslname = "junit-noframes.xsl"; if (styleDir == null) { URLResource stylesheet = new URLResource(); URL stylesheetURL = getClass().getClassLoader().getResource(concat(XSL_FILE_PATH, xslname)); stylesheet.setURL(stylesheetURL); return stylesheet; } FileResource stylesheet = new FileResource(); File stylesheetFile = new File(styleDir, xslname); stylesheet.setFile(stylesheetFile); return stylesheet; }
/** * Access the stylesheet to be used as a resource. * * @return stylesheet as a resource */ @Override protected Resource getStylesheet() { String xslname = "junit-frames.xsl"; if (NOFRAMES.equals(format)) xslname = "junit-noframes.xsl"; if (styleDir == null) { URLResource stylesheet = new URLResource(); URL stylesheetURL = getClass().getClassLoader().getResource(concat(XSL_FILE_PATH, xslname)); stylesheet.setURL(stylesheetURL); return stylesheet; } FileResource stylesheet = new FileResource(); File stylesheetFile = new File(styleDir, xslname); stylesheet.setFile(stylesheetFile); return stylesheet; }
private static List<Pair<String, String>> readTaskListingFromAntlib(IFile resource) { URL url; try { url = resource.toURI().toURL(); } catch (MalformedURLException e) { throw GosuExceptionUtil.forceThrow(e); } URLResource antlibResource = new URLResource(url); ProjectHelperRepository helperRepository = ProjectHelperRepository.getInstance(); ProjectHelper parser = helperRepository.getProjectHelperForAntlib(antlibResource); UnknownElement ue = parser.parseAntlibDescriptor(AntlibTypeLoader.NULL_PROJECT, antlibResource); if (!ue.getTag().equals(Antlib.TAG)) { throw new BuildException("Unexpected tag " + ue.getTag() + " expecting " + Antlib.TAG, ue.getLocation()); } List<Pair<String, String>> listing = new ArrayList<Pair<String, String>>(); for (Object childObj : ue.getChildren()) { UnknownElement child = (UnknownElement) childObj; if (child.getTag().equals("taskdef")) { Map attributes = child.getWrapper().getAttributeMap(); listing.add(new Pair<String, String>((String) attributes.get("name"), (String) attributes.get("classname"))); } } return listing; }
this.stylesheet = new URLResource(defaultStylesheetUrl);