Search in sources :

Example 6 with PojoConfigSource

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

the class AssemblyInterpolatorTest method testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId.

public void testShouldResolveModelPropertyBeforeModelGroupIdInAssemblyId() 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 PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    final Assembly assembly = new Assembly();
    assembly.setId("assembly.${groupId}");
    final MavenProject project = new MavenProject(model);
    configSourceStub.setMavenProject(project);
    final Assembly result = roundTripInterpolation(assembly, configSourceStub);
    assertEquals("assembly.other.id", result.getId());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Properties(java.util.Properties) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 7 with PojoConfigSource

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

the class AssemblyInterpolatorTest method testDependencySetOutputDirectoryIsNotInterpolated.

public void testDependencySetOutputDirectoryIsNotInterpolated() throws IOException, AssemblyInterpolationException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final Assembly assembly = new Assembly();
    final String outputDirectory = "${artifactId}.${packaging}";
    final DependencySet set = new DependencySet();
    set.setOutputDirectory(outputDirectory);
    assembly.addDependencySet(set);
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    final MavenProject project = new MavenProject(model);
    configSourceStub.setMavenProject(project);
    final Assembly outputAssembly = roundTripInterpolation(assembly, configSourceStub);
    final List<DependencySet> outputDependencySets = outputAssembly.getDependencySets();
    assertEquals(1, outputDependencySets.size());
    final DependencySet outputSet = outputDependencySets.get(0);
    assertEquals("${artifactId}.${packaging}", outputSet.getOutputDirectory());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 8 with PojoConfigSource

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

the class ReaderFormatterTest method lineUnixFeedWithInterpolation.

@Test
public void lineUnixFeedWithInterpolation() throws IOException, AssemblyFormattingException {
    final PojoConfigSource cfg = getPojoConfigSource();
    InputStreamTransformer fileSetTransformers = ReaderFormatter.getFileSetTransformers(cfg, true, "unix");
    InputStream fud = fileSetTransformers.transform(dummyResource(), payload("This is a test for project: ${artifactId} @artifactId@."));
    assertEquals("This is a test for project: anArtifact anArtifact.", readResultStream(fud));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InputStreamTransformer(org.codehaus.plexus.components.io.functions.InputStreamTransformer) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Test(org.junit.Test)

Example 9 with PojoConfigSource

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

the class AssemblyInterpolatorTest method testShouldResolveModelGroupIdInAssemblyId.

public void testShouldResolveModelGroupIdInAssemblyId() 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.${groupId}");
    final MavenProject project = new MavenProject(model);
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setMavenProject(project);
    final Assembly outputAssembly = roundTripInterpolation(assembly, configSourceStub);
    assertEquals("assembly.group.id", outputAssembly.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 10 with PojoConfigSource

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

the class AssemblyInterpolatorTest method testDependencySetOutputFileNameMappingsAreNotInterpolated.

public void testDependencySetOutputFileNameMappingsAreNotInterpolated() throws IOException, AssemblyInterpolationException, AssemblyReadException, InvalidAssemblerConfigurationException {
    final Model model = new Model();
    model.setArtifactId("artifact-id");
    model.setGroupId("group.id");
    model.setVersion("1");
    model.setPackaging("jar");
    final MavenProject project = new MavenProject(model);
    final Assembly assembly = new Assembly();
    // artifactId is blacklisted, but packaging is not.
    final String outputFileNameMapping = "${artifactId}.${packaging}";
    final DependencySet set = new DependencySet();
    set.setOutputFileNameMapping(outputFileNameMapping);
    assembly.addDependencySet(set);
    final PojoConfigSource configSourceStub = new PojoConfigSource();
    configSourceStub.setRootInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setEnvironmentInterpolator(FixedStringSearchInterpolator.create());
    configSourceStub.setMavenProject(project);
    final Assembly outputAssembly = roundTripInterpolation(assembly, configSourceStub);
    final List<DependencySet> outputDependencySets = outputAssembly.getDependencySets();
    assertEquals(1, outputDependencySets.size());
    final DependencySet outputSet = outputDependencySets.get(0);
    assertEquals("${artifactId}.${packaging}", outputSet.getOutputFileNameMapping());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) PojoConfigSource(org.apache.maven.plugins.assembly.testutils.PojoConfigSource) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

PojoConfigSource (org.apache.maven.plugins.assembly.testutils.PojoConfigSource)11 Model (org.apache.maven.model.Model)7 Assembly (org.apache.maven.plugins.assembly.model.Assembly)7 MavenProject (org.apache.maven.project.MavenProject)7 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 InputStreamTransformer (org.codehaus.plexus.components.io.functions.InputStreamTransformer)3 Test (org.junit.Test)3 Properties (java.util.Properties)2 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)2 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1 MavenSession (org.apache.maven.execution.MavenSession)1 Build (org.apache.maven.model.Build)1 DefaultMavenReaderFilter (org.apache.maven.shared.filtering.DefaultMavenReaderFilter)1 PropertiesBasedValueSource (org.codehaus.plexus.interpolation.fixed.PropertiesBasedValueSource)1 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)1 EasyMockSupport (org.easymock.classextension.EasyMockSupport)1