You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ol...@apache.org on 2011/12/21 18:23:22 UTC

svn commit: r1221817 - in /tomcat/maven-plugin/trunk: ./ tomcat7-maven-plugin/ tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/

Author: olamy
Date: Wed Dec 21 17:23:22 2011
New Revision: 1221817

URL: http://svn.apache.org/viewvc?rev=1221817&view=rev
Log:
feature to add extra resources in the exec war: log4j configuration files

Added:
    tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java   (with props)
Modified:
    tomcat/maven-plugin/trunk/pom.xml
    tomcat/maven-plugin/trunk/tomcat7-maven-plugin/pom.xml
    tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java

Modified: tomcat/maven-plugin/trunk/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/pom.xml?rev=1221817&r1=1221816&r2=1221817&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/pom.xml (original)
+++ tomcat/maven-plugin/trunk/pom.xml Wed Dec 21 17:23:22 2011
@@ -413,7 +413,7 @@
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-utils</artifactId>
-        <version>1.0.4</version>
+        <version>3.0</version>
       </dependency>
       <dependency>
         <groupId>commons-codec</groupId>

Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/pom.xml?rev=1221817&r1=1221816&r2=1221817&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/pom.xml (original)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/pom.xml Wed Dec 21 17:23:22 2011
@@ -186,6 +186,11 @@
     </dependency>
 
     <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.tomcat.maven</groupId>
       <artifactId>tomcat-maven-plugin-it</artifactId>
       <scope>test</scope>

Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java?rev=1221817&r1=1221816&r2=1221817&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java (original)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java Wed Dec 21 17:23:22 2011
@@ -41,6 +41,7 @@ import org.apache.tomcat.maven.runner.To
 import org.apache.tomcat.maven.runner.Tomcat7RunnerCli;
 import org.codehaus.plexus.archiver.jar.Manifest;
 import org.codehaus.plexus.archiver.jar.ManifestException;
+import org.codehaus.plexus.util.DirectoryScanner;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -49,7 +50,9 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.Enumeration;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.jar.JarEntry;
@@ -212,6 +215,13 @@ public abstract class AbstractExecWarMoj
     private List<ExtraDependency> extraDependencies;
 
     /**
+     * list of extra resources to add in the standalone tomcat jar: your logger configuration etc
+     *
+     * @parameter
+     */
+    private List<ExtraResource> extraResources;
+
+    /**
      * Main class to use for starting the standalone jar.
      *
      * @parameter expression="${maven.tomcat.exec.war.mainClass}" default-value="org.apache.tomcat.maven.runner.Tomcat7RunnerCli"
@@ -221,6 +231,7 @@ public abstract class AbstractExecWarMoj
 
     /**
      * which connector protocol to use HTTP/1.1 or org.apache.coyote.http11.Http11NioProtocol
+     *
      * @parameter expression="${maven.tomcat.exec.war.connectorHttpProtocol}" default-value="HTTP/1.1"
      * @required
      */
@@ -431,6 +442,29 @@ public abstract class AbstractExecWarMoj
                 projectHelper.attachArtifact( project, attachArtifactClassifierType, attachArtifactClassifier,
                                               execWarJar );
             }
+
+            if ( extraResources != null )
+            {
+                for ( ExtraResource extraResource : extraResources )
+                {
+
+                    DirectoryScanner directoryScanner = new DirectoryScanner();
+                    directoryScanner.setBasedir( extraResource.getDirectory() );
+                    directoryScanner.addDefaultExcludes();
+                    directoryScanner.setExcludes( toStringArray( extraResource.getExcludes() ) );
+                    directoryScanner.setIncludes( toStringArray( extraResource.getIncludes() ) );
+                    directoryScanner.scan();
+                    for ( String includeFile : directoryScanner.getIncludedFiles() )
+                    {
+                        getLog().debug( "include file:" + includeFile );
+                        os.putArchiveEntry( new JarArchiveEntry( includeFile ) );
+                        IOUtils.copy( new FileInputStream( new File( extraResource.getDirectory(), includeFile ) ),
+                                      os );
+                        os.closeArchiveEntry();
+                    }
+                }
+            }
+
         }
         catch ( ManifestException e )
         {
@@ -461,6 +495,21 @@ public abstract class AbstractExecWarMoj
         }
     }
 
+    private String[] toStringArray( List list )
+    {
+        if ( list == null || list.isEmpty() )
+        {
+            return new String[0];
+        }
+        List<String> res = new ArrayList<String>( list.size() );
+
+        for ( Iterator ite = list.iterator(); ite.hasNext(); )
+        {
+            res.add( (String) ite.next() );
+        }
+        return res.toArray( new String[res.size()] );
+    }
+
 
     /**
      * return file can be deleted

Added: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java?rev=1221817&view=auto
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java (added)
+++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java Wed Dec 21 17:23:22 2011
@@ -0,0 +1,31 @@
+package org.apache.tomcat.maven.plugin.tomcat7.run;
+/*
+ * 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.
+ */
+
+import org.apache.maven.model.Resource;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ExtraResource
+    extends Resource
+{
+    // no op just here to support for maven 2.x
+}
+

Propchange: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/ExtraResource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org