Search in sources :

Example 1 with Overlay

use of org.apache.maven.plugins.war.Overlay in project maven-plugins by apache.

the class WarZipTest method testOneZipWithForceSkip.

public void testOneZipWithForceSkip() throws Exception {
    File webAppDirectory = configureMojo("one-zip-overlay-skip");
    Overlay overlay = new DefaultOverlay(buildZipArtifact());
    overlay.setSkip(true);
    overlay.setType("zip");
    mojo.addOverlay(overlay);
    mojo.execute();
    assertZipContentNotHere(webAppDirectory);
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) File(java.io.File)

Example 2 with Overlay

use of org.apache.maven.plugins.war.Overlay in project maven-plugins by apache.

the class OverlayManagerTest method testSimpleOverlay.

public void testSimpleOverlay() throws Exception {
    final MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    final ArtifactStub first = newWarArtifact("test", "test-webapp");
    project.addArtifact(first);
    final List<Overlay> overlays = new ArrayList<Overlay>();
    overlays.add(new DefaultOverlay(first));
    try {
        final Overlay currentProjectOverlay = Overlay.createInstance();
        OverlayManager manager = new OverlayManager(overlays, project, DEFAULT_INCLUDES, DEFAULT_EXCLUDES, currentProjectOverlay);
        assertNotNull(manager.getOverlays());
        assertEquals(2, manager.getOverlays().size());
        assertEquals(Overlay.createInstance(), manager.getOverlays().get(0));
        assertEquals(overlays.get(0), manager.getOverlays().get(1));
    } catch (InvalidOverlayConfigurationException e) {
        e.printStackTrace();
        fail("Should not have failed to validate a valid overlay config " + e.getMessage());
    }
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) OverlayManager(org.apache.maven.plugins.war.overlay.OverlayManager) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) InvalidOverlayConfigurationException(org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)

Example 3 with Overlay

use of org.apache.maven.plugins.war.Overlay in project maven-plugins by apache.

the class OverlayManagerTest method testOverlaysWithSameArtifactAndGroupId.

public void testOverlaysWithSameArtifactAndGroupId() throws Exception {
    final MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
    final ArtifactStub first = newWarArtifact("test", "test-webapp");
    final ArtifactStub second = newWarArtifact("test", "test-webapp", "my-classifier");
    project.addArtifact(first);
    project.addArtifact(second);
    final List<Overlay> overlays = new ArrayList<Overlay>();
    overlays.add(new DefaultOverlay(first));
    overlays.add(new DefaultOverlay(second));
    try {
        final Overlay currentProjectOverlay = Overlay.createInstance();
        OverlayManager manager = new OverlayManager(overlays, project, DEFAULT_INCLUDES, DEFAULT_EXCLUDES, currentProjectOverlay);
        assertNotNull(manager.getOverlays());
        assertEquals(3, manager.getOverlays().size());
        assertEquals(currentProjectOverlay, manager.getOverlays().get(0));
        assertEquals(overlays.get(0), manager.getOverlays().get(1));
        assertEquals(overlays.get(1), manager.getOverlays().get(2));
    } catch (InvalidOverlayConfigurationException e) {
        e.printStackTrace();
        fail("Should not have failed to validate a valid overlay config " + e.getMessage());
    }
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) OverlayManager(org.apache.maven.plugins.war.overlay.OverlayManager) MavenProjectArtifactsStub(org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) WarArtifactStub(org.apache.maven.plugins.war.stub.WarArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) InvalidOverlayConfigurationException(org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)

Example 4 with Overlay

use of org.apache.maven.plugins.war.Overlay in project maven-plugins by apache.

the class WarOverlaysTest method testCacheWithRemovedOverlay.

public void testCacheWithRemovedOverlay() throws Exception {
    // setup test data
    final String testId = "cache-removed-overlay";
    // Add an overlay
    final ArtifactStub overlay = buildWarOverlayStub("overlay-one");
    final ArtifactStub overlay2 = buildWarOverlayStub("overlay-two");
    final File webAppDirectory = setUpMojo(testId, new ArtifactStub[] { overlay, overlay2 });
    final List<File> assertedFiles = new ArrayList<File>();
    try {
        // Use the cache
        setVariableValueToObject(mojo, "useCache", Boolean.TRUE);
        setVariableValueToObject(mojo, "cacheFile", new File(mojo.getWorkDirectory(), "cache.xml"));
        final LinkedList<Overlay> overlays = new LinkedList<Overlay>();
        overlays.add(new DefaultOverlay(overlay));
        overlays.add(new DefaultOverlay(overlay2));
        mojo.setOverlays(overlays);
        mojo.execute();
        // Now remove overlay one the right file is overwritten
        final LinkedList<Overlay> updatedOverlays = new LinkedList<Overlay>();
        updatedOverlays.add(new DefaultOverlay(overlay2));
        mojo.setOverlays(updatedOverlays);
        // Remove overlay one as a dep
        mojo.getProject().getArtifacts().remove(overlay);
        mojo.execute();
        assertedFiles.addAll(assertDefaultContent(webAppDirectory));
        assertedFiles.addAll(assertWebXml(webAppDirectory));
        assertedFiles.addAll(assertCustomContent(webAppDirectory, new String[] { "index.jsp", "login.jsp", "admin.jsp" }, "overlay file not found"));
        // index and login come from overlay2 now
        assertOverlayedFile(webAppDirectory, "overlay-two", "index.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-one", "login.jsp");
        assertOverlayedFile(webAppDirectory, "overlay-two", "admin.jsp");
        // Ok now check that there is no more files/directories
        final FileFilter filter = new FileFilterImpl(webAppDirectory, new String[] { MANIFEST_PATH });
        assertWebAppContent(webAppDirectory, assertedFiles, filter);
    } finally {
        cleanDirectory(webAppDirectory);
    }
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) FileFilter(java.io.FileFilter) File(java.io.File) LinkedList(java.util.LinkedList)

Example 5 with Overlay

use of org.apache.maven.plugins.war.Overlay in project maven-plugins by apache.

the class WarOverlaysTest method testScenarioOneWithFullSettings.

/**
     * Tests that specifying the overlay explicitely has the same behavior as the default (i.e. order, etc).
     * 
     * The default project is explicitely specified so this should match the default.
     *
     * @throws Exception if an error occurs
     */
public void testScenarioOneWithFullSettings() throws Exception {
    // setup test data
    final String testId = "scenario-one-full-settings";
    // Add an overlay
    final ArtifactStub overlay1 = buildWarOverlayStub("overlay-full-1");
    final ArtifactStub overlay2 = buildWarOverlayStub("overlay-full-2");
    final ArtifactStub overlay3 = buildWarOverlayStub("overlay-full-3");
    final File webAppDirectory = setUpMojo(testId, new ArtifactStub[] { overlay1, overlay2, overlay3 }, new String[] { "org/sample/company/test.jsp", "jsp/b.jsp" });
    // Add the tags
    final List<Overlay> overlays = new ArrayList<Overlay>();
    // Add the default project explicitely
    overlays.add(mojo.getCurrentProjectOverlay());
    // Other overlays
    overlays.add(new DefaultOverlay(overlay1));
    overlays.add(new DefaultOverlay(overlay2));
    overlays.add(new DefaultOverlay(overlay3));
    mojo.setOverlays(overlays);
    // current project ignored. Should be on top of the list
    assertScenariOne(testId, webAppDirectory);
}
Also used : DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) ArrayList(java.util.ArrayList) ArtifactStub(org.apache.maven.plugin.testing.stubs.ArtifactStub) Overlay(org.apache.maven.plugins.war.Overlay) DefaultOverlay(org.apache.maven.plugins.war.overlay.DefaultOverlay) File(java.io.File)

Aggregations

Overlay (org.apache.maven.plugins.war.Overlay)16 DefaultOverlay (org.apache.maven.plugins.war.overlay.DefaultOverlay)15 ArrayList (java.util.ArrayList)13 ArtifactStub (org.apache.maven.plugin.testing.stubs.ArtifactStub)11 File (java.io.File)9 InvalidOverlayConfigurationException (org.apache.maven.plugins.war.overlay.InvalidOverlayConfigurationException)6 OverlayManager (org.apache.maven.plugins.war.overlay.OverlayManager)6 MavenProjectArtifactsStub (org.apache.maven.plugins.war.stub.MavenProjectArtifactsStub)6 WarArtifactStub (org.apache.maven.plugins.war.stub.WarArtifactStub)5 FileFilter (java.io.FileFilter)4 LinkedList (java.util.LinkedList)2 Artifact (org.apache.maven.artifact.Artifact)1