示例#1
0
  protected void generateJarFile(File jarFile, boolean standAlone, File dir) throws IOException {
    Verbose.log("Generating jar file ... " + jarFile);
    FileOutputStream out = new FileOutputStream(jarFile);
    InputStream manifestIo = getManifest();
    Manifest manifest = new Manifest(manifestIo);
    JarOutputStream jar = new JarOutputStream(out, manifest);

    int rootLen = dir.getAbsolutePath().length();

    int len = "java".length();
    for (File javaFile : javaFiles) {
      String fileName = javaFile.getPath();
      String classFile = fileName.substring(0, fileName.length() - len) + "class";
      String className = classFile.substring(rootLen + 1);
      addFileToJar(className, classFile, jar);

      String javaName = fileName.substring(rootLen + 1);
      addFileToJar(javaName, fileName, jar);
    }

    if (standAlone) {
      Verbose.log("Adding runtime classes to the jar");
      addRuntimeClasses(jar);
    }

    jar.close();
    out.close();
    Verbose.log("Generated jar file " + jarFile);
  }
示例#2
0
 protected void compileTypes(File dir) throws ToolsException {
   Compiler compiler = new Compiler();
   List<String> fileNames = new ArrayList<String>();
   for (File f : javaFiles) {
     fileNames.add(f.getPath());
   }
   compiler.compile(fileNames.toArray(new String[fileNames.size()]), dir);
 }