Search in sources :

Example 6 with DependencySet

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

the class ModuleSetAssemblyPhase method getDependencySets.

public static List<DependencySet> getDependencySets(final ModuleBinaries binaries) {
    List<DependencySet> depSets = binaries.getDependencySets();
    if (((depSets == null) || depSets.isEmpty()) && binaries.isIncludeDependencies()) {
        final DependencySet impliedDependencySet = new DependencySet();
        impliedDependencySet.setOutputDirectory(binaries.getOutputDirectory());
        //impliedDependencySet.setOutputFileNameMapping( binaries.getOutputFileNameMapping() );
        impliedDependencySet.setFileMode(binaries.getFileMode());
        impliedDependencySet.setDirectoryMode(binaries.getDirectoryMode());
        impliedDependencySet.setExcludes(binaries.getExcludes());
        impliedDependencySet.setIncludes(binaries.getIncludes());
        impliedDependencySet.setUnpack(binaries.isUnpack());
        // unpackOptions is handled in the first stage of dependency-set handling, below.
        depSets = Collections.singletonList(impliedDependencySet);
    }
    return depSets;
}
Also used : DependencySet(org.apache.maven.plugins.assembly.model.DependencySet)

Example 7 with DependencySet

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, 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 8 with DependencySet

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

the class AddDependencySetsTaskTest method testGetDependencyArtifacts_ShouldFilterOneDependencyArtifactViaInclude.

public void testGetDependencyArtifacts_ShouldFilterOneDependencyArtifactViaInclude() throws ArchiveCreationException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final Set<Artifact> artifacts = new HashSet<Artifact>();
    final ArtifactMock am = new ArtifactMock(mockManager, "group", "artifact", "1.0", "jar", false);
    am.setDependencyTrail(Collections.singletonList(project.getId()));
    artifacts.add(am.getArtifact());
    final ArtifactMock am2 = new ArtifactMock(mockManager, "group2", "artifact2", "1.0", "jar", false);
    am2.setDependencyTrail(Collections.singletonList(project.getId()));
    artifacts.add(am2.getArtifact());
    final DependencySet dependencySet = new DependencySet();
    dependencySet.addInclude("group:artifact");
    dependencySet.setUseTransitiveFiltering(true);
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    mockManager.replayAll();
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySet), artifacts, project, null, logger);
    final Set<Artifact> result = task.resolveDependencyArtifacts(dependencySet);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertSame(am.getArtifact(), result.iterator().next());
    mockManager.verifyAll();
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) Artifact(org.apache.maven.artifact.Artifact) HashSet(java.util.HashSet) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 9 with DependencySet

use of org.apache.maven.plugins.assembly.model.DependencySet 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());
}
Also used : AssemblyInterpolator(org.apache.maven.plugins.assembly.interpolation.AssemblyInterpolator) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) List(java.util.List) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 10 with DependencySet

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

the class DefaultDependencyResolverTest method test_getDependencySetResolutionRequirements.

public void test_getDependencySetResolutionRequirements() throws DependencyResolutionException {
    final DependencySet ds1 = new DependencySet();
    ds1.setScope(Artifact.SCOPE_COMPILE);
    ds1.setUseTransitiveDependencies(false);
    final DependencySet ds2 = new DependencySet();
    ds2.setScope(Artifact.SCOPE_SYSTEM);
    ds2.setUseTransitiveDependencies(false);
    final MavenProject project = createMavenProject("main-group", "main-artifact", "1", null);
    final ResolutionManagementInfo info = new ResolutionManagementInfo(project);
    final Assembly assembly = new Assembly();
    ProjectBuildingRequest buildingRequest = newMavenSession(project).getProjectBuildingRequest();
    resolver.updateDependencySetResolutionRequirements(ds1, info, AssemblyId.createAssemblyId(assembly), buildingRequest, project);
    assertTrue(info.isResolutionRequired());
    assertFalse(info.isResolvedTransitively());
    assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_COMPILE));
    assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_SYSTEM));
    assertTrue(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_PROVIDED));
    assertFalse(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_RUNTIME));
    assertFalse(info.getScopeFilter().getIncluded().contains(Artifact.SCOPE_TEST));
}
Also used : ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) DefaultProjectBuildingRequest(org.apache.maven.project.DefaultProjectBuildingRequest) MavenProject(org.apache.maven.project.MavenProject) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)21 MavenProject (org.apache.maven.project.MavenProject)16 Model (org.apache.maven.model.Model)11 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)10 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)8 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)8 Logger (org.codehaus.plexus.logging.Logger)8 Assembly (org.apache.maven.plugins.assembly.model.Assembly)7 File (java.io.File)6 Artifact (org.apache.maven.artifact.Artifact)6 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 LinkedHashSet (java.util.LinkedHashSet)3 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 AddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.AddDependencySetsTask)2 FileSet (org.apache.maven.plugins.assembly.model.FileSet)2 AssemblyId (org.apache.maven.plugins.assembly.resolved.AssemblyId)2 PojoConfigSource (org.apache.maven.plugins.assembly.testutils.PojoConfigSource)2