Exemplo n.º 1
0
  /** @param xstreamObject not null */
  private void addAlias(XStream xstreamObject) {
    try {
      addAlias(xstreamObject, getMavenModelJarFile(), "org.apache.maven.model");
      addAlias(xstreamObject, getMavenSettingsJarFile(), "org.apache.maven.settings");
    } catch (MojoExecutionException e) {
      if (getLog().isDebugEnabled()) {
        getLog().debug("MojoExecutionException: " + e.getMessage(), e);
      }
    } catch (ArtifactResolutionException e) {
      if (getLog().isDebugEnabled()) {
        getLog().debug("ArtifactResolutionException: " + e.getMessage(), e);
      }
    } catch (ArtifactNotFoundException e) {
      if (getLog().isDebugEnabled()) {
        getLog().debug("ArtifactNotFoundException: " + e.getMessage(), e);
      }
    } catch (ProjectBuildingException e) {
      if (getLog().isDebugEnabled()) {
        getLog().debug("ProjectBuildingException: " + e.getMessage(), e);
      }
    }

    // TODO need to handle specific Maven objects like DefaultArtifact?
  }
  protected void addDependencySet(
      final DependencySet dependencySet,
      final Archiver archiver,
      final AssemblerConfigurationSource configSource)
      throws AssemblyFormattingException, ArchiveCreationException,
          InvalidAssemblerConfigurationException {
    logger.debug("Processing DependencySet (output=" + dependencySet.getOutputDirectory() + ")");

    if (!dependencySet.isUseTransitiveDependencies() && dependencySet.isUseTransitiveFiltering()) {
      logger.warn(
          "DependencySet has nonsensical configuration: useTransitiveDependencies == false "
              + "AND useTransitiveFiltering == true. Transitive filtering flag will be ignored.");
    }

    final Set<Artifact> dependencyArtifacts = resolveDependencyArtifacts(dependencySet);

    boolean filterContents = false;
    final UnpackOptions opts = dependencySet.getUnpackOptions();
    if (dependencySet.isUnpack()
        && opts != null
        && (opts.isFiltered() || opts.getLineEnding() != null)) {
      filterContents = true;
    } else if (dependencyArtifacts.size() > 1) {
      checkMultiArtifactOutputConfig(dependencySet);
    }

    logger.debug("Adding " + dependencyArtifacts.size() + " dependency artifacts.");

    for (final Iterator<Artifact> j = dependencyArtifacts.iterator(); j.hasNext(); ) {
      final Artifact depArtifact = j.next();

      MavenProject depProject;
      try {
        depProject =
            projectBuilder.buildFromRepository(
                depArtifact,
                configSource.getRemoteRepositories(),
                configSource.getLocalRepository());
      } catch (final ProjectBuildingException e) {
        logger.debug(
            "Error retrieving POM of module-dependency: "
                + depArtifact.getId()
                + "; Reason: "
                + e.getMessage()
                + "\n\nBuilding stub project instance.");

        depProject = buildProjectStub(depArtifact);
      }

      if (NON_ARCHIVE_DEPENDENCY_TYPES.contains(depArtifact.getType())) {
        addNonArchiveDependency(depArtifact, depProject, dependencySet, archiver, configSource);
      } else {
        if (filterContents) {
          addFilteredUnpackedArtifact(
              dependencySet, depArtifact, depProject, archiver, configSource);
        } else {
          addNormalArtifact(dependencySet, depArtifact, depProject, archiver, configSource);
        }
      }
    }
  }