sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-maven-launchpad-plugin] 08/49: SLING-1364 - creating prepare-test-webapp mojo
Date Tue, 07 Nov 2017 09:14:51 GMT
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag maven-launchpad-plugin-2.0.10
in repository https://gitbox.apache.org/repos/asf/sling-maven-launchpad-plugin.git

commit 8ffdfb1a86bc6563ac4b487037f6e5e3d946e2ba
Author: Justin Edelson <justin@apache.org>
AuthorDate: Wed Feb 17 03:56:20 2010 +0000

    SLING-1364 - creating prepare-test-webapp mojo
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/maven/maven-launchpad-plugin@910814
13f79535-47bb-0310-9956-ffa450edef68
---
 .../maven/projectsupport/PreparePackageMojo.java   |  4 +-
 .../projectsupport/PrepareTestWebAppMojo.java      | 91 ++++++++++++++++++++++
 2 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java b/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
index 5972e34..55629db 100644
--- a/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
+++ b/src/main/java/org/apache/sling/maven/projectsupport/PreparePackageMojo.java
@@ -166,7 +166,7 @@ public class PreparePackageMojo extends AbstractLaunchpadFrameworkMojo
{
 				base.getGroupId() + ":" + base.getArtifactId());
 	}
 
-	private File getOutputDirectory() {
+	protected File getOutputDirectory() {
 		if (WAR.equals(packaging)) {
 			return warOutputDirectory;
 		} else {
@@ -174,7 +174,7 @@ public class PreparePackageMojo extends AbstractLaunchpadFrameworkMojo
{
 		}
 	}
 
-	private void unpackBaseArtifact() throws MojoExecutionException {
+	protected void unpackBaseArtifact() throws MojoExecutionException {
 		Artifact artifact = getBaseDependency();
 		if (artifact == null) {
 			throw new MojoExecutionException(
diff --git a/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
b/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
new file mode 100644
index 0000000..229c894
--- /dev/null
+++ b/src/main/java/org/apache/sling/maven/projectsupport/PrepareTestWebAppMojo.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.maven.projectsupport;
+
+import java.io.File;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Initialize a Sling integration test webapp by extracting bundles into the
+ * correct locations, including the current artifact.
+ *
+ * @goal prepare-test-webapp
+ * @requiresDependencyResolution test
+ * @phase package
+ */
+public class PrepareTestWebAppMojo extends PreparePackageMojo {
+
+    /**
+     * The project's build directory (i.e. target).
+     *
+     * @parameter expression="${project.build.directory}"
+     * @readonly
+     */
+    private File buildDirectory;
+
+    /**
+     * The start level for the current artifact.
+     *
+     * @parameter default-value="16"
+     */
+    private int startLevel;
+
+    /**
+     * The output directory for bundles.
+     *
+     * @parameter default-value="${project.build.directory}/launchpad-bundles"
+     */
+    private File outputDirectory;
+
+    /**
+     * @component
+     */
+    private ArtifactHandlerManager artifactHandlerManager;
+
+    public void executeWithArtifacts() throws MojoExecutionException, MojoFailureException
{
+        super.executeWithArtifacts();
+        copy(getPrimaryArtifact(), startLevel, getOutputDirectory());
+    }
+
+    @Override
+    protected File getOutputDirectory() {
+        return outputDirectory;
+    }
+
+
+    @Override
+    protected void unpackBaseArtifact() throws MojoExecutionException {
+        // No-op. This is JAR-specific.
+    }
+
+    private File getPrimaryArtifact() throws MojoExecutionException {
+        ArtifactHandler handler = artifactHandlerManager.getArtifactHandler(project.getPackaging());
+
+        String artifactName = project.getBuild().getFinalName() + "." + handler.getExtension();
+
+        File file = new File(buildDirectory, artifactName);
+        if (!file.exists()) {
+            throw new MojoExecutionException("Project's primary artifact (" + file.getPath()
+ ") doesn't exist.");
+        }
+        return file;
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Mime
View raw message