Java Code Examples for org.apache.tools.ant.Project#replaceProperties()

The following examples show how to use org.apache.tools.ant.Project#replaceProperties() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JPDAStart.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static void verifyPaths(Project project, Path path) {
    if (path == null) return ;
    String[] paths = path.list();
    for (int i = 0; i < paths.length; i++) {
        String pathName = project.replaceProperties(paths[i]);
        File file = FileUtil.normalizeFile
            (project.resolveFile (pathName));
        if (!file.exists()) {
            project.log("Non-existing path \""+pathName+"\" provided.", Project.MSG_WARN);
            //throw new BuildException("Non-existing path \""+paths[i]+"\" provided.");
        }
    }
}
 
Example 2
Source File: JPDAStart.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static ClassPath convertToClassPath (Project project, Path path) {
    String[] paths = path == null ? new String [0] : path.list ();
    List l = new ArrayList ();
    int i, k = paths.length;
    for (i = 0; i < k; i++) {
        String pathName = project.replaceProperties(paths[i]);
        File f = FileUtil.normalizeFile (project.resolveFile (pathName));
        if (!isValid (f, project)) continue;
        URL url = fileToURL (f, project, true, false);
        if (url == null) continue;
        l.add (url);
    }
    URL[] urls = (URL[]) l.toArray (new URL [l.size ()]);
    return ClassPathSupport.createClassPath (urls);
}
 
Example 3
Source File: NbBuildLogger.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override String evaluate(String text) {
    verifyRunning();
    Project project = getProjectIfPropertiesDefined();
    if (project != null) {
        return project.replaceProperties(text);
    } else {
        return text;
    }
}
 
Example 4
Source File: JPDAStart.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * This method uses SourceForBinaryQuery to find sources for each
 * path item and returns them as ClassPath instance. All path items for which
 * the sources were not found are omitted.
 *
 */
private static ClassPath convertToSourcePath (Project project, Path path, boolean reportNonExistingFiles) {
    String[] paths = path == null ? new String [0] : path.list ();
    List l = new ArrayList ();
    Set exist = new HashSet ();
    int i, k = paths.length;
    for (i = 0; i < k; i++) {
        String pathName = project.replaceProperties(paths[i]);
        final String pathInArchive;
        final int index = pathName.lastIndexOf(URL_EMBEDDING);
        if (index >= 0) {
            pathInArchive = pathName.substring(index+URL_EMBEDDING.length()).replace(File.separatorChar, '/');  //NOI18N
            pathName = pathName.substring(0, index);
        } else {
            pathInArchive = ""; //NOI18N
        }
        File file = FileUtil.normalizeFile
            (project.resolveFile (pathName));
        if (!isValid (file, project)) continue;
        URL url = fileToURL (file, project, reportNonExistingFiles, true);
        if (url == null) continue;
        if (!pathInArchive.isEmpty()) {
            url = appendPathInArchive(url, pathInArchive, project);
        }
        logger.log(Level.FINE, "convertToSourcePath - class: {0}", url); // NOI18N
        try {
            SourceForBinaryQuery.Result srcRootsResult = SourceForBinaryQuery.findSourceRoots(url);
            FileObject fos[] = srcRootsResult.getRoots();
            int j, jj = fos.length;
            logger.log(Level.FINE, "  source roots = {0}; jj = {1}", new Object[]{java.util.Arrays.asList(fos), jj});
            /* ?? (#60640)
            if (jj == 0) { // no sourcepath defined
                // Take all registered source roots
                Set allSourceRoots = GlobalPathRegistry.getDefault().getSourceRoots();
                fos = (FileObject[]) allSourceRoots.toArray(new FileObject[0]);
                jj = fos.length;
            }
             */
            for (j = 0; j < jj; j++) {
                FileObject fo = fos[j];
                logger.log(Level.FINE, "convertToSourcePath - source : {0}", fo); // NOI18N
                if (FileUtil.isArchiveFile (fo)) {
                    fo = FileUtil.getArchiveRoot (fo);
                    if (fo == null) { // can occur if we fail to find the actual archive
                        fo = fos[j];
                    }
                }
                url = fo.toURL ();
                if (url == null) continue;
                if (!exist.contains (url)) {
                    l.add (ClassPathSupport.createResource (url));
                    exist.add (url);
                }
            } // for
        } catch (IllegalArgumentException ex) {
            Exceptions.printStackTrace(ex);
            logger.log(Level.FINE, "Have illegal url! {0}", ex.getLocalizedMessage()); // NOI18N
        }
    }
    return ClassPathSupport.createClassPath (l);
}