use of org.apache.maven.plugins.assembly.model.DependencySet in project maven-plugins by apache.
the class AddDependencySetsTaskTest method testAddDependencySet_ShouldInterpolateDefaultOutputFileNameMapping.
public void testAddDependencySet_ShouldInterpolateDefaultOutputFileNameMapping() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, IOException {
final String outDir = "tmp/";
final String mainAid = "main";
final String mainGid = "org.maingrp";
final String mainVer = "9";
final String depAid = "dep";
final String depGid = "org.depgrp";
final String depVer = "1";
final String depExt = "war";
final DependencySet ds = new DependencySet();
ds.setOutputDirectory(outDir);
ds.setDirectoryMode(Integer.toString(10, 8));
ds.setFileMode(Integer.toString(10, 8));
final Model mainModel = new Model();
mainModel.setArtifactId(mainAid);
mainModel.setGroupId(mainGid);
mainModel.setVersion(mainVer);
final MavenProject mainProject = new MavenProject(mainModel);
final ArtifactMock mainArtifactMock = new ArtifactMock(mockManager, mainGid, mainAid, mainVer, "jar", false);
mainProject.setArtifact(mainArtifactMock.getArtifact());
final Model depModel = new Model();
depModel.setArtifactId(depAid);
depModel.setGroupId(depGid);
depModel.setVersion(depVer);
depModel.setPackaging(depExt);
final MavenProject depProject = new MavenProject(depModel);
final ArtifactMock depArtifactMock = new ArtifactMock(mockManager, depGid, depAid, depVer, depExt, false);
final File newFile = depArtifactMock.setNewFile();
depProject.setArtifact(depArtifactMock.getArtifact());
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, mainProject);
macTask.expectBuildFromRepository(depProject);
macTask.expectCSGetFinalName(mainAid + "-" + mainVer);
macTask.expectCSGetRepositories(null, null);
macTask.expectGetDestFile(new File("junk"));
macTask.expectAddFile(newFile, outDir + depAid + "-" + depVer + "." + depExt, 10);
// macTask.expectGetSession( null );
macTask.expectGetMode(0222, 0222);
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mockManager.replayAll();
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(depArtifactMock.getArtifact()), depProject, macTask.projectBuilder, logger);
task.addDependencySet(ds, macTask.archiver, macTask.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.DependencySet in project maven-plugins by apache.
the class AddDependencySetsTaskTest method verifyOneDependencyAdded.
private void verifyOneDependencyAdded(final String outputLocation, final boolean unpack) throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException {
final MavenProject project = new MavenProject(new Model());
final DependencySet ds = new DependencySet();
ds.setOutputDirectory(outputLocation);
ds.setOutputFileNameMapping("artifact");
ds.setUnpack(unpack);
ds.setScope(Artifact.SCOPE_COMPILE);
ds.setDirectoryMode(Integer.toString(10, 8));
ds.setFileMode(Integer.toString(10, 8));
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, new MavenProject(new Model()));
final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
final File artifactFile = artifactMock.setNewFile();
if (unpack) {
macTask.expectAddArchivedFileSet();
// macTask.expectModeChange( -1, -1, 10, 10, 2 );
} else {
macTask.expectAddFile(artifactFile, outputLocation + "/artifact", 10);
}
macTask.expectGetDestFile(new File("junk"));
macTask.expectCSGetFinalName("final-name");
macTask.expectCSGetRepositories(null, null);
final MavenProject depProject = new MavenProject(new Model());
macTask.expectBuildFromRepository(depProject);
macTask.expectGetMode(0222, 0222);
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(artifactMock.getArtifact()), project, macTask.projectBuilder, logger);
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mockManager.replayAll();
task.addDependencySet(ds, macTask.archiver, macTask.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.DependencySet in project maven-plugins by apache.
the class AddDependencySetsTaskTest method testAddDependencySet_ShouldNotAddDependenciesWhenProjectIsStubbed.
// TODO: Find a better way of testing the project-stubbing behavior when a ProjectBuildingException takes place.
public void testAddDependencySet_ShouldNotAddDependenciesWhenProjectIsStubbed() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, IOException {
final MavenProject project = new MavenProject(new Model());
final ProjectBuildingException pbe = new ProjectBuildingException("test", "Test error.", new Throwable());
final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, new MavenProject(new Model()));
final String gid = "org.test";
final String aid = "test-dep";
final String version = "2.0-SNAPSHOT";
final String type = "jar";
final File file = new File("dep-artifact.jar");
final ArtifactMock depMock = new ArtifactMock(mockManager, gid, aid, version, type, true);
depMock.setBaseVersion(version);
depMock.setFile(file);
final File destFile = new File("assembly-dep-set.zip");
macTask.expectGetDestFile(destFile);
macTask.expectBuildFromRepository(pbe);
macTask.expectCSGetRepositories(null, null);
macTask.expectCSGetFinalName("final-name");
macTask.expectAddFile(file, "out/" + aid + "-" + version + "." + type);
macTask.expectGetMode(0222, 0222);
final DependencySet ds = new DependencySet();
ds.setOutputDirectory("/out");
DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
mockManager.replayAll();
final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(depMock.getArtifact()), project, macTask.projectBuilder, logger);
task.addDependencySet(ds, macTask.archiver, macTask.configSource);
mockManager.verifyAll();
}
use of org.apache.maven.plugins.assembly.model.DependencySet in project maven-plugins by apache.
the class DefaultAssemblyReader method mergeComponentWithAssembly.
/**
* Add the content of a single Component to main assembly
*
* @param component The component
* @param assembly The assembly
*/
protected void mergeComponentWithAssembly(final Component component, final Assembly assembly) {
final List<ContainerDescriptorHandlerConfig> containerHandlerDescriptors = component.getContainerDescriptorHandlers();
for (final ContainerDescriptorHandlerConfig cfg : containerHandlerDescriptors) {
assembly.addContainerDescriptorHandler(cfg);
}
final List<DependencySet> dependencySetList = component.getDependencySets();
for (final DependencySet dependencySet : dependencySetList) {
assembly.addDependencySet(dependencySet);
}
final List<FileSet> fileSetList = component.getFileSets();
for (final FileSet fileSet : fileSetList) {
assembly.addFileSet(fileSet);
}
final List<FileItem> fileList = component.getFiles();
for (final FileItem fileItem : fileList) {
assembly.addFile(fileItem);
}
final List<Repository> repositoriesList = component.getRepositories();
for (final Repository repository : repositoriesList) {
assembly.addRepository(repository);
}
final List<ModuleSet> moduleSets = component.getModuleSets();
for (final ModuleSet moduleSet : moduleSets) {
assembly.addModuleSet(moduleSet);
}
}
use of org.apache.maven.plugins.assembly.model.DependencySet in project maven-plugins by apache.
the class DefaultDependencyResolver method resolveDependencySets.
@Override
public Map<DependencySet, Set<Artifact>> resolveDependencySets(final Assembly assembly, final AssemblerConfigurationSource configSource, List<DependencySet> dependencySets) throws DependencyResolutionException {
Map<DependencySet, Set<Artifact>> result = new LinkedHashMap<DependencySet, Set<Artifact>>();
for (DependencySet dependencySet : dependencySets) {
final MavenProject currentProject = configSource.getProject();
final ResolutionManagementInfo info = new ResolutionManagementInfo(currentProject);
updateRepositoryResolutionRequirements(assembly, info);
final AssemblyId assemblyId = AssemblyId.createAssemblyId(assembly);
updateDependencySetResolutionRequirements(dependencySet, info, assemblyId, configSource.getMavenSession().getProjectBuildingRequest(), currentProject);
resolve(assembly, configSource, result, dependencySet, info);
}
return result;
}
Aggregations