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());
}
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());
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testReadAssembly_ShouldReadAssemblyWithComponentInterpolationWithoutSiteDirInclusionOrAssemblyInterpolation.
public void testReadAssembly_ShouldReadAssemblyWithComponentInterpolationWithoutSiteDirInclusionOrAssemblyInterpolation() 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("${groupId}-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).atLeastOnce();
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).atLeastOnce();
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("group-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 testReadAssembly_ShouldReadAssemblyWithInterpolationWithoutComponentsOrSiteDirInclusion.
public void testReadAssembly_ShouldReadAssemblyWithInterpolationWithoutComponentsOrSiteDirInclusion() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
final Assembly assembly = new Assembly();
assembly.setId("${groupId}-assembly");
final Assembly result = doReadAssembly(assembly);
assertEquals("group-assembly", result.getId());
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class DefaultAssemblyReaderTest method testMergeComponentWithAssembly_ShouldAddOneDependencySetToExistingListOfTwo.
public void testMergeComponentWithAssembly_ShouldAddOneDependencySetToExistingListOfTwo() {
final Assembly assembly = new Assembly();
DependencySet ds = new DependencySet();
ds.setScope(Artifact.SCOPE_RUNTIME);
assembly.addDependencySet(ds);
ds = new DependencySet();
ds.setScope(Artifact.SCOPE_COMPILE);
assembly.addDependencySet(ds);
final Component component = new Component();
ds = new DependencySet();
ds.setScope(Artifact.SCOPE_SYSTEM);
component.addDependencySet(ds);
new DefaultAssemblyReader().mergeComponentWithAssembly(component, assembly);
final List<DependencySet> depSets = assembly.getDependencySets();
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());
}
Aggregations