cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject svn commit: r429986 - /cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
Date Wed, 09 Aug 2006 07:59:37 GMT
Author: giacomo
Date: Wed Aug  9 00:59:35 2006
New Revision: 429986

URL: http://svn.apache.org/viewvc?rev=429986&view=rev
Log:
supply a default web.xml if none is in the project

Modified:
    cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java

Modified: cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java?rev=429986&r1=429985&r2=429986&view=diff
==============================================================================
--- cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
(original)
+++ cocoon/trunk/tools/cocoon-block-deployer/cocoon-deployer-plugin/src/main/java/org/apache/cocoon/maven/deployer/AbstractDeployMojo.java
Wed Aug  9 00:59:35 2006
@@ -20,6 +20,7 @@
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -30,6 +31,7 @@
 import org.apache.cocoon.maven.deployer.monolithic.MonolithicCocoonDeployer;
 import org.apache.cocoon.maven.deployer.utils.WebApplicationRewriter;
 import org.apache.cocoon.maven.deployer.utils.XMLUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.SystemUtils;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -171,7 +173,6 @@
 
     	// build the web application
         this.buildExplodedWebapp(webappDirectory_);
-
         MonolithicCocoonDeployer deployer = new MonolithicCocoonDeployer(this.getLog());
       
         deployer.deploy(getBlockArtifactsAsMap(null), webappDirectory_, 
                 blocksdir, new DevelopmentBlock[0], new DevelopmentProperty[0]);
@@ -299,6 +300,18 @@
         if ( webXmlLocation == null ) {
             webXmlLocation = getWarSourceDirectory().getAbsolutePath() + File.separatorChar
+ "WEB-INF" + File.separatorChar + "web.xml";
         }
+        if( ! new File(webXmlLocation).exists())
+        {
+            this.getLog().info("No web.xml supplied. Will install default web.xml");
+            final String webXml = "WEB-INF" + File.separatorChar + "web.xml";
+            File outFile = org.apache.cocoon.maven.deployer.utils.FileUtils.createDirectory(new
File(webappDirectory_, webXml));
+            try {
+                IOUtils.copy(readResourceFromClassloader(webXml), new FileOutputStream(outFile));
+            } catch(IOException ioex) {
+                throw new MojoExecutionException("cannot read resource " + webXml, ioex);
+            }
+            webXmlLocation = webappDirectory_.getAbsolutePath() + File.separatorChar + webXml;
+        }
         this.getLog().info("Adding shielded classloader configuration to webapp configuration.");
         this.getLog().debug("Reading web.xml: " + webXmlLocation);
         try {
@@ -318,6 +331,11 @@
         }
     }  
 
+    private InputStream readResourceFromClassloader(String fileName) {
+        return MonolithicCocoonDeployer.class.getClassLoader().
+            getResourceAsStream("org/apache/cocoon/maven/deployer/monolithic/" + fileName);
+    }
+
     /**
      * Copy all libs that don't have the scope provided or system to WEB-INF/cocoon/lib,
except
      * cocoon-bootstrap, which is copied to WEB-INF/lib
@@ -386,4 +404,4 @@
             }
         }
     }    
-}
\ No newline at end of file
+}



Mime
View raw message