@Test( expected = InvalidAssemblerConfigurationException.class ) public void failWhenAssemblyIdIsNull() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException { final EasyMockSupport mm = new EasyMockSupport(); final MockAndControlForAssemblyArchiver macMgr = new MockAndControlForAssemblyArchiver( mm ); final AssemblerConfigurationSource configSource = mm.createControl().createMock( AssemblerConfigurationSource.class ); mm.replayAll(); final DefaultAssemblyArchiver archiver = createSubject( macMgr, null, null ); archiver.createArchive( new Assembly(), "full-name", "zip", configSource, false, null ); mm.verifyAll(); }
@Override public File createArchive( final Assembly assembly, final String fullName, final String format, final AssemblerConfigurationSource configSource, boolean recompressZippedFiles, String mergeManifestMode ) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException { validate( assembly ); String filename = fullName; if ( !configSource.isIgnoreDirFormatExtensions() || !format.startsWith( "dir" ) ) { filename += "." + format; } AssemblyFileUtils.verifyTempDirectoryAvailability( configSource.getTemporaryRootDirectory() ); final File outputDirectory = configSource.getOutputDirectory(); final File destFile = new File( outputDirectory, filename ); try { final String finalName = configSource.getFinalName(); final String specifiedBasedir = assembly.getBaseDirectory(); String basedir = finalName; if ( specifiedBasedir != null ) { basedir = AssemblyFormatUtils.getOutputDirectory( specifiedBasedir, finalName, configSource, AssemblyFormatUtils.moduleProjectInterpolator( configSource.getProject() ), AssemblyFormatUtils.artifactProjectInterpolator( null ) ); } final List<ContainerDescriptorHandler> containerHandlers = selectContainerDescriptorHandlers( assembly.getContainerDescriptorHandlers(), configSource ); final Archiver archiver = createArchiver( format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers, recompressZippedFiles, mergeManifestMode ); archiver.setDestFile( destFile ); for ( AssemblyArchiverPhase phase : sortedPhases() ) { phase.execute( assembly, archiver, configSource ); } archiver.createArchive(); } catch ( final ArchiverException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final IOException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final NoSuchArchiverException e ) { throw new ArchiveCreationException( "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'", e ); } catch ( final DependencyResolutionException e ) { throw new ArchiveCreationException( "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e ); } return destFile; }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { @Override public File createArchive( final Assembly assembly, final String fullName, final String format, final AssemblerConfigurationSource configSource, boolean recompressZippedFiles, String mergeManifestMode ) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException { validate( assembly ); String filename = fullName; if ( !configSource.isIgnoreDirFormatExtensions() || !format.startsWith( "dir" ) ) { filename += "." + format; } AssemblyFileUtils.verifyTempDirectoryAvailability( configSource.getTemporaryRootDirectory() ); final File outputDirectory = configSource.getOutputDirectory(); final File destFile = new File( outputDirectory, filename ); try { final String finalName = configSource.getFinalName(); final String specifiedBasedir = assembly.getBaseDirectory(); String basedir = finalName; if ( specifiedBasedir != null ) { basedir = AssemblyFormatUtils.getOutputDirectory( specifiedBasedir, finalName, configSource, AssemblyFormatUtils.moduleProjectInterpolator( configSource.getProject() ), AssemblyFormatUtils.artifactProjectInterpolator( null ) ); } final List<ContainerDescriptorHandler> containerHandlers = selectContainerDescriptorHandlers( assembly.getContainerDescriptorHandlers(), configSource ); final Archiver archiver = createArchiver( format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers, recompressZippedFiles, mergeManifestMode ); archiver.setDestFile( destFile ); for ( AssemblyArchiverPhase phase : sortedPhases() ) { phase.execute( assembly, archiver, configSource ); } archiver.createArchive(); } catch ( final ArchiverException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final IOException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final NoSuchArchiverException e ) { throw new ArchiveCreationException( "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'", e ); } catch ( final DependencyResolutionException e ) { throw new ArchiveCreationException( "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e ); } return destFile; } }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { @Override public File createArchive( final Assembly assembly, final String fullName, final String format, final AssemblerConfigurationSource configSource, boolean recompressZippedFiles, String mergeManifestMode ) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException { validate( assembly ); String filename = fullName; if ( !configSource.isIgnoreDirFormatExtensions() || !format.startsWith( "dir" ) ) { filename += "." + format; } AssemblyFileUtils.verifyTempDirectoryAvailability( configSource.getTemporaryRootDirectory() ); final File outputDirectory = configSource.getOutputDirectory(); final File destFile = new File( outputDirectory, filename ); try { final String finalName = configSource.getFinalName(); final String specifiedBasedir = assembly.getBaseDirectory(); String basedir = finalName; if ( specifiedBasedir != null ) { basedir = AssemblyFormatUtils.getOutputDirectory( specifiedBasedir, finalName, configSource, AssemblyFormatUtils.moduleProjectInterpolator( configSource.getProject() ), AssemblyFormatUtils.artifactProjectInterpolator( null ) ); } final List<ContainerDescriptorHandler> containerHandlers = selectContainerDescriptorHandlers( assembly.getContainerDescriptorHandlers(), configSource ); final Archiver archiver = createArchiver( format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers, recompressZippedFiles, mergeManifestMode ); archiver.setDestFile( destFile ); for ( AssemblyArchiverPhase phase : sortedPhases() ) { phase.execute( assembly, archiver, configSource ); } archiver.createArchive(); } catch ( final ArchiverException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final IOException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final NoSuchArchiverException e ) { throw new ArchiveCreationException( "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'", e ); } catch ( final DependencyResolutionException e ) { throw new ArchiveCreationException( "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e ); } return destFile; } @SuppressWarnings( "UnusedDeclaration" )  DefaultAssemblyArchiver(); protected  DefaultAssemblyArchiver( final ArchiverManager archiverManager,
                                       final List<AssemblyArchiverPhase> assemblyPhases ); }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { @Override public File createArchive( final Assembly assembly, final String fullName, final String format, final AssemblerConfigurationSource configSource, boolean recompressZippedFiles, String mergeManifestMode ) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException { validate( assembly ); String filename = fullName; if ( !configSource.isIgnoreDirFormatExtensions() || !format.startsWith( "dir" ) ) { filename += "." + format; } AssemblyFileUtils.verifyTempDirectoryAvailability( configSource.getTemporaryRootDirectory() ); final File outputDirectory = configSource.getOutputDirectory(); final File destFile = new File( outputDirectory, filename ); try { final String finalName = configSource.getFinalName(); final String specifiedBasedir = assembly.getBaseDirectory(); String basedir = finalName; if ( specifiedBasedir != null ) { basedir = AssemblyFormatUtils.getOutputDirectory( specifiedBasedir, finalName, configSource, AssemblyFormatUtils.moduleProjectInterpolator( configSource.getProject() ), AssemblyFormatUtils.artifactProjectInterpolator( null ) ); } final List<ContainerDescriptorHandler> containerHandlers = selectContainerDescriptorHandlers( assembly.getContainerDescriptorHandlers(), configSource ); final Archiver archiver = createArchiver( format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers, recompressZippedFiles, mergeManifestMode ); archiver.setDestFile( destFile ); for ( AssemblyArchiverPhase phase : sortedPhases() ) { phase.execute( assembly, archiver, configSource ); } archiver.createArchive(); } catch ( final ArchiverException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final IOException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final NoSuchArchiverException e ) { throw new ArchiveCreationException( "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'", e ); } catch ( final DependencyResolutionException e ) { throw new ArchiveCreationException( "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e ); } return destFile; } @SuppressWarnings( "UnusedDeclaration" )  DefaultAssemblyArchiver(); protected  DefaultAssemblyArchiver( final ArchiverManager archiverManager,
                                       final List<AssemblyArchiverPhase> assemblyPhases ); @Override File createArchive( final Assembly assembly, final String fullName, final String format,
                               final AssemblerConfigurationSource configSource, boolean recompressZippedFiles,
                               String mergeManifestMode ); @Override void contextualize( final Context context ); }
DefaultAssemblyArchiver extends AbstractLogEnabled implements AssemblyArchiver, Contextualizable { @Override public File createArchive( final Assembly assembly, final String fullName, final String format, final AssemblerConfigurationSource configSource, boolean recompressZippedFiles, String mergeManifestMode ) throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException { validate( assembly ); String filename = fullName; if ( !configSource.isIgnoreDirFormatExtensions() || !format.startsWith( "dir" ) ) { filename += "." + format; } AssemblyFileUtils.verifyTempDirectoryAvailability( configSource.getTemporaryRootDirectory() ); final File outputDirectory = configSource.getOutputDirectory(); final File destFile = new File( outputDirectory, filename ); try { final String finalName = configSource.getFinalName(); final String specifiedBasedir = assembly.getBaseDirectory(); String basedir = finalName; if ( specifiedBasedir != null ) { basedir = AssemblyFormatUtils.getOutputDirectory( specifiedBasedir, finalName, configSource, AssemblyFormatUtils.moduleProjectInterpolator( configSource.getProject() ), AssemblyFormatUtils.artifactProjectInterpolator( null ) ); } final List<ContainerDescriptorHandler> containerHandlers = selectContainerDescriptorHandlers( assembly.getContainerDescriptorHandlers(), configSource ); final Archiver archiver = createArchiver( format, assembly.isIncludeBaseDirectory(), basedir, configSource, containerHandlers, recompressZippedFiles, mergeManifestMode ); archiver.setDestFile( destFile ); for ( AssemblyArchiverPhase phase : sortedPhases() ) { phase.execute( assembly, archiver, configSource ); } archiver.createArchive(); } catch ( final ArchiverException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final IOException e ) { throw new ArchiveCreationException( "Error creating assembly archive " + assembly.getId() + ": " + e.getMessage(), e ); } catch ( final NoSuchArchiverException e ) { throw new ArchiveCreationException( "Unable to obtain archiver for extension '" + format + "', for assembly: '" + assembly.getId() + "'", e ); } catch ( final DependencyResolutionException e ) { throw new ArchiveCreationException( "Unable to resolve dependencies for assembly '" + assembly.getId() + "'", e ); } return destFile; } @SuppressWarnings( "UnusedDeclaration" )  DefaultAssemblyArchiver(); protected  DefaultAssemblyArchiver( final ArchiverManager archiverManager,
                                       final List<AssemblyArchiverPhase> assemblyPhases ); @Override File createArchive( final Assembly assembly, final String fullName, final String format,
                               final AssemblerConfigurationSource configSource, boolean recompressZippedFiles,
                               String mergeManifestMode ); @Override void contextualize( final Context context );  }