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

The following examples show how to use org.apache.tools.ant.Project#log() . 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: ModuleListParser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Find all modules in a binary build, possibly from cache.
 */
private static Map<String,Entry> scanBinaries(Project project, File[] clusters) throws IOException {
    Map<String,Entry> allEntries = new HashMap<>();

    for (File cluster : clusters) {
        Map<String, Entry> entries = BINARY_SCAN_CACHE.get(cluster);
        if (entries == null) {
            if (project != null) {
                project.log("Scanning for modules in " + cluster);
            }
            entries = new HashMap<>();
            doScanBinaries(cluster, entries);
            if (project != null) {
                project.log("Found modules: " + entries.keySet(), Project.MSG_VERBOSE);
            }
            BINARY_SCAN_CACHE.put(cluster, entries);
        }
        allEntries.putAll(entries);
    }
    return allEntries;
}
 
Example 2
Source File: ModuleListParser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Map<String,Entry> scanSuiteSources(Map<String,Object> properties, Project project) throws IOException {
    File basedir = new File((String) properties.get("basedir"));
    String suiteDir = (String) properties.get("suite.dir");
    if (suiteDir == null) {
        throw new IOException("No definition of suite.dir in " + basedir);
    }
    File suite = FileUtils.getFileUtils().resolveFile(basedir, suiteDir);
    if (!suite.isDirectory()) {
        throw new IOException("No such suite " + suite);
    }
    Map<String,Entry> entries = SUITE_SCAN_CACHE.get(suite);
    if (entries == null) {
        if (project != null) {
            project.log("Scanning for modules in suite " + suite);
        }
        entries = new HashMap<>();
        doScanSuite(entries, suite, properties, project);
        if (project != null) {
            project.log("Found modules: " + entries.keySet(), Project.MSG_VERBOSE);
        }
        SUITE_SCAN_CACHE.put(suite, entries);
    }
    return entries;
}
 
Example 3
Source File: AntHarnessTest.java    From ExpectIt with Apache License 2.0 6 votes vote down vote up
@Test
public void runTarget() throws IOException {
    Project project = newProject();
    project.log("started: " + target);
    // prepare
    project.executeTarget("");
    boolean negative = target.endsWith("-negative");
    // run test
    try {
        project.executeTarget(target);
        if (negative) {
            fail("Negative test fails");
        }
    } catch (BuildException e) {
        e.printStackTrace();
        if (!negative) {
            fail("Positive test fails");
        }
    } finally {
        project.log("finished");
    }
}
 
Example 4
Source File: SignJarsTask.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void extendLibrariesManifests(
    final Project prj,
    final File mainJar,
    final List<? extends File> libraries) throws IOException {
    String codebase = null;
    String permissions = null;
    String appName = null;
    final JarFile jf = new JarFile(mainJar);
    try {
        final java.util.jar.Manifest mf = jf.getManifest();
        if (mf != null) {
            final Attributes attrs = mf.getMainAttributes();
            codebase = attrs.getValue(ATTR_CODEBASE);
            permissions = attrs.getValue(ATTR_PERMISSIONS);
            appName = attrs.getValue(ATTR_APPLICATION_NAME);
        }
    } finally {
        jf.close();
    }
    prj.log(
        String.format(
            "Application: %s manifest: Codebase: %s, Permissions: %s, Application-Name: %s",    //NOI18N
            safeRelativePath(prj.getBaseDir(), mainJar),
            codebase,
            permissions,
            appName),
        Project.MSG_VERBOSE);
    if (codebase != null || permissions != null || appName != null) {
        for (File library : libraries) {
            try {
                extendLibraryManifest(prj, library, codebase, permissions, appName);
            } catch (ManifestException mex) {
                throw new IOException(mex);
            }
        }
    }
}
 
Example 5
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 6
Source File: JPDAStart.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static URL appendPathInArchive(URL rootURL, String pathInArchive, Project prj) {
    String embeddedURL = rootURL.toExternalForm() + pathInArchive;
    if (embeddedURL.charAt(embeddedURL.length()-1) != '/') {    //NOI18N
        embeddedURL = embeddedURL + '/';    //NOI18N
    }
    try {
        return new URL(embeddedURL);
    } catch (MalformedURLException e) {
        prj.log("Invalid embedded URL: \""+embeddedURL+"\".", Project.MSG_WARN);   //NOI18N
        return rootURL;
    }
}
 
Example 7
Source File: JPDAStart.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static URL fileToURL (File file, Project project, boolean reportNonExistingFiles, boolean withSlash) {
    FileObject fileObject = FileUtil.toFileObject (file);
    if (fileObject == null) {
        if (reportNonExistingFiles) {
            String path = file.getAbsolutePath();
            project.log("Have no file for "+path, Project.MSG_WARN);
        }
        return null;
    }
    if (FileUtil.isArchiveFile (fileObject)) {
        fileObject = FileUtil.getArchiveRoot (fileObject);
        if (fileObject == null) {
            project.log("Bad archive "+file.getAbsolutePath(), Project.MSG_WARN);
            /*
            ErrorManager.getDefault().notify(ErrorManager.getDefault().annotate(
                    new NullPointerException("Bad archive "+file.toString()),
                    NbBundle.getMessage(JPDAStart.class, "MSG_WrongArchive", file.getAbsolutePath())));
             */
            return null;
        }
    }
    if (withSlash) {
        return FileUtil.urlForArchiveOrDir(file);
    } else {
        return fileObject.toURL ();
    }
}
 
Example 8
Source File: JPDAStart.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean isValid (File f, Project project) {
    if (f.getPath ().indexOf ("${") != -1 && !f.exists ()) { // NOI18N
        project.log (
            "Classpath item " + f + " will be ignored.",  // NOI18N
            Project.MSG_VERBOSE
        );
        return false;
    }
    return true;
}