org.apache.tools.ant.Location Java Examples

The following examples show how to use org.apache.tools.ant.Location. 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: CheckHelpSets.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void execute() throws BuildException {
    for(FileSet fs: filesets) {
        FileScanner scanner = fs.getDirectoryScanner(getProject());
        File dir = scanner.getBasedir();
        String[] files = scanner.getIncludedFiles();
        for (int i = 0; i < files.length; i++) {
            File helpset = new File(dir, files[i]);
            try {
                checkHelpSet(helpset);
            } catch (BuildException be) {
                throw be;
            } catch (Exception e) {
                throw new BuildException("Error checking helpset", e, new Location(helpset.getAbsolutePath()));
            }
        }
    }
}
 
Example #2
Source File: NbBuildLogger.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static String getFileNameOfLocation(Location loc) {
    if (locationGetFileName != null) {
        try {
            return (String) locationGetFileName.invoke(loc);
        } catch (Exception e) {
            LOG.log(Level.WARNING, null, e);
        }
    }
    // OK, using Ant 1.5.x.
    String locs = loc.toString();
    // Format: "$file:$line: " or "$file: " or ""
    int x = locs.indexOf(':');
    if (x != -1) {
        return locs.substring(0, x);
    } else {
        return null;
    }
}
 
Example #3
Source File: NbBuildLogger.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Try to find the location of an Ant target.
 * @param project if not null, the main project from which this target might have been imported
 */
private Location getLocationOfTarget(Target target, Project project) {
    if (targetGetLocation != null) {
        try {
            return (Location) targetGetLocation.invoke(target);
        } catch (Exception e) {
            LOG.log(Level.WARNING, null, e);
        }
    }
    // For Ant 1.6.2 and earlier, hope we got the right info from the hacks above.
    LOG.log(Level.FINEST, "knownImportedTargets: {0}", knownImportedTargets);
    if (project != null) {
        String file = project.getProperty("ant.file"); // NOI18N
        if (file != null) {
            Map<String,String> targetLocations = knownImportedTargets.get(file);
            if (targetLocations != null) {
                String importedFile = targetLocations.get(target.getName());
                if (importedFile != null) {
                    // Have no line number, note.
                    return new Location(importedFile);
                }
            }
        }
    }
    // Dunno.
    return null;
}
 
Example #4
Source File: CheckHelpSets.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void checkHelpSet(File hsfile) throws Exception {
    log("Checking helpset: " + hsfile);
    HelpSet hs = new HelpSet(null, hsfile.toURI().toURL());
    javax.help.Map map = hs.getCombinedMap();
    log("Parsed helpset, checking map IDs in TOC/Index navigators...");
    NavigatorView[] navs = hs.getNavigatorViews();
    for (int i = 0; i < navs.length; i++) {
        String name = navs[i].getName();
        File navfile = new File(hsfile.getParentFile(), (String)navs[i].getParameters().get("data"));
        if (! navfile.exists()) throw new BuildException("Navigator " + name + " not found", new Location(navfile.getAbsolutePath()));
        if (navs[i] instanceof IndexView) {
            log("Checking index navigator " + name, Project.MSG_VERBOSE);
            IndexView.parse(navfile.toURI().toURL(), hs, Locale.getDefault(), new VerifyTIFactory(hs, map, navfile, false));
        } else if (navs[i] instanceof TOCView) {
            log("Checking TOC navigator " + name, Project.MSG_VERBOSE);
            TOCView.parse(navfile.toURI().toURL(), hs, Locale.getDefault(), new VerifyTIFactory(hs, map, navfile, true));
        } else {
            log("Skipping non-TOC/Index view: " + name, Project.MSG_VERBOSE);
        }
    }
    log("Checking for duplicate map IDs...");
    HelpSet.parse(hsfile.toURI().toURL(), null, new VerifyHSFactory());
    log("Checking links from help map and between HTML files...");
    @SuppressWarnings("unchecked")
    Enumeration<javax.help.Map.ID> e = map.getAllIDs();
    Set<URI> okurls = new HashSet<>(1000);
    Set<URI> badurls = new HashSet<>(1000);
    Set<URI> cleanurls = new HashSet<>(1000);
    while (e.hasMoreElements()) {
        javax.help.Map.ID id = e.nextElement();
        URL u = map.getURLFromID(id);
        if (u == null) {
            throw new BuildException("Bogus map ID: " + id.id, new Location(hsfile.getAbsolutePath()));
        }
        log("Checking ID " + id.id, Project.MSG_VERBOSE);
        List<String> errors = new ArrayList<>();
        CheckLinks.scan(this, null, null, id.id, "", 
        u.toURI(), okurls, badurls, cleanurls, false, false, false, 2, 
        Collections.<Mapper>emptyList(), errors);
        for (String error : errors) {
            log(error, Project.MSG_WARN);
        }
    }
}
 
Example #5
Source File: IvyResources.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void setLocation(Location location) {
    super.setLocation(location);
    wrapper.setLocation(location);
}