Search in sources :

Example 1 with AddArtifactTask

use of org.apache.maven.plugins.assembly.archive.task.AddArtifactTask in project maven-plugins by apache.

the class ModuleSetAssemblyPhase method addModuleArtifact.

void addModuleArtifact(final Artifact artifact, final MavenProject project, final Archiver archiver, final AssemblerConfigurationSource configSource, final ModuleBinaries binaries) throws ArchiveCreationException, AssemblyFormattingException {
    if (artifact.getFile() == null) {
        throw new ArchiveCreationException("Artifact: " + artifact.getId() + " (included by module) does not have an artifact with a file. " + "Please ensure the package phase is run before the assembly is generated.");
    }
    final AddArtifactTask task = new AddArtifactTask(artifact, getLogger(), null);
    task.setFileNameMapping(binaries.getOutputFileNameMapping());
    task.setOutputDirectory(binaries.getOutputDirectory());
    task.setProject(project);
    task.setModuleProject(project);
    task.setModuleArtifact(artifact);
    final int dirMode = TypeConversionUtils.modeToInt(binaries.getDirectoryMode(), getLogger());
    if (dirMode != -1) {
        task.setDirectoryMode(dirMode);
    }
    final int fileMode = TypeConversionUtils.modeToInt(binaries.getFileMode(), getLogger());
    if (fileMode != -1) {
        task.setFileMode(fileMode);
    }
    task.setUnpack(binaries.isUnpack());
    if (binaries.isUnpack() && binaries.getUnpackOptions() != null) {
        task.setIncludes(binaries.getUnpackOptions().getIncludes());
        task.setExcludes(binaries.getUnpackOptions().getExcludes());
    }
    task.execute(archiver, configSource);
}
Also used : ArchiveCreationException(org.apache.maven.plugins.assembly.archive.ArchiveCreationException) AddArtifactTask(org.apache.maven.plugins.assembly.archive.task.AddArtifactTask)

Aggregations

ArchiveCreationException (org.apache.maven.plugins.assembly.archive.ArchiveCreationException)1 AddArtifactTask (org.apache.maven.plugins.assembly.archive.task.AddArtifactTask)1