private void addNormalArtifact( final DependencySet dependencySet, final Artifact depArtifact, final MavenProject depProject, final Archiver archiver, final AssemblerConfigurationSource configSource) throws AssemblyFormattingException, ArchiveCreationException { logger.debug("Adding dependency artifact " + depArtifact.getId() + "."); final AddArtifactTask task = new AddArtifactTask(depArtifact, logger); task.setProject(depProject); task.setModuleProject(moduleProject); task.setModuleArtifact(moduleArtifact); task.setOutputDirectory(dependencySet.getOutputDirectory(), defaultOutputDirectory); task.setFileNameMapping(dependencySet.getOutputFileNameMapping(), defaultOutputFileNameMapping); final int dirMode = TypeConversionUtils.modeToInt(dependencySet.getDirectoryMode(), logger); if (dirMode != -1) { task.setDirectoryMode(dirMode); } final int fileMode = TypeConversionUtils.modeToInt(dependencySet.getFileMode(), logger); if (fileMode != -1) { task.setFileMode(fileMode); } task.setUnpack(dependencySet.isUnpack()); final UnpackOptions opts = dependencySet.getUnpackOptions(); if (dependencySet.isUnpack() && (opts != null)) { task.setIncludes(opts.getIncludes()); task.setExcludes(opts.getExcludes()); } task.execute(archiver, configSource); }
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); } } } }