Search in sources :

Example 21 with Assembly

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

the class DefaultAssemblyReaderTest method testReadAssemblies_ShouldGetTwoAssemblyDescriptorsFromDirectoryWithThreeFiles.

public void testReadAssemblies_ShouldGetTwoAssemblyDescriptorsFromDirectoryWithThreeFiles() throws IOException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final Assembly assembly1 = new Assembly();
    assembly1.setId("test");
    final Assembly assembly2 = new Assembly();
    assembly2.setId("test2");
    final List<Assembly> assemblies = new ArrayList<Assembly>();
    assemblies.add(assembly1);
    assemblies.add(assembly2);
    final File basedir = fileManager.createTempDir();
    writeAssembliesToFile(assemblies, basedir);
    fileManager.createFile(basedir, "readme.txt", "This is just a readme file, not a descriptor.");
    final List<Assembly> results = performReadAssemblies(basedir, null, null, basedir);
    assertNotNull(results);
    assertEquals(2, results.size());
    final Assembly result1 = assemblies.get(0);
    assertEquals(assembly1.getId(), result1.getId());
    final Assembly result2 = assemblies.get(1);
    assertEquals(assembly2.getId(), result2.getId());
}
Also used : ArrayList(java.util.ArrayList) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 22 with Assembly

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

the class AssemblyInterpolatorTest method testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId.

public void testShouldResolveContextValueBeforeModelPropertyOrModelGroupIdInAssemblyId() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Properties props = new Properties();
    props.setProperty("groupId", "other.id");
    model.setProperties(props);
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${groupId}");
    final EasyMockSupport mm = new EasyMockSupport();
    final MavenSession session = mm.createMock(MavenSession.class);
    final Properties execProps = new Properties();
    execProps.setProperty("groupId", "still.another.id");
    expect(session.getExecutionProperties()).andReturn(execProps).anyTimes();
    expect(session.getUserProperties()).andReturn(new Properties()).anyTimes();
    final PojoConfigSource cs = new PojoConfigSource();
    final ArtifactRepository lr = mm.createMock(ArtifactRepository.class);
    cs.setLocalRepository(lr);
    cs.setMavenSession(session);
    cs.setRootInterpolator(FixedStringSearchInterpolator.create());
    cs.setEnvironmentInterpolator(FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(execProps)));
    cs.setEnvInterpolator(FixedStringSearchInterpolator.empty());
    expect(lr.getBasedir()).andReturn("/path/to/local/repo").anyTimes();
    mm.replayAll();
    final MavenProject project = new MavenProject(model);
    cs.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, cs);
    assertEquals("assembly.still.another.id", result.getId());
    mm.verifyAll();
    mm.resetAll();
}
Also used : MavenSession(org.apache.maven.execution.MavenSession) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Properties(java.util.Properties) PropertiesBasedValueSource(org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 23 with Assembly

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

the class AssemblyInterpolatorTest method testShouldNotTouchUnresolvedExpression.

public void testShouldNotTouchUnresolvedExpression() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${unresolved}");
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    final MavenProject project = new MavenProject(model);
    configSourceStub.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, configSourceStub);
    assertEquals("assembly.${unresolved}", result.getId());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 24 with Assembly

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

the class DefaultDependencyResolverTest method test_getRepositoryResolutionRequirements.

public void test_getRepositoryResolutionRequirements() {
    final List<Repository> repositories = new ArrayList<Repository>();
    {
        final Repository r = new Repository();
        r.setScope(Artifact.SCOPE_COMPILE);
        repositories.add(r);
    }
    {
        final Repository r = new Repository();
        r.setScope(Artifact.SCOPE_SYSTEM);
        repositories.add(r);
    }
    final MavenProject project = createMavenProject("group", "artifact", "1.0", null);
    final Assembly assembly = new Assembly();
    assembly.setRepositories(repositories);
    final ResolutionManagementInfo info = new ResolutionManagementInfo(project);
    resolver.updateRepositoryResolutionRequirements(assembly, info);
    assertTrue(info.isResolutionRequired());
    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 : ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) Repository(org.apache.maven.plugins.assembly.model.Repository) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 25 with Assembly

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

the class AssemblyInterpolatorTest method testShouldInterpolateMultiDotProjectExpression.

public void testShouldInterpolateMultiDotProjectExpression() throws AssemblyInterpolationException, InvalidAssemblerConfigurationException, AssemblyReadException, IOException {
    final Build build = new Build();
    build.setFinalName("final-name");
    final Model model = new Model();
    model.setBuild(build);
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${project.build.finalName}");
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    final MavenProject project = new MavenProject(model);
    configSourceStub.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, configSourceStub);
    assertEquals("assembly.final-name", result.getId());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Build(org.apache.maven.model.Build) Model(org.apache.maven.model.Model) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

Assembly (org.apache.maven.plugins.assembly.model.Assembly)56 File (java.io.File)29 MavenProject (org.apache.maven.project.MavenProject)28 Model (org.apache.maven.model.Model)21 EasyMockSupport (org.easymock.classextension.EasyMockSupport)13 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)12 FileSet (org.apache.maven.plugins.assembly.model.FileSet)9 ArrayList (java.util.ArrayList)8 Component (org.apache.maven.plugins.assembly.model.Component)8 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)7 PojoConfigSource (org.apache.maven.plugins.assembly.testutils.PojoConfigSource)7 FileItem (org.apache.maven.plugins.assembly.model.FileItem)6 FileOutputStream (java.io.FileOutputStream)5 IOException (java.io.IOException)5 OutputStreamWriter (java.io.OutputStreamWriter)5 StringWriter (java.io.StringWriter)5 Writer (java.io.Writer)5 AssemblyXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer)5 ComponentXpp3Reader (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Reader)5 ComponentXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer)5