當前位置: 首頁>>代碼示例>>Java>>正文


Java FileSet類代碼示例

本文整理匯總了Java中com.sun.squawk.builder.util.FileSet的典型用法代碼示例。如果您正苦於以下問題:Java FileSet類的具體用法?Java FileSet怎麽用?Java FileSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileSet類屬於com.sun.squawk.builder.util包,在下文中一共展示了FileSet類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * Processes a set of files placing the resulting output in a given directory.
 *
 * @param inputFiles  the files to be processed
 * @param destDir     the directory where the processed files are to be written
 */
public void execute(FileSet inputFiles, File destDir) {
    Iterator iterator = inputFiles.list().iterator();
    while (iterator.hasNext()) {
        File inputFile = (File)iterator.next();
        if (inputFile.length() != 0) {
            File outputFile = inputFiles.replaceBaseDir(inputFile, destDir);
            try {
                execute(inputFile, outputFile);
            } catch (IOException ex) {
                System.out.println("Error processing import file " + inputFile);
                ex.printStackTrace();
            }
        }
    }
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:22,代碼來源:SourceProcessor.java

示例2: createJar

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * Convenience method that creates a jar-file using all the files in
 * <code>srcFolder</code> and the specified <code>manifest</code>.
 * 
 * @param dest The jar-file to be created.
 * @param srcFolder The source for the jar.
 * @param manifest The manifest for the jar. If this value is null, then no
 *            manifest will be included.
 * 
 * @throws BuildException if the build fails.
 * 
 * @see Build#createJar(File, FileSet[], Manifest)
 */
protected void createJar(File dest, File... srcFolders) throws BuildException {
    Manifest mf = null;
    ArrayList<FileSet> fileSets = new ArrayList<FileSet>();
    for (File srcFolder: srcFolders) {
        if (mf == null) {
            File manifestFile = getFile(srcFolder.getParentFile(), "resources", "META-INF", "MANIFEST.MF");
            if (manifestFile.canRead()) {
                try {
                    mf = new Manifest(new FileInputStream(manifestFile));
                } catch (Exception e) {
                    throw new BuildException("Error reading manifest: " + manifestFile, e);
                }
            }
        }
        fileSets.add(new FileSet(srcFolder, (FileSet.Selector) null));
    }
    env.createJar(dest, fileSets.toArray(new FileSet[fileSets.size()]), mf);
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:32,代碼來源:UEICommand.java

示例3: genJNAPhase2

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * genJNAPhase2
 * Create final JNA impl source by compiling and running C code.
 *
 * @param includeDirs include directorys to compile against
 * @param sourceDir   the directory containing the C source code to compile and run
 * @param baseDir     the directory under which the "build" directory exists
 * @param dstDir      the directory to create the generated Java files (typically "native").
 * @return the preprocessor output directory
 */
public File genJNAPhase2(
        File[] includeDirs,
        File sourceDir,
        File baseDir,
        File dstDir) {
    final File buildDir = mkdir(baseDir, "build");

    System.out.println("    Compiling and running JNA C files...");
    FileSet fs = new FileSet(buildDir, Build.C_SOURCE_SELECTOR);
    Iterator iterator = fs.list().iterator();
    while (iterator.hasNext()) {
        File inputFile = (File) iterator.next();
        if (inputFile.length() != 0 && inputFile.getName().indexOf('$') < 0) { // only look at outer classes. Inner classes will get sucked up by them
            File oFile = env.ccompiler.compile(includeDirs, inputFile, inputFile.getParentFile(), true);
            File exeFile = env.ccompiler.link(new File[]{oFile}, inputFile.getParentFile() + "/a.out", false);
            String outFileName = env.stripSuffix(inputFile.getName()) + ".java";
            File generatedFile = fs.replaceBaseDir(new File(inputFile.getParentFile(), outFileName), dstDir);

            String cmd = exeFile + " " + generatedFile;
            env.exec(cmd);
        }
    }
    System.out.println("    Generated JNA files in " + dstDir);
    return dstDir;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:36,代碼來源:Build.java

示例4: preverify

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
public void preverify(String classPath, File classesDir, File j2meclassesDir) {

        // See if any of the classes actually need re-preverifying
        FileSet.Selector outOfDate = new FileSet.DependSelector(new FileSet.SourceDestDirMapper(classesDir, j2meclassesDir));
        if (!new FileSet(classesDir, outOfDate).list().iterator().hasNext()) {
            return;
        }

        log(info, "[running preverifier ...]");

        // Ensure that the preverifier is executable which may not be the case if
        // Squawk was checked out with a Java CVS client (Java doesn't know anything
        // about 'execute' file permissions and so cannot preserve them).
        chmod(platform.preverifier(), "+x");

        if (classPath == null) {
            classPath = "";
        } else {
            classPath = " -classpath " + toPlatformPath(classPath, true);
        }
        exec(platform.preverifier() + (verbose?" -verbose ":"") + classPath + " -d " + j2meclassesDir + " " + classesDir);
    }
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:23,代碼來源:Build.java

示例5: processImports

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * Preprocess a given set of Java import file source files.
 *
 * @param   dstDir     the directory containing the generated Java src files (typically "native")
 * @param   srcDirs    the set of directories that are searched recursively for the source files to be imported
 * @param   j2me       specifies if the classes being compiled are to be deployed on a J2ME platform
 * @return the preprocessor output directory
 */
public File processImports(
        File dstDir,
        File[] srcDirs,
        boolean j2me) {
    // Get the preprocessor output directory
    SourceProcessor sp = new SourceProcessor();


    for (int i = 0; i != srcDirs.length; ++i) {

        File sourceDir = srcDirs[i];

        // A selector that matches a source file whose preprocessed copy does not exist,
        // is younger than the source file or has a last modification date
        // earlier than the last modification date of the properties
        FileSet.Selector outOfDate = new FileSet.DependSelector(new FileSet.SourceDestDirMapper(sourceDir, dstDir)) {

            public boolean isSelected(
                    File file) {
                if (super.isSelected(file)) {
                    return true;
                }
                File preprocessedFile = getMapper().map(file);
                long fileLastModified = preprocessedFile.lastModified();
                return (fileLastModified < env.propertiesLastModified);
            }
        };

        FileSet.Selector selector = new FileSet.AndSelector(JAVA_SOURCE_SELECTOR, outOfDate);
        FileSet fs = new FileSet(sourceDir, selector);
        sp.execute(fs, dstDir);
    }
    return dstDir;
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:43,代碼來源:Build.java

示例6: extractPackages

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * Extracts a list of packages from a given set of Java source files.
 *
 * @param fs   the Java source files
 * @param packages the list to append any unique package names to
 */
private void extractPackages(FileSet fs, List<String> packages) {
	for (File file: fs.list()) {
        assert file.getPath().endsWith(".java");

        // Make file relative
        String packagePath = fs.getRelativePath(file.getParentFile());
        if (packagePath.length() > 0) {
            String pkg = packagePath.replace(File.separatorChar, '.');
            if (!packages.contains(pkg)) {
                packages.add(pkg);
            }
        }
	}
}
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:21,代碼來源:Build.java

示例7: preverify

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * Run the CLDC preverifier over a set of classes in the "classes" directory
 * and write the resulting classes to the "j2meclasses" directory.
 *
 * @param   classPath  directories in which to look for classes
 * @param   baseDir    the directory under which the "j2meclasses" and "classes" directories
 */
public void preverify(String classPath, File baseDir) {


    // Get the preverifier input and output directories
    File classesDir = isJava5SyntaxSupported()?new File(baseDir, "weaved"):new File(baseDir, "classes");
    File j2meclassesDir = mkdir(baseDir, "j2meclasses");

    // See if any of the classes actually need re-preverifying
    FileSet.Selector outOfDate = new FileSet.DependSelector(new FileSet.SourceDestDirMapper(classesDir, j2meclassesDir));
    if (!new FileSet(classesDir, outOfDate).list().iterator().hasNext()) {
        return;
    }

    log(info, "[running preverifier ...]");

    // Ensure that the preverifier is executable which may not be the case if
    // Squawk was checked out with a Java CVS client (Java doesn't know anything
    // about 'execute' file permissions and so cannot preserve them).
    chmod(platform.preverifier(), "+x");

    if (classPath == null) {
        classPath = "";
    } else {
        classPath = " -classpath " + toPlatformPath(classPath, true);
    }
    exec(platform.preverifier() + (verbose?" -verbose ":"") + classPath + " -d " + j2meclassesDir + " " + classesDir);
}
 
開發者ID:sics-sse,項目名稱:moped,代碼行數:35,代碼來源:Build.java

示例8: preprocess

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
public File preprocess(File baseDir, File[] srcDirs, boolean j2me, boolean vm2c, boolean stripHostCode) {

	 // Get the preprocessor output directory
        final File preprocessedDir;
        boolean resetJava5Syntax = false;
        if (vm2c && !isJava5SyntaxSupported()) {
            log(brief, "[preprocessing with forced JAVA5SYNTAX for vm2c]");
            preprocessedDir = mkdir(baseDir, RomCommand.PREPROCESSED_FOR_VM2C_DIR_NAME);
            updateProperty("JAVA5SYNTAX", "true");
            isJava5SyntaxSupported = true;
            resetJava5Syntax = true;
        } else {
            preprocessedDir = mkdir(baseDir, stripHostCode ? "preprocessed.target" : "preprocessed");	    
        }

        // Preprocess the sources
        preprocessor.processAssertions = j2me;
        preprocessor.verbose = verbose;
        // @TODO: Should be true for desktop builds. host == target?
        preprocessor.showLineNumbers = true;

	preprocessor.hosted = !stripHostCode;
	
	for (int i = 0; i != srcDirs.length; ++i) {

            File sourceDir = srcDirs[i];

            // A selector that matches a source file whose preprocessed copy does not exist,
            // is younger than the source file or has a last modification date
            // earlier than the last modification date of the properties
            FileSet.Selector outOfDate = new FileSet.DependSelector(new FileSet.SourceDestDirMapper(sourceDir, preprocessedDir)) {
                public boolean isSelected(File file) {
                    if (super.isSelected(file)) {
                        return true;
                    }
                    File preprocessedFile = getMapper().map(file);
                    long fileLastModified = preprocessedFile.lastModified();
                    return (fileLastModified < propertiesLastModified);
                }
            };

            FileSet.Selector selector = new FileSet.AndSelector(JAVA_SOURCE_SELECTOR, outOfDate);
            FileSet fs = new FileSet(sourceDir, selector);
            preprocessor.execute(fs, preprocessedDir);

            FileSet htmlFiles = new FileSet(sourceDir, HTML_SELECTOR);
            for (Iterator iterator = htmlFiles.list().iterator(); iterator.hasNext();) {
                File htmlFile = (File) iterator.next();
                File toHtmlFile = htmlFiles.replaceBaseDir(htmlFile, preprocessedDir);
                cp(htmlFile, toHtmlFile, false);
            }

        }

        if (resetJava5Syntax) {
            updateProperty("JAVA5SYNTAX", "false");
            isJava5SyntaxSupported = false;
        }

        return preprocessedDir;
    }
 
開發者ID:tomatsu,項目名稱:squawk,代碼行數:62,代碼來源:Build.java

示例9: preprocess

import com.sun.squawk.builder.util.FileSet; //導入依賴的package包/類
/**
 * Preprocess a given set of Java source files.
 *
 * @param   baseDir    the directory under which the "preprocessed" directory exists
 * @param   srcDirs    the set of directories that are searched recursively for the source files to be compiled
 * @param   j2me       specifies if the classes being compiled are to be deployed on a J2ME platform
 * @param   vm2c       use true if preprocessing as part of vm2c compile
 * @return the preprocessor output directory
 */
public File preprocess(File baseDir, File[] srcDirs, boolean j2me, boolean vm2c) {
    // Get the preprocessor output directory
    final File preprocessedDir;
    boolean resetJava5Syntax = false;
    if (vm2c && !isJava5SyntaxSupported()) {
        log(brief, "[preprocessing with forced JAVA5SYNTAX for vm2c]");
        preprocessedDir = mkdir(baseDir, RomCommand.PREPROCESSED_FOR_VM2C_DIR_NAME);
        updateProperty("JAVA5SYNTAX", "true");
        isJava5SyntaxSupported = true;
        resetJava5Syntax = true;
    } else {
        preprocessedDir = mkdir(baseDir, "preprocessed");
    }

    // Preprocess the sources
    preprocessor.processAssertions = j2me;
    preprocessor.verbose = verbose;
    // @TODO: Should be true for desktop builds. host == target?
    preprocessor.showLineNumbers = true;

    for (int i = 0; i != srcDirs.length; ++i) {

        File sourceDir = srcDirs[i];

        // A selector that matches a source file whose preprocessed copy does not exist,
        // is younger than the source file or has a last modification date
        // earlier than the last modification date of the properties
        FileSet.Selector outOfDate = new FileSet.DependSelector(new FileSet.SourceDestDirMapper(sourceDir, preprocessedDir)) {
            public boolean isSelected(File file) {
                if (super.isSelected(file)) {
                    return true;
                }
                File preprocessedFile = getMapper().map(file);
                long fileLastModified = preprocessedFile.lastModified();
                return (fileLastModified < propertiesLastModified);
            }
        };

        FileSet.Selector selector = new FileSet.AndSelector(JAVA_SOURCE_SELECTOR, outOfDate);
        FileSet fs = new FileSet(sourceDir, selector);
        preprocessor.execute(fs, preprocessedDir);

        FileSet htmlFiles = new FileSet(sourceDir, HTML_SELECTOR);
        for (Iterator iterator = htmlFiles.list().iterator(); iterator.hasNext();) {
            File htmlFile = (File) iterator.next();
            File toHtmlFile = htmlFiles.replaceBaseDir(htmlFile, preprocessedDir);
            cp(htmlFile, toHtmlFile, false);
        }

    }

    if (resetJava5Syntax) {
        updateProperty("JAVA5SYNTAX", "false");
        isJava5SyntaxSupported = false;
    }

    return preprocessedDir;
}
 
開發者ID:sics-sse,項目名稱:moped,代碼行數:68,代碼來源:Build.java


注:本文中的com.sun.squawk.builder.util.FileSet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。