Search in sources :

Example 1 with RepositoryAssemblyException

use of org.apache.maven.plugins.assembly.repository.RepositoryAssemblyException in project maven-plugins by apache.

the class RepositoryAssemblyPhase method execute.

/**
     * {@inheritDoc}
     */
@Override
@SuppressWarnings("ResultOfMethodCallIgnored")
public void execute(final Assembly assembly, final Archiver archiver, final AssemblerConfigurationSource configSource) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final List<Repository> repositoriesList = assembly.getRepositories();
    final File tempRoot = configSource.getTemporaryRootDirectory();
    for (final Repository repository : repositoriesList) {
        final String outputDirectory = AssemblyFormatUtils.getOutputDirectory(repository.getOutputDirectory(), configSource.getFinalName(), configSource, AssemblyFormatUtils.moduleProjectInterpolator(configSource.getProject()), AssemblyFormatUtils.artifactProjectInterpolator(null));
        final File repositoryDirectory = new File(tempRoot, outputDirectory);
        if (!repositoryDirectory.exists()) {
            repositoryDirectory.mkdirs();
        }
        try {
            getLogger().debug("Assembling repository to: " + repositoryDirectory);
            repositoryAssembler.buildRemoteRepository(repositoryDirectory, wrap(repository), wrap(configSource));
            getLogger().debug("Finished assembling repository to: " + repositoryDirectory);
        } catch (final RepositoryAssemblyException e) {
            throw new ArchiveCreationException("Failed to assemble repository: " + e.getMessage(), e);
        }
        final AddDirectoryTask task = new AddDirectoryTask(repositoryDirectory);
        final int dirMode = TypeConversionUtils.modeToInt(repository.getDirectoryMode(), getLogger());
        if (dirMode != -1) {
            task.setDirectoryMode(dirMode);
        }
        final int fileMode = TypeConversionUtils.modeToInt(repository.getFileMode(), getLogger());
        if (fileMode != -1) {
            task.setFileMode(fileMode);
        }
        task.setOutputDirectory(outputDirectory);
        task.execute(archiver);
    }
}
Also used : Repository(org.apache.maven.plugins.assembly.model.Repository) RepositoryAssemblyException(org.apache.maven.plugins.assembly.repository.RepositoryAssemblyException) ArchiveCreationException(org.apache.maven.plugins.assembly.archive.ArchiveCreationException) AddDirectoryTask(org.apache.maven.plugins.assembly.archive.task.AddDirectoryTask) File(java.io.File)

Aggregations

File (java.io.File)1 ArchiveCreationException (org.apache.maven.plugins.assembly.archive.ArchiveCreationException)1 AddDirectoryTask (org.apache.maven.plugins.assembly.archive.task.AddDirectoryTask)1 Repository (org.apache.maven.plugins.assembly.model.Repository)1 RepositoryAssemblyException (org.apache.maven.plugins.assembly.repository.RepositoryAssemblyException)1