use of org.apache.maven.plugins.assembly.model.Assembly 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.Assembly in project maven-plugins by apache.
the class AssemblyInterpolatorTest method testShouldResolveModelGroupIdInAssemblyId.
public void testShouldResolveModelGroupIdInAssemblyId() 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 Assembly assembly = new Assembly();
assembly.setId("assembly.${groupId}");
final MavenProject project = new MavenProject(model);
final PojoConfigSource configSourceStub = new PojoConfigSource();
configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
configSourceStub.setMavenProject(project);
final Assembly outputAssembly = roundTripInterpolation(assembly, configSourceStub);
assertEquals("assembly.group.id", outputAssembly.getId());
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class AssemblyInterpolatorTest method testDependencySetOutputFileNameMappingsAreNotInterpolated.
public void testDependencySetOutputFileNameMappingsAreNotInterpolated() 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 MavenProject project = new MavenProject(model);
final Assembly assembly = new Assembly();
// artifactId is blacklisted, but packaging is not.
final String outputFileNameMapping = "${artifactId}.${packaging}";
final DependencySet set = new DependencySet();
set.setOutputFileNameMapping(outputFileNameMapping);
assembly.addDependencySet(set);
final PojoConfigSource configSourceStub = new PojoConfigSource();
configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
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.getOutputFileNameMapping());
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testExecute_ShouldSkipIfNoModuleSetsFound.
public void testExecute_ShouldSkipIfNoModuleSetsFound() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException, DependencyResolutionException {
final Assembly assembly = new Assembly();
assembly.setIncludeBaseDirectory(false);
createPhase(null, null).execute(assembly, null, null);
}
use of org.apache.maven.plugins.assembly.model.Assembly in project maven-plugins by apache.
the class ModuleSetAssemblyPhaseTest method testExecute_ShouldAddOneModuleSetWithOneModuleInIt.
public void testExecute_ShouldAddOneModuleSetWithOneModuleInIt() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
final EasyMockSupport mm = new EasyMockSupport();
final MavenProject project = createProject("group", "artifact", "version", null);
final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, project);
final MavenProject module = createProject("group", "module", "version", project);
final ArtifactMock moduleArtifactMock = new ArtifactMock(mm, "group", "module", "version", "jar", false);
final File moduleArtifactFile = moduleArtifactMock.setNewFile();
module.setArtifact(moduleArtifactMock.getArtifact());
final List<MavenProject> projects = new ArrayList<MavenProject>();
projects.add(module);
macTask.expectGetReactorProjects(projects);
macTask.expectGetFinalName("final-name");
macTask.expectGetDestFile(new File("junk"));
macTask.expectGetMode(0777, 0777);
final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
macTask.expectAddFile(moduleArtifactFile, "out/artifact", mode);
final Assembly assembly = new Assembly();
assembly.setIncludeBaseDirectory(false);
final ModuleSet ms = new ModuleSet();
final ModuleBinaries bin = new ModuleBinaries();
bin.setOutputFileNameMapping("artifact");
bin.setOutputDirectory("out");
bin.setFileMode("777");
bin.setUnpack(false);
bin.setIncludeDependencies(false);
ms.setBinaries(bin);
assembly.addModuleSet(ms);
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
macTask.expectResolveDependencySets();
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mm.replayAll();
final ModuleSetAssemblyPhase phase = createPhase(logger, macTask.dependencyResolver, null);
phase.execute(assembly, macTask.archiver, macTask.configSource);
mm.verifyAll();
}
Aggregations