Search in sources :

Example 46 with Assembly

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

the class DefaultAssemblyReaderTest method testReadAssemblies_ShouldGetAssemblyDescriptorFromMultipleRefs.

public void testReadAssemblies_ShouldGetAssemblyDescriptorFromMultipleRefs() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final File basedir = fileManager.createTempDir();
    final List<Assembly> assemblies = performReadAssemblies(basedir, null, new String[] { "bin", "src" }, null);
    assertNotNull(assemblies);
    assertEquals(2, assemblies.size());
    final Assembly result = assemblies.get(0);
    assertEquals("bin", result.getId());
    final Assembly result2 = assemblies.get(1);
    assertEquals("src", result2.getId());
}
Also used : File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 47 with Assembly

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

the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneFileSetToExistingListOfTwo.

public void testMergeComponentWithAssembly_ShouldAddOneFileSetToExistingListOfTwo() {
    final Assembly assembly = new Assembly();
    FileSet fs = new FileSet();
    fs.setDirectory("/dir");
    assembly.addFileSet(fs);
    fs = new FileSet();
    fs.setDirectory("/other-dir");
    assembly.addFileSet(fs);
    fs = new FileSet();
    fs.setDirectory("/third-dir");
    final Component component = new Component();
    component.addFileSet(fs);
    new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
    final List<FileSet> fileSets = assembly.getFileSets();
    assertNotNull(fileSets);
    assertEquals(3, fileSets.size());
    final FileSet rfs1 = fileSets.get(0);
    assertEquals("/dir", rfs1.getDirectory());
    final FileSet rfs2 = fileSets.get(1);
    assertEquals("/other-dir", rfs2.getDirectory());
    final FileSet rfs3 = fileSets.get(2);
    assertEquals("/third-dir", rfs3.getDirectory());
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) Component(org.apache.maven.plugins.assembly.model.Component) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 48 with Assembly

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

the class DefaultAssemblyReaderTest method testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly.

public void testMergeComponentsWithMainAssembly_ShouldAddOneFileSetToAssembly() throws IOException, AssemblyReadException {
    final Component component = new Component();
    final FileSet fileSet = new FileSet();
    fileSet.setDirectory("/dir");
    component.addFileSet(fileSet);
    final File componentFile = fileManager.createTempFile();
    Writer writer = null;
    try {
        writer = new OutputStreamWriter(new FileOutputStream(componentFile), "UTF-8");
        final ComponentXpp3Writer componentWriter = new ComponentXpp3Writer();
        componentWriter.write(writer, component);
        writer.close();
        writer = null;
    } finally {
        IOUtil.close(writer);
    }
    final String filename = componentFile.getName();
    final Assembly assembly = new Assembly();
    assembly.addComponentDescriptor(filename);
    final File basedir = componentFile.getParentFile();
    final MavenProject project = new MavenProject();
    expect(configSource.getProject()).andReturn(project).anyTimes();
    expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
    DefaultAssemblyArchiverTest.setupInterpolators(configSource);
    InterpolationState is = new InterpolationState();
    ComponentXpp3Reader.ContentTransformer componentIp = AssemblyInterpolator.componentInterpolator(FixedStringSearchInterpolator.create(), is, new ConsoleLogger(Logger.LEVEL_DEBUG, "console"));
    mockManager.replayAll();
    new DefaultAssemblyReader().mergeComponentsWithMainAssembly(assembly, null, configSource, componentIp);
    final List<FileSet> fileSets = assembly.getFileSets();
    assertNotNull(fileSets);
    assertEquals(1, fileSets.size());
    final FileSet fs = fileSets.get(0);
    assertEquals("/dir", fs.getDirectory());
    mockManager.verifyAll();
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) MavenProject(org.apache.maven.project.MavenProject) ComponentXpp3Reader(org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader) InterpolationState(org.codehaus.plexus.interpolation.fixed.InterpolationState) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) FileOutputStream(java.io.FileOutputStream) ComponentXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer) OutputStreamWriter(java.io.OutputStreamWriter) Component(org.apache.maven.plugins.assembly.model.Component) File(java.io.File) OutputStreamWriter(java.io.OutputStreamWriter) StringWriter(java.io.StringWriter) AssemblyXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer) Writer(java.io.Writer) ComponentXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 49 with Assembly

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

the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneRepositoryToExistingListOfTwo.

public void testMergeComponentWithAssembly_ShouldAddOneRepositoryToExistingListOfTwo() {
    final Assembly assembly = new Assembly();
    Repository repo = new Repository();
    repo.setScope(Artifact.SCOPE_RUNTIME);
    assembly.addRepository(repo);
    repo = new Repository();
    repo.setScope(Artifact.SCOPE_COMPILE);
    assembly.addRepository(repo);
    final Component component = new Component();
    repo = new Repository();
    repo.setScope(Artifact.SCOPE_SYSTEM);
    component.addRepository(repo);
    new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
    final List<Repository> depSets = assembly.getRepositories();
    assertNotNull(depSets);
    assertEquals(3, depSets.size());
    assertEquals(Artifact.SCOPE_RUNTIME, depSets.get(0).getScope());
    assertEquals(Artifact.SCOPE_COMPILE, depSets.get(1).getScope());
    assertEquals(Artifact.SCOPE_SYSTEM, depSets.get(2).getScope());
}
Also used : ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Repository(org.apache.maven.plugins.assembly.model.Repository) Component(org.apache.maven.plugins.assembly.model.Component) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 50 with Assembly

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

the class DefaultAssemblyReaderTest method testReadAssemblies_ShouldGetAssemblyDescriptorFromSingleFile.

public void testReadAssemblies_ShouldGetAssemblyDescriptorFromSingleFile() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final FileSet fs = new FileSet();
    fs.setDirectory("/dir");
    assembly.addFileSet(fs);
    final File basedir = fileManager.createTempDir();
    final List<String> files = writeAssembliesToFile(Collections.singletonList(assembly), basedir);
    final String assemblyFile = files.get(0);
    final List<Assembly> assemblies = performReadAssemblies(basedir, new String[] { assemblyFile }, null, null);
    assertNotNull(assemblies);
    assertEquals(1, assemblies.size());
    final Assembly result = assemblies.get(0);
    assertEquals(assembly.getId(), result.getId());
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) 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