Search in sources :

Example 91 with MavenProject

use of org.apache.maven.project.MavenProject in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleArtifact_ShouldAddOneArtifact.

public void testAddModuleArtifact_ShouldAddOneArtifact() throws AssemblyFormattingException, IOException, ArchiveCreationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "type", false);
    final File artifactFile = artifactMock.setNewFile();
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.setArtifact(artifactMock.getArtifact());
    macTask.expectGetFinalName("final-name");
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectGetMode(0222, 0222);
    macTask.expectAddFile(artifactFile, "out/artifact", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    final ModuleBinaries binaries = new ModuleBinaries();
    binaries.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).addModuleArtifact(artifactMock.getArtifact(), project, macTask.archiver, macTask.configSource, binaries);
    mm.verifyAll();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) ModuleBinaries(org.apache.maven.plugins.assembly.model.ModuleBinaries) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 92 with MavenProject

use of org.apache.maven.project.MavenProject in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps.

public void testAddModuleBinaries_ShouldAddOneModuleArtifactAndNoDeps() throws ArchiveCreationException, AssemblyFormattingException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
    final File artifactFile = artifactMock.setNewFile();
    macTask.expectGetFinalName("final-name");
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectAddFile(artifactFile, "out/artifact", TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test")));
    macTask.expectGetMode(0222, 0222);
    final ModuleBinaries binaries = new ModuleBinaries();
    binaries.setIncludeDependencies(false);
    binaries.setUnpack(false);
    binaries.setFileMode("777");
    binaries.setOutputDirectory("out");
    binaries.setOutputFileNameMapping("artifact");
    final MavenProject project = createProject("group", "artifact", "version", null);
    project.setArtifact(artifactMock.getArtifact());
    final Set<MavenProject> projects = singleton(project);
    macTask.expectResolveDependencySets();
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    createPhase(logger, macTask.dependencyResolver, null).addModuleBinaries(null, null, binaries, projects, macTask.archiver, macTask.configSource);
    mm.verifyAll();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) ModuleBinaries(org.apache.maven.plugins.assembly.model.ModuleBinaries) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) File(java.io.File)

Example 93 with MavenProject

use of org.apache.maven.project.MavenProject in project maven-plugins by apache.

the class AbstractResolveMojo method getPluginArtifactsFilter.

protected FilterArtifacts getPluginArtifactsFilter() {
    if (excludeReactor) {
        final StringBuilder exAids = new StringBuilder();
        if (this.excludeArtifactIds != null) {
            exAids.append(this.excludeArtifactIds);
        }
        for (final MavenProject rp : reactorProjects) {
            if (!"maven-plugin".equals(rp.getPackaging())) {
                continue;
            }
            if (exAids.length() > 0) {
                exAids.append(",");
            }
            exAids.append(rp.getArtifactId());
        }
        this.excludeArtifactIds = exAids.toString();
    }
    final FilterArtifacts filter = new FilterArtifacts();
    filter.addFilter(new org.apache.maven.shared.artifact.filter.collection.ScopeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeScope), DependencyUtil.cleanToBeTokenizedString(this.excludeScope)));
    filter.addFilter(new TypeFilter(DependencyUtil.cleanToBeTokenizedString(this.includeTypes), DependencyUtil.cleanToBeTokenizedString(this.excludeTypes)));
    filter.addFilter(new ClassifierFilter(DependencyUtil.cleanToBeTokenizedString(this.includeClassifiers), DependencyUtil.cleanToBeTokenizedString(this.excludeClassifiers)));
    filter.addFilter(new GroupIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeGroupIds), DependencyUtil.cleanToBeTokenizedString(this.excludeGroupIds)));
    filter.addFilter(new ArtifactIdFilter(DependencyUtil.cleanToBeTokenizedString(this.includeArtifactIds), DependencyUtil.cleanToBeTokenizedString(this.excludeArtifactIds)));
    return filter;
}
Also used : ArtifactIdFilter(org.apache.maven.shared.artifact.filter.collection.ArtifactIdFilter) MavenProject(org.apache.maven.project.MavenProject) ClassifierFilter(org.apache.maven.shared.artifact.filter.collection.ClassifierFilter) FilterArtifacts(org.apache.maven.shared.artifact.filter.collection.FilterArtifacts) TypeFilter(org.apache.maven.shared.artifact.filter.collection.TypeFilter) GroupIdFilter(org.apache.maven.shared.artifact.filter.collection.GroupIdFilter)

Example 94 with MavenProject

use of org.apache.maven.project.MavenProject in project maven-plugins by apache.

the class CompilerMojoTestCase method getMockMavenProject.

private MavenProject getMockMavenProject() {
    MavenProject mp = new MavenProject();
    mp.getBuild().setDirectory("target");
    mp.getBuild().setOutputDirectory("target/classes");
    mp.getBuild().setSourceDirectory("src/main/java");
    mp.getBuild().setTestOutputDirectory("target/test-classes");
    return mp;
}
Also used : MavenProject(org.apache.maven.project.MavenProject)

Example 95 with MavenProject

use of org.apache.maven.project.MavenProject in project maven-plugins by apache.

the class DisplayAncestorsMojo method collectAncestors.

private ArrayList<String> collectAncestors() {
    final ArrayList<String> ancestors = new ArrayList<String>();
    MavenProject currentAncestor = project.getParent();
    while (currentAncestor != null) {
        final String gav = String.format(Locale.US, "%s:%s:%s", currentAncestor.getGroupId(), currentAncestor.getArtifactId(), currentAncestor.getVersion());
        ancestors.add(gav);
        currentAncestor = currentAncestor.getParent();
    }
    return ancestors;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList)

Aggregations

MavenProject (org.apache.maven.project.MavenProject)297 File (java.io.File)138 Artifact (org.apache.maven.artifact.Artifact)66 ArrayList (java.util.ArrayList)64 Model (org.apache.maven.model.Model)57 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)36 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)33 IOException (java.io.IOException)29 Assembly (org.apache.maven.plugins.assembly.model.Assembly)28 EasyMockSupport (org.easymock.classextension.EasyMockSupport)27 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)20 Test (org.junit.Test)17 HashMap (java.util.HashMap)16 HashSet (java.util.HashSet)16 MavenSession (org.apache.maven.execution.MavenSession)16 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)16 ProjectBuildingException (org.apache.maven.project.ProjectBuildingException)16 LinkedHashSet (java.util.LinkedHashSet)15 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)15 FileSet (org.apache.maven.plugins.assembly.model.FileSet)15