use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithSiteDirInclusionFromAssemblyWithoutComponentsOrInterpolation.
public void testReadAssembly_ShouldReadAssemblyWithSiteDirInclusionFromAssemblyWithoutComponentsOrInterpolation() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.setIncludeSiteDirectory(true);
final StringReader sr = writeToStringReader(assembly);
final File siteDir = fileManager.createTempDir();
expect(configSource.getSiteDirectory()).andReturn(siteDir).anyTimes();
final File basedir = fileManager.createTempDir();
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
final Model model = new Model();
model.setGroupId("group");
model.setArtifactId("artifact");
model.setVersion("version");
final MavenProject project = new MavenProject(model);
expect(configSource.getProject()).andReturn(project).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
mockManager.replayAll();
final Assembly result = new DefaultAssemblyReader().readAssembly(sr, "testLocation", null, configSource);
assertEquals(assembly.getId(), result.getId());
final List<FileSet> fileSets = result.getFileSets();
assertEquals(1, fileSets.size());
assertEquals("/site", fileSets.get(0).getOutputDirectory());
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssemblies_ShouldGetAssemblyDescriptorFromDirectory.
public void testReadAssemblies_ShouldGetAssemblyDescriptorFromDirectory() 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();
writeAssembliesToFile(assemblies, basedir);
final List<Assembly> results = performReadAssemblies(basedir, null, null, basedir);
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());
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithComponentWithoutSiteDirInclusionOrInterpolation.
public void testReadAssembly_ShouldReadAssemblyWithComponentWithoutSiteDirInclusionOrInterpolation() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final File componentsFile = fileManager.createTempFile();
final File basedir = componentsFile.getParentFile();
final String componentsFilename = componentsFile.getName();
final Component component = new Component();
final FileSet fs = new FileSet();
fs.setDirectory("/dir");
component.addFileSet(fs);
Writer fw = null;
try {
fw = new OutputStreamWriter(new FileOutputStream(componentsFile), "UTF-8");
new ComponentXpp3Writer().write(fw, component);
fw.close();
fw = null;
} finally {
IOUtil.close(fw);
}
final Assembly assembly = new Assembly();
assembly.setId("test");
assembly.addComponentDescriptor(componentsFilename);
final StringReader sr = writeToStringReader(assembly);
expect(configSource.getBasedir()).andReturn(basedir).anyTimes();
final Model model = new Model();
model.setGroupId("group");
model.setArtifactId("artifact");
model.setVersion("version");
final MavenProject project = new MavenProject(model);
expect(configSource.getProject()).andReturn(project).anyTimes();
DefaultAssemblyArchiverTest.setupInterpolators(configSource);
mockManager.replayAll();
final Assembly result = new DefaultAssemblyReader().readAssembly(sr, "testLocation", null, configSource);
assertEquals(assembly.getId(), result.getId());
final List<FileSet> fileSets = result.getFileSets();
assertEquals(1, fileSets.size());
assertEquals("/dir", fileSets.get(0).getDirectory());
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneContainerDescriptorHandlerToExistingListOfTwo.
// FIXME: Deep merging should take place...
// public void
// testMergeComponentWithAssembly_ShouldMergeOneFileSetToOneOfExistingTwo()
// {
// Assembly assembly = new Assembly();
//
// FileSet fs = new FileSet();
// fs.setDirectory( "/dir" );
// fs.addInclude( "**/test.txt" );
//
// assembly.addFileSet( fs );
//
// fs = new FileSet();
// fs.setDirectory( "/other-dir" );
// assembly.addFileSet( fs );
//
// fs = new FileSet();
// fs.setDirectory( "/dir" );
// fs.addInclude( "**/components.txt" );
//
// Component component = new Component();
//
// component.addFileSet( fs );
//
// new DefaultAssemblyReader().mergeComponentWithAssembly( component,
// assembly );
//
// List<FileSet> fileSets = assembly.getFileSets();
//
// assertNotNull( fileSets );
// assertEquals( 2, fileSets.size() );
//
// FileSet rfs1 = (FileSet) fileSets.get( 0 );
// assertEquals( "/dir", rfs1.getDirectory() );
//
// List includes = rfs1.getIncludes();
//
// assertNotNull( includes );
// assertEquals( 2, includes.size() );
// assertTrue( includes.contains( "**/test.txt" ) );
// assertTrue( includes.contains( "**/components.txt" ) );
//
// FileSet rfs2 = (FileSet) fileSets.get( 1 );
// assertEquals( "/other-dir", rfs2.getDirectory() );
//
// }
public void testMergeComponentWithAssembly_ShouldAddOneContainerDescriptorHandlerToExistingListOfTwo() {
final Assembly assembly = new Assembly();
ContainerDescriptorHandlerConfig cfg = new ContainerDescriptorHandlerConfig();
cfg.setHandlerName("one");
assembly.addContainerDescriptorHandler(cfg);
cfg = new ContainerDescriptorHandlerConfig();
cfg.setHandlerName("two");
assembly.addContainerDescriptorHandler(cfg);
final Component component = new Component();
cfg = new ContainerDescriptorHandlerConfig();
cfg.setHandlerName("three");
component.addContainerDescriptorHandler(cfg);
new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
final List<ContainerDescriptorHandlerConfig> result = assembly.getContainerDescriptorHandlers();
assertNotNull(result);
assertEquals(3, result.size());
final Iterator<ContainerDescriptorHandlerConfig> it = result.iterator();
assertEquals("one", it.next().getHandlerName());
assertEquals("two", it.next().getHandlerName());
assertEquals("three", it.next().getHandlerName());
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class AssemblyInterpolatorTest method testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId.
public void testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
final Model model = new Model();
model.setArtifactId("artifact-id");
model.setGroupId("group.id");
model.setVersion("1");
model.setPackaging("jar");
final Properties props = new Properties();
props.setProperty("groupId", "other.id");
model.setProperties(props);
final PojoConfigSource configSourceStub = new PojoConfigSource();
configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
final Assembly assembly = new Assembly();
assembly.setId("assembly.${groupId}");
final MavenProject project = new MavenProject(model);
configSourceStub.setMavenProject(project);
final Assembly result = roundTripInterpolation(assembly, configSourceStub);
assertEquals("assembly.other.id", result.getId());
}
Aggregations