Ejemplo n.º 1
0
  void unpackJars() throws BuildException {
    // unpack in separate dirs, to allow multiple instances of the same
    // resource from different jars.

    int jarId = 0;

    Iterator it = task.getLibs().iterator();
    while (it.hasNext()) {
      FileSet fs = (FileSet) it.next();
      DirectoryScanner scanner = fs.getDirectoryScanner(task.getProject());

      String[] files = scanner.getIncludedFiles();
      Expand unjar = (Expand) task.createSubtask(Expand.class);

      for (int i = 0; i < files.length; i++) {

        File unpackDir = new File(scratchDir, jarId++ + "");
        unpackDir.mkdirs();
        unpackedJarDirs.add(unpackDir);

        unjar.setDest(unpackDir);
        unjar.setSrc(new File(scanner.getBasedir(), files[i]));
        unjar.execute();
      }
    }
  }
Ejemplo n.º 2
0
  void createManifest() throws BuildException {
    this.manifestFile = new File(scratchDir, "MANIFEST.MF");

    Manifest.Attribute mainClass = new Manifest.Attribute();
    mainClass.setName("Main-Class");
    mainClass.setValue(task.getMainClass());

    ManifestTask manifest = (ManifestTask) task.createSubtask(ManifestTask.class);
    manifest.setFile(manifestFile);
    try {
      manifest.addConfiguredAttribute(mainClass);
    } catch (ManifestException e) {
      throw new BuildException("Manifest error", e);
    }

    manifest.execute();
  }
Ejemplo n.º 3
0
  void createFatJar() throws BuildException {
    File fatJar = new File(baseDir, task.getName() + ".jar");
    fatJar.delete();

    Jar jar = (Jar) task.createSubtask(Jar.class);
    jar.setDestFile(fatJar);
    jar.setManifest(manifestFile);

    Iterator it = unpackedJarDirs.iterator();
    while (it.hasNext()) {

      File jarDir = (File) it.next();

      FileSet fs = new FileSet();
      fs.setDir(jarDir);
      jar.addFileset(fs);
    }

    jar.execute();
  }
Ejemplo n.º 4
0
  public void execute(JApplication task) throws BuildException {
    this.task = task;
    this.baseDir = task.getDestDir();
    this.unpackedJarDirs = new ArrayList();

    try {
      executeInternal();
    } finally {
      // must clean the tempdir
      if (!recursiveDelete(scratchDir)) {
        throw new BuildException("Failed to clean up temp directory: " + scratchDir);
      }
    }
  }
Ejemplo n.º 5
0
 public static void main(String args[]) {
   JApplication app = new JApplication();
   app.Run();
 }