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