コード例 #1
0
 private static void checkStatus(IStatus status) throws FacadeException {
   if (status.matches(IStatus.ERROR)) {
     throw new FacadeException(
         MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(status),
         StatusTool.findException(status));
   }
 }
コード例 #2
0
  @Override
  public void mirrorStandalone(
      RepositoryReferences sources,
      DestinationRepositoryDescriptor destination,
      Collection<IUDescription> seedIUs,
      MirrorOptions mirrorOptions,
      BuildOutputDirectory tempDirectory)
      throws FacadeException {
    IProvisioningAgent agent = Activator.createProvisioningAgent(tempDirectory);
    try {
      final MirrorApplication mirrorApp =
          createMirrorApplication(sources, destination, agent, mirrorOptions.isIncludePacked());
      mirrorApp.setSlicingOptions(createSlicingOptions(mirrorOptions));
      try {
        // we want to see mirror progress as this is a possibly long-running operation
        mirrorApp.setVerbose(true);
        mirrorApp.setLog(new LogListener(mavenContext.getLogger()));
        mirrorApp.setSourceIUs(
            querySourceIus(seedIUs, mirrorApp.getCompositeMetadataRepository(), sources));
        IStatus returnStatus = mirrorApp.run(null);
        checkStatus(returnStatus);

      } catch (ProvisionException e) {
        throw new FacadeException(
            MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
      }
    } finally {
      agent.stop();
    }
  }
コード例 #3
0
 @Override
 public void log(IStatus status) {
   if (!status.isOK()) {
     logger.warn(MIRROR_TOOL_MESSAGE_PREFIX + StatusTool.collectProblems(status));
     hasLogged = true;
   }
 }
コード例 #4
0
 @Override
 public void log(IArtifactDescriptor descriptor, IStatus status) {
   if (!status.isOK()) {
     logger.debug(MIRROR_TOOL_MESSAGE_PREFIX + StatusTool.collectProblems(status));
     hasLogged = true;
   }
 }
コード例 #5
0
  /**
   * Generate p2 data for an artifact, if the artifact is an OSGI bundle.
   *
   * <p>The p2 metadata produced by this method is only determined by the artifact, and the function
   * used for this conversion must not change (significantly) even in future versions. This is
   * required because the resulting metadata can be included in p2 repositories built by Tycho, and
   * hence may be propagated into the p2 universe. Therefore the metadata generated by this method
   * shall fulfill the basic assumption of p2 that ID+version uniquely identifies a unit/artifact.
   * Assuming that distinct bundle artifacts specify unique ID+versions in their manifest (which
   * should be mostly true), and the p2 BundlesAction used in the implementation doesn't change
   * significantly (which can also be assumed), these conditions specified above a met.
   *
   * <p>In slight deviation on the principles described in the previous paragraph, the
   * implementation adds GAV properties to the generated IU. This is justified by the potential
   * benefits of tracing the origin of artifact.
   *
   * @param mavenArtifact An artifact in local file system.
   * @return the p2 metadata of the artifact, or <code>null</code> if the artifact isn't a valid
   *     OSGi bundle.
   */
  IInstallableUnit attemptToPublishBundle(IArtifactFacade mavenArtifact) {
    if (!isAvailableAsLocalFile(mavenArtifact)) {
      // this should have been ensured by the caller
      throw new IllegalArgumentException("Not an artifact file: " + mavenArtifact.getLocation());
    }
    if (isCertainlyNoBundle(mavenArtifact)) {
      return null;
    }

    PublisherRun publisherRun = new PublisherRun(mavenArtifact);
    IStatus status = publisherRun.execute();

    if (!status.isOK()) {
      /**
       * If publishing of a jar fails, it is simply not added to the resolution context. The
       * BundlesAction already ignores non-bundle JARs silently, so an error status here indicates a
       * caught exception that we at least want to see.
       */
      logger.warn(StatusTool.collectProblems(status), status.getException());
    }

    IInstallableUnit publishedIU = publisherRun.getPublishedUnitIfExists();
    if (publishedIU != null) {
      IArtifactDescriptor publishedDescriptor = publisherRun.getPublishedArtifactDescriptor();
      publishedArtifacts.addPublishedArtifact(publishedDescriptor, mavenArtifact);
    }

    return publishedIU;
  }
コード例 #6
0
  @Override
  public void mirrorReactor(
      RepositoryReferences sources,
      DestinationRepositoryDescriptor destination,
      Collection<DependencySeed> projectSeeds,
      BuildContext context,
      boolean includeAllDependencies,
      boolean includePacked,
      Map<String, String> filterProperties)
      throws FacadeException {
    IProvisioningAgent agent = Activator.createProvisioningAgent(context.getTargetDirectory());
    try {
      final MirrorApplication mirrorApp =
          createMirrorApplication(sources, destination, agent, includePacked);

      // mirror scope: seed units...
      mirrorApp.setSourceIUs(
          toInstallableUnitList(projectSeeds, mirrorApp.getCompositeMetadataRepository(), sources));

      // TODO the p2 mirror tool should support mirroring multiple environments at once
      for (TargetEnvironment environment : context.getEnvironments()) {
        SlicingOptions options = new SlicingOptions();
        options.considerStrictDependencyOnly(!includeAllDependencies);
        Map<String, String> filter = options.getFilter();
        addFilterForFeatureJARs(filter);
        if (filterProperties != null) {
          filter.putAll(filterProperties);
        }
        filter.putAll(environment.toFilterProperties());
        mirrorApp.setSlicingOptions(options);

        try {
          LogListener logListener = new LogListener(mavenContext.getLogger());
          mirrorApp.setLog(logListener);

          IStatus returnStatus = mirrorApp.run(null);
          checkStatus(returnStatus);
          logListener.showHelpForLoggedMessages();

        } catch (ProvisionException e) {
          throw new FacadeException(
              MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
        }
      }
    } finally {
      agent.stop();
    }
  }