use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class AssemblyInterpolator2Test method testDependencyOutputFileNameMappingsAreNotInterpolated.
public void testDependencyOutputFileNameMappingsAreNotInterpolated() throws IOException, AssemblyInterpolationException {
AssemblyInterpolator interpolator = new AssemblyInterpolator();
Model model = new Model();
model.setArtifactId("artifact-id");
model.setGroupId("group.id");
model.setVersion("1");
Assembly assembly = new Assembly();
DependencySet set = new DependencySet();
set.setOutputFileNameMapping("${artifact.artifactId}.${artifact.extension}");
assembly.addDependencySet(set);
Assembly outputAssembly = interpolator.interpolate(assembly, model, Collections.EMPTY_MAP, DefaultAssemblyReader.create(model));
List outputDependencySets = outputAssembly.getDependencySets();
assertEquals(1, outputDependencySets.size());
DependencySet outputSet = (DependencySet) outputDependencySets.get(0);
assertEquals(set.getOutputFileNameMapping(), outputSet.getOutputFileNameMapping());
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class AssemblyInterpolatorTest method testDependencySetOutputDirectoryIsNotInterpolated.
public void testDependencySetOutputDirectoryIsNotInterpolated() throws IOException, AssemblyInterpolationException, AssemblyReadException, InvalidAssemblerConfigurationException {
final Model model = new Model();
model.setArtifactId("artifact-id");
model.setGroupId("group.id");
model.setVersion("1");
model.setPackaging("jar");
final Assembly assembly = new Assembly();
final String outputDirectory = "${artifactId}.${packaging}";
final DependencySet set = new DependencySet();
set.setOutputDirectory(outputDirectory);
assembly.addDependencySet(set);
final PojoConfigSource configSourceStub = new PojoConfigSource();
configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
final MavenProject project = new MavenProject(model);
configSourceStub.setMavenProject(project);
final Assembly outputAssembly = roundTripInterpolation(assembly, configSourceStub);
final List<DependencySet> outputDependencySets = outputAssembly.getDependencySets();
assertEquals(1, outputDependencySets.size());
final DependencySet outputSet = outputDependencySets.get(0);
assertEquals("${artifactId}.${packaging}", outputSet.getOutputDirectory());
}
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());
}
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());
}
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();
}
Aggregations