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);
}
}
Aggregations