|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.nbbuild; import java.io.*; import java.util.*; import java.util.jar.Attributes; import java.util.jar.Manifest; import org.apache.tools.ant.*; import org.apache.tools.ant.types.*; import javax.xml.parsers.*; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; /** Task that scans Bundle.properties files for unused keys. * * @author Radim Kubacki */ public class CheckBundles extends Task { private static HashSet knownKeys; private static String [] moduleKeys = new String [] { "OpenIDE-Module-Name", "OpenIDE-Module-Display-Category", "OpenIDE-Module-Long-Description", "OpenIDE-Module-Short-Description", "OpenIDE-Module-Package-Dependency-Message" }; private File srcdir; public void setSrcdir(File f) { // Note: f will automatically be absolute (resolved from project basedir). if (!f.isDirectory()) throw new IllegalArgumentException ("srcdir must be a directory"); srcdir = f; } public void execute() throws BuildException { log("Scanning "+srcdir.getAbsolutePath(), Project.MSG_VERBOSE); Map knownNames = parseManifest(srcdir); Collection bundles = new ArrayList(); Map sources = new TreeMap(); try { File dir = new File (srcdir, "src"); if (dir.exists()) scanSubdirs(dir, bundles, sources); dir = new File (srcdir, "libsrc"); if (dir.exists()) scanSubdirs(dir, bundles, sources); check (bundles, sources, knownNames); } catch (Exception e) { throw new BuildException (e); } } private void scan (File file, Collection bundles, Map sources) throws Exception { File bundle = new File (file, "Bundle.properties"); if (!bundle.exists()) { log("No bundle in "+file.getAbsolutePath()+". OK", Project.MSG_VERBOSE); } else { bundles.add (bundle); } addSources (file, sources); } private void check (Collection bundles, Map files, Map knownNames) { try { Iterator bIt = bundles.iterator(); while (bIt.hasNext ()) { File bundle = (File)bIt.next(); Iterator it = entries (bundle).iterator (); while (it.hasNext()) { String key = (String)it.next(); log("Looking for "+key, Project.MSG_DEBUG); boolean found = false; // module info or file name from layer if (bundle.equals (knownNames.get(key))) { log("Checked name "+key+" OK", Project.MSG_VERBOSE); found = true; } else { // java source in the same package Object o = files.get (bundle.getParentFile()); log(" in "+o, Project.MSG_DEBUG); String [] srcs = (String [])o; for (int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.