Search in sources :

Example 11 with AssemblerConfigurationSource

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

the class AssemblyFormatUtilsTest method testEvalFileNameMapping_ShouldResolveArtifactIdAndBaseVersionInOutDir_UseArtifactInfo_WithValidMainProject.

public void testEvalFileNameMapping_ShouldResolveArtifactIdAndBaseVersionInOutDir_UseArtifactInfo_WithValidMainProject() throws AssemblyFormattingException {
    final MavenProject mainProject = createProject("group", "main", "1", null);
    final String artifactVersion = "2-20070807.112233-1";
    final String artifactBaseVersion = "2-SNAPSHOT";
    final MavenProject artifactProject = createProject("group", "artifact", artifactVersion, null);
    final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", artifactVersion, "jar", true, artifactBaseVersion);
    artifactProject.setArtifact(artifactMock.getArtifact());
    final MavenSession session = mockManager.createMock(MavenSession.class);
    expect(session.getExecutionProperties()).andReturn(null).anyTimes();
    expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
    final AssemblerConfigurationSource cs = mockManager.createMock(AssemblerConfigurationSource.class);
    expect(cs.getMavenSession()).andReturn(session).anyTimes();
    DefaultAssemblyArchiverTest.setupInterpolators(cs);
    mockManager.replayAll();
    final String result = AssemblyFormatUtils.evaluateFileNameMapping("${artifact.artifactId}-${artifact.baseVersion}", artifactMock.getArtifact(), mainProject, null, cs, AssemblyFormatUtils.moduleProjectInterpolator(null), AssemblyFormatUtils.artifactProjectInterpolator(artifactProject));
    /*
        final Artifact artifact = artifactMock.getArtifact();
        final String result =
            AssemblyFormatUtils.evaluateFileNameMapping( "${artifact.artifactId}-${artifact.baseVersion}",
                                                         moduleArtifactInterpolator( null ),
                                                         moduleProjectInterpolator( null ),
                                                         artifactInterpolator( artifact ),
                                                         artifactProjectInterpolator( artifactProject ),
                                                         mainArtifactPropsOnly( mainProject ),
                                                         classifierRules( artifact ),
                                                         FixedStringSearchInterpolator.empty() );

         */
    assertEquals("artifact-2-SNAPSHOT", result);
    mockManager.verifyAll();
    // clear out for next call.
    mockManager.resetAll();
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) MavenProject(org.apache.maven.project.MavenProject) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) AssemblerConfigurationSource(org.apache.maven.plugins.assembly.AssemblerConfigurationSource) Properties(java.util.Properties)

Aggregations

AssemblerConfigurationSource (org.apache.maven.plugins.assembly.AssemblerConfigurationSource)11 EasyMockSupport (org.easymock.classextension.EasyMockSupport)8 Test (org.junit.Test)6 File (java.io.File)4 Properties (java.util.Properties)4 MavenSession (org.apache.maven.execution.MavenSession)4 MavenProject (org.apache.maven.project.MavenProject)4 AssemblyArchiverPhase (org.apache.maven.plugins.assembly.archive.phase.AssemblyArchiverPhase)3 Assembly (org.apache.maven.plugins.assembly.model.Assembly)3 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)2 Model (org.apache.maven.model.Model)2 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)1 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)1 ModuleSet (org.apache.maven.plugins.assembly.model.ModuleSet)1 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)1 NoSuchArchiverException (org.codehaus.plexus.archiver.manager.NoSuchArchiverException)1 ZipArchiver (org.codehaus.plexus.archiver.zip.ZipArchiver)1