Search in sources :

Example 1 with AssemblyXpp3Writer

use of org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method writeToStringReader.

public static StringReader writeToStringReader(Assembly assembly) throws IOException {
    final StringWriter sw = new StringWriter();
    final AssemblyXpp3Writer assemblyWriter = new AssemblyXpp3Writer();
    assemblyWriter.write(sw, assembly);
    return new StringReader(sw.toString());
}
Also used : StringWriter(java.io.StringWriter) AssemblyXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer) StringReader(java.io.StringReader)

Example 2 with AssemblyXpp3Writer

use of org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method testGetAssemblyFromDescriptorFile_ShouldReadAssembly.

public void testGetAssemblyFromDescriptorFile_ShouldReadAssembly() 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 assemblyFile = fileManager.createTempFile();
    final File basedir = assemblyFile.getParentFile();
    expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
    expect(configSource.getProject()).andReturn(new MavenProject(new Model())).anyTimes();
    DefaultAssemblyArchiverTest.setupInterpolators(configSource);
    Writer writer = null;
    try {
        writer = new OutputStreamWriter(new FileOutputStream(assemblyFile), "UTF-8");
        new AssemblyXpp3Writer().write(writer, assembly);
        writer.close();
        writer = null;
    } finally {
        IOUtil.close(writer);
    }
    mockManager.replayAll();
    final Assembly result = new DefaultAssemblyReader().getAssemblyFromDescriptorFile(assemblyFile, configSource);
    assertEquals(assembly.getId(), result.getId());
    mockManager.verifyAll();
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) MavenProject(org.apache.maven.project.MavenProject) AssemblyXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer) FileOutputStream(java.io.FileOutputStream) Model(org.apache.maven.model.Model) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly) 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)

Example 3 with AssemblyXpp3Writer

use of org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer in project maven-plugins by apache.

the class DefaultAssemblyReaderTest method writeAssembliesToFile.

private List<String> writeAssembliesToFile(final List<Assembly> assemblies, final File dir) throws IOException {
    final List<String> files = new ArrayList<String>();
    for (final Assembly assembly : assemblies) {
        final File assemblyFile = new File(dir, assembly.getId() + ".xml");
        Writer writer = null;
        try {
            writer = new OutputStreamWriter(new FileOutputStream(assemblyFile), "UTF-8");
            new AssemblyXpp3Writer().write(writer, assembly);
            writer.close();
            writer = null;
        } finally {
            IOUtil.close(writer);
        }
        files.add(assemblyFile.getAbsolutePath());
    }
    return files;
}
Also used : AssemblyXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer) FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly) 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)

Example 4 with AssemblyXpp3Writer

use of org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer in project maven-plugins by apache.

the class DefaultAssemblyReader method debugPrintAssembly.

private void debugPrintAssembly(final String message, final Assembly assembly) {
    final StringWriter sWriter = new StringWriter();
    try {
        new AssemblyXpp3Writer().write(sWriter, assembly);
    } catch (final IOException e) {
        getLogger().debug("Failed to print debug message with assembly descriptor listing, and message: " + message, e);
    }
    getLogger().debug(message + "\n\n" + sWriter.toString() + "\n\n");
}
Also used : StringWriter(java.io.StringWriter) AssemblyXpp3Writer(org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer) IOException(java.io.IOException)

Aggregations

StringWriter (java.io.StringWriter)4 AssemblyXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer)4 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Writer (java.io.Writer)2 Assembly (org.apache.maven.plugins.assembly.model.Assembly)2 ComponentXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer)2 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 Model (org.apache.maven.model.Model)1 FileSet (org.apache.maven.plugins.assembly.model.FileSet)1 MavenProject (org.apache.maven.project.MavenProject)1