Ejemplo n.º 1
0
  // TODO implement at eclipse: have product publisher take the executables from the context
  // repositories
  private File getEquinoxExecutableFeature() throws MojoExecutionException, MojoFailureException {
    // TODO 364134 take the executable feature from the target platform instead
    DependencyArtifacts dependencyArtifacts =
        TychoProjectUtils.getDependencyArtifacts(getProject());
    ArtifactDescriptor artifact =
        dependencyArtifacts.getArtifact(
            ArtifactType.TYPE_ECLIPSE_FEATURE, "org.eclipse.equinox.executable", null);

    if (artifact == null) {
      throw new MojoExecutionException(
          "Unable to locate the equinox launcher feature (aka delta-pack)");
    }

    File equinoxExecFeature = artifact.getLocation();
    if (equinoxExecFeature.isDirectory()) {
      return equinoxExecFeature.getAbsoluteFile();
    } else {
      File unzipped =
          new File(
              getProject().getBuild().getDirectory(),
              artifact.getKey().getId() + "-" + artifact.getKey().getVersion());
      if (unzipped.exists()) {
        return unzipped.getAbsoluteFile();
      }
      try {
        FileLocker locker = fileLockService.getFileLocker(equinoxExecFeature);
        locker.lock();
        try {
          // unzip now then:
          unzipped.mkdirs();
          deflater.setSourceFile(equinoxExecFeature);
          deflater.setDestDirectory(unzipped);
          deflater.extract();
          return unzipped.getAbsoluteFile();
        } finally {
          locker.release();
        }
      } catch (ArchiverException e) {
        throw new MojoFailureException("Unable to unzip the eqiuinox executable feature", e);
      }
    }
  }