Search in sources :

Example 1 with ModuleSet

use of org.apache.maven.plugins.assembly.model.ModuleSet in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively.

public void testGetModuleProjects_ShouldExcludeModuleAndDescendentsTransitively() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    addArtifact(project, mm, false);
    final MavenProject project2 = createProject("group", "artifact2", "version", project);
    addArtifact(project2, mm, false);
    final MavenProject project3 = createProject("group", "artifact3", "version", project2);
    addArtifact(project3, mm, true);
    final List<MavenProject> projects = new ArrayList<MavenProject>();
    projects.add(project);
    projects.add(project2);
    projects.add(project3);
    macTask.expectGetReactorProjects(projects);
    final ModuleSet moduleSet = new ModuleSet();
    moduleSet.setIncludeSubModules(true);
    moduleSet.addExclude("group:artifact2");
    mm.replayAll();
    final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
    assertTrue(moduleProjects.isEmpty());
    mm.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet)

Example 2 with ModuleSet

use of org.apache.maven.plugins.assembly.model.ModuleSet in project maven-plugins by apache.

the class DefaultDependencyResolver method resolveDependencySets.

@Override
public Map<DependencySet, Set<Artifact>> resolveDependencySets(final Assembly assembly, ModuleSet moduleSet, 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);
        updateModuleSetResolutionRequirements(assemblyId, moduleSet, dependencySet, info, configSource);
        resolve(assembly, configSource, result, dependencySet, info);
    }
    return result;
}
Also used : ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) MavenProject(org.apache.maven.project.MavenProject) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) AssemblyId(org.apache.maven.plugins.assembly.resolved.AssemblyId) Artifact(org.apache.maven.artifact.Artifact) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with ModuleSet

use of org.apache.maven.plugins.assembly.model.ModuleSet in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldReturnDescendentModulesOfCurrentProject.

public void testGetModuleProjects_ShouldReturnDescendentModulesOfCurrentProject() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    final MavenProject project2 = createProject("group", "artifact2", "version", project);
    final MavenProject project3 = createProject("group", "artifact3", "version", project2);
    final List<MavenProject> projects = new ArrayList<MavenProject>();
    projects.add(project);
    projects.add(project2);
    projects.add(project3);
    macTask.expectGetReactorProjects(projects);
    final ModuleSet moduleSet = new ModuleSet();
    moduleSet.setIncludeSubModules(true);
    mm.replayAll();
    final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
    assertEquals(2, moduleProjects.size());
    final List<MavenProject> check = new ArrayList<MavenProject>();
    check.add(project2);
    check.add(project3);
    verifyResultIs(check, moduleProjects);
    mm.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet)

Example 4 with ModuleSet

use of org.apache.maven.plugins.assembly.model.ModuleSet 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();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ModuleBinaries(org.apache.maven.plugins.assembly.model.ModuleBinaries) ArrayList(java.util.ArrayList) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 5 with ModuleSet

use of org.apache.maven.plugins.assembly.model.ModuleSet in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testGetModuleProjects_ShouldReturnNothingWhenReactorContainsTwoSiblingProjects.

public void testGetModuleProjects_ShouldReturnNothingWhenReactorContainsTwoSiblingProjects() throws ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenProject project = createProject("group", "artifact", "version", null);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    final MavenProject project2 = createProject("group", "artifact2", "version", null);
    final List<MavenProject> projects = new ArrayList<MavenProject>();
    projects.add(project);
    projects.add(project2);
    macTask.expectGetReactorProjects(projects);
    final ModuleSet moduleSet = new ModuleSet();
    moduleSet.setIncludeSubModules(true);
    mm.replayAll();
    final Set<MavenProject> moduleProjects = ModuleSetAssemblyPhase.getModuleProjects(moduleSet, macTask.configSource, logger);
    assertTrue(moduleProjects.isEmpty());
    mm.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) ModuleSet(org.apache.maven.plugins.assembly.model.ModuleSet)

Aggregations

ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)10 MavenProject (org.apache.maven.project.MavenProject)9 EasyMockSupport (org.easymock.classextension.EasyMockSupport)7 ArrayList (java.util.ArrayList)6 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)5 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)4 File (java.io.File)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 Artifact (org.apache.maven.artifact.Artifact)2 Assembly (org.apache.maven.plugins.assembly.model.Assembly)2 FileSet (org.apache.maven.plugins.assembly.model.FileSet)2 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)2 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)1 InvalidAssemblerConfigurationException (org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException)1