cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r383142 - in /cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer: AbstractDeployMojo.java DeployExplodedMojo.java DeployMojo.java DeployWarMojo.java
Date Sat, 04 Mar 2006 15:47:06 GMT
Author: reinhard
Date: Sat Mar  4 07:47:06 2006
New Revision: 383142

URL: http://svn.apache.org/viewcvs?rev=383142&view=rev
Log:
COCOON-1748
cocoon:deploy and cocoon:deploy-war work. Packaging and creating the web application are based
on the Maven war plugin. 

Added:
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
      - copied, changed from r383117, cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployMojo.java
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
  (with props)
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployWarMojo.java
  (with props)
Removed:
    cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployMojo.java

Copied: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
(from r383117, cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployMojo.java)
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java?p2=cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java&p1=cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployMojo.java&r1=383117&r2=383142&rev=383142&view=diff
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployMojo.java
(original)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
Sat Mar  4 07:47:06 2006
@@ -35,23 +35,9 @@
 
 /**
  * Create a Cocoon web application based on a block deployment descriptor.
- * 
- * @goal deploy
- * @requiresProject true
- * @phase package
- * @description Create a Cocoon web application based on a block deployment descriptor.
  */
-public class DeployMojo extends AbstractWarMojo 
+abstract class AbstractDeployMojo extends AbstractWarMojo 
 {
-	
-    /**
-     * The project whose project files to create.
-     *
-     * @parameter expression="${project}"
-     * @required
-     */
-    private MavenProject project;		
-
     /**
      * Artifact factory, needed to download source jars for inclusion in classpath.
      *
@@ -106,6 +92,15 @@
     
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     // set properties: necessary because DeployMojo is not in the same package as AbstractWarMojo
+    
+    /**
+     * The project whose project files to create.
+     *
+     * @parameter expression="${project}"
+     * @required
+     */
+    private MavenProject project;	    
+    
     /**
      * The directory containing generated classes.
      *
@@ -139,7 +134,7 @@
     private String webXml;
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   
 	
-    public void execute() throws MojoExecutionException 
+    protected void deployBlocks() throws MojoExecutionException 
     {
     	File webappDirectory_ = getWebappDirectory();
     	

Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java?rev=383142&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
(added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
Sat Mar  4 07:47:06 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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.cocoon.maven.deployer;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Create a Cocoon web application based on a block deployment descriptor.
+ * 
+ * @goal deploy
+ * @requiresProject true
+ * @phase package
+ * @description Create a Cocoon web application based on a block deployment descriptor.
+ */
+public class DeployExplodedMojo extends AbstractDeployMojo 
+{
+
+	public void execute() throws MojoExecutionException {
+		this.deployBlocks();
+	}
+
+}
\ No newline at end of file

Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployExplodedMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployWarMojo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployWarMojo.java?rev=383142&view=auto
==============================================================================
--- cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployWarMojo.java
(added)
+++ cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployWarMojo.java
Sat Mar  4 07:47:06 2006
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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.cocoon.maven.deployer;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.archiver.MavenArchiveConfiguration;
+import org.apache.maven.archiver.MavenArchiver;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.archiver.war.WarArchiver;
+
+/**
+ * Create a packaged Cocoon web application (.war file) based on a block
+ * deployment descriptor.
+ * 
+ * @goal deploy-war
+ * @requiresProject true
+ * @phase package
+ * @description Create a packaged Cocoon web application (.war file) based on a
+ *              block deployment descriptor.
+ */
+public class DeployWarMojo extends AbstractDeployMojo {
+
+	/**
+	 * The directory for the generated WAR.
+	 * 
+	 * @parameter expression="${project.build.directory}"
+	 * @required
+	 */
+	private String outputDirectory;
+
+	/**
+	 * The name of the generated war.
+	 * 
+	 * @parameter expression="${project.build.finalName}"
+	 * @required
+	 */
+	private String warName;
+
+	/**
+	 * The Jar archiver.
+	 * 
+	 * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#war}"
+	 * @required
+	 */
+	private WarArchiver warArchiver;
+
+	/**
+	 * The maven archive configuration to use.
+	 * 
+	 * @parameter
+	 */
+	private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
+
+	public void execute() throws MojoExecutionException {
+
+		File warFile = new File(outputDirectory, warName + ".war");
+		this.deployBlocks();
+
+		try {
+			performPackaging(warFile);
+		} catch (Exception e) {
+			// TODO: improve error handling
+			throw new MojoExecutionException("Error assembling WAR", e);
+		}
+
+	}
+
+	/**
+	 * Generates the webapp according to the <tt>mode</tt> attribute.
+	 * 
+	 * @param warFile
+	 *            the target war file
+	 * @throws IOException
+	 * @throws ArchiverException
+	 * @throws ManifestException
+	 * @throws DependencyResolutionRequiredException
+	 */
+	private void performPackaging(File warFile) throws IOException,
+			ArchiverException, ManifestException,
+			DependencyResolutionRequiredException, MojoExecutionException {
+		getLog().info("Generating war " + warFile.getAbsolutePath());
+
+		MavenArchiver archiver = new MavenArchiver();
+
+		archiver.setArchiver(warArchiver);
+
+		archiver.setOutputFile(warFile);
+
+		warArchiver.addDirectory(getWebappDirectory(), getIncludes(),
+				getExcludes());
+
+		warArchiver
+				.setWebxml(new File(getWebappDirectory(), "WEB-INF/web.xml"));
+
+		// create archive
+		archiver.createArchive(getProject(), archive);
+
+		getProject().getArtifact().setFile(warFile);
+	}
+
+}
\ No newline at end of file

Propchange: cocoon/trunk/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/DeployWarMojo.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message