Search in sources :

Example 16 with Assembly

use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testIncludeSiteInAssembly_ShouldFailIfSiteDirectoryNonExistent.

public void testIncludeSiteInAssembly_ShouldFailIfSiteDirectoryNonExistent() throws IOException {
    final File siteDir = File.createTempFile("assembly-reader.", ".test");
    siteDir.delete();
    expect(configSource.getSiteDirectory()).andReturn(siteDir).anyTimes();
    final Assembly assembly = new Assembly();
    mockManager.replayAll();
    try {
        new DefaultAssemblyReader().includeSiteInAssembly(assembly, configSource);
        fail("Should fail when site directory is non-existent.");
    } catch (final InvalidAssemblerConfigurationException e) {
    // this should happen.
    }
    mockManager.verifyAll();
}
Also used : InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 17 with Assembly

use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testReadAssemblies_ShouldGetAssemblyDescriptorFromFileArray.

public void testReadAssemblies_ShouldGetAssemblyDescriptorFromFileArray() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final Assembly assembly1 = new Assembly();
    assembly1.setId("test");
    final Assembly assembly2 = new Assembly();
    assembly2.setId("test2");
    final List<Assembly> assemblies = new ArrayList<Assembly>();
    assemblies.add(assembly1);
    assemblies.add(assembly2);
    final File basedir = fileManager.createTempDir();
    final List<String> files = writeAssembliesToFile(assemblies, basedir);
    final List<Assembly> results = performReadAssemblies(basedir, files.toArray(new String[files.size()]), null, null);
    assertNotNull(results);
    assertEquals(2, results.size());
    final Assembly result1 = assemblies.get(0);
    assertEquals(assembly1.getId(), result1.getId());
    final Assembly result2 = assemblies.get(1);
    assertEquals(assembly2.getId(), result2.getId());
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 18 with Assembly

use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method performReadAssemblies.

private List<Assembly> performReadAssemblies(final File basedir, final String[] descriptors, final String[] descriptorRefs, final File descriptorDir, final boolean ignoreMissing) throws AssemblyReadException, InvalidAssemblerConfigurationException {
    expect(configSource.getDescriptorReferences()).andReturn(descriptorRefs);
    expect(configSource.getDescriptors()).andReturn(descriptors);
    expect(configSource.getDescriptorSourceDirectory()).andReturn(descriptorDir);
    expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
    expect(configSource.getProject()).andReturn(new MavenProject(new Model())).anyTimes();
    expect(configSource.isIgnoreMissingDescriptor()).andReturn(ignoreMissing).anyTimes();
    DefaultAssemblyArchiverTest.setupInterpolators(configSource);
    mockManager.replayAll();
    final List<Assembly> assemblies = new DefaultAssemblyReader().readAssemblies(configSource);
    mockManager.verifyAll();
    return assemblies;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 19 with Assembly

use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithoutComponentsInterpolationOrSiteDirInclusion.

public void testReadAssembly_ShouldReadAssemblyWithoutComponentsInterpolationOrSiteDirInclusion() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final Assembly result = doReadAssembly(assembly);
    assertEquals(assembly.getId(), result.getId());
    mockManager.verifyAll();
}
Also used : Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 20 with Assembly

use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testGetAssemblyForDescriptorReference_ShouldReadBinaryAssemblyRef.

public void testGetAssemblyForDescriptorReference_ShouldReadBinaryAssemblyRef() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final File basedir = fileManager.createTempDir();
    expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
    expect(configSource.getProject()).andReturn(new MavenProject(new Model())).anyTimes();
    expect(configSource.isIgnoreMissingDescriptor()).andReturn(false).anyTimes();
    DefaultAssemblyArchiverTest.setupInterpolators(configSource);
    mockManager.replayAll();
    final Assembly result = new DefaultAssemblyReader().getAssemblyForDescriptorReference("bin", configSource);
    assertEquals("bin", result.getId());
    mockManager.verifyAll();
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

Assembly (org.apache.maven.plugins.assembly.model.Assembly)56 File (java.io.File)29 MavenProject (org.apache.maven.project.MavenProject)28 Model (org.apache.maven.model.Model)21 EasyMockSupport (org.easymock.classextension.EasyMockSupport)13 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)12 FileSet (org.apache.maven.plugins.assembly.model.FileSet)9 ArrayList (java.util.ArrayList)8 Component (org.apache.maven.plugins.assembly.model.Component)8 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)7 PojoConfigSource (org.apache.maven.plugins.assembly.testutils.PojoConfigSource)7 FileItem (org.apache.maven.plugins.assembly.model.FileItem)6 FileOutputStream (java.io.FileOutputStream)5 IOException (java.io.IOException)5 OutputStreamWriter (java.io.OutputStreamWriter)5 StringWriter (java.io.StringWriter)5 Writer (java.io.Writer)5 AssemblyXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer)5 ComponentXpp3Reader (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader)5 ComponentXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer)5