maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r620222 - in /maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war: AbstractWarMojo.java packaging/AbstractWarPackagingTask.java packaging/WarPackagingContext.java
Date Sat, 09 Feb 2008 23:53:55 GMT
Author: olamy
Date: Sat Feb  9 15:53:54 2008
New Revision: 620222

URL: http://svn.apache.org/viewvc?rev=620222&view=rev
Log:
create List of FilterWrapper only one time for the mojo execution instead of for each file
filtering.


Modified:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?rev=620222&r1=620221&r2=620222&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
Sat Feb  9 15:53:54 2008
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
@@ -44,8 +45,12 @@
 import org.apache.maven.plugin.war.util.WebappStructureSerializer;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.shared.filtering.MavenFileFilter;
+import org.apache.maven.shared.filtering.MavenFilteringException;
+import org.apache.maven.shared.filtering.ReflectionProperties;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.InterpolationFilterReader;
 import org.codehaus.plexus.util.StringUtils;
 
 /**
@@ -370,7 +375,29 @@
         final OverlayManager overlayManager =
             new OverlayManager( overlays, project, dependentWarIncludes, dependentWarExcludes
);
         final List packagingTasks = getPackagingTasks( overlayManager );
-        final WarPackagingContext context = new DefaultWarPackagingContext( webappDirectory,
cache, overlayManager );
+        List filterWrappers = new ArrayList( );
+        try
+        {
+            List defaultFilterWrappers = mavenFileFilter.getDefaultFilterWrappers( project,
filters, true );
+
+            filterWrappers.addAll( defaultFilterWrappers );
+            FileUtils.FilterWrapper filterWrapper = new FileUtils.FilterWrapper()
+            {
+                public Reader getReader( Reader reader )
+                {
+                    ReflectionProperties reflectionProperties = new ReflectionProperties(
getProject(), true );
+                    return new InterpolationFilterReader( reader, reflectionProperties, "@",
"@" );
+                }
+            };
+            filterWrappers.add( filterWrapper );
+        }
+        catch ( MavenFilteringException e )
+        {
+            getLog().error( "fail to build filering wrappers " + e.getMessage() );
+            throw new MojoExecutionException( e.getMessage(), e );
+        }
+        
+        final WarPackagingContext context = new DefaultWarPackagingContext( webappDirectory,
cache, overlayManager, filterWrappers );
         final Iterator it = packagingTasks.iterator();
         while ( it.hasNext() )
         {
@@ -456,13 +483,16 @@
         private final File webappDirectory;
 
         private final OverlayManager overlayManager;
+        
+        private final List filterWrappers;
 
         public DefaultWarPackagingContext( File webappDirectory, final WebappStructure webappStructure,
-                                           final OverlayManager overlayManager )
+                                           final OverlayManager overlayManager, List filterWrappers
)
         {
             this.webappDirectory = webappDirectory;
             this.webappStructure = webappStructure;
             this.overlayManager = overlayManager;
+            this.filterWrappers = filterWrappers;
 
             // This is kinda stupid but if we loop over the current overlays and we request
the path structure
             // it will register it. This will avoid wrong warning messages in a later phase
@@ -557,6 +587,11 @@
         public MavenFileFilter getMavenFileFilter()
         {
             return mavenFileFilter;
+        }
+
+        public List getFilterWrappers()
+        {
+            return filterWrappers;
         }
         
         

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java?rev=620222&r1=620221&r2=620222&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/AbstractWarPackagingTask.java
Sat Feb  9 15:53:54 2008
@@ -21,10 +21,7 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
@@ -33,16 +30,15 @@
 import org.apache.maven.plugin.war.util.PathSet;
 import org.apache.maven.plugin.war.util.WebappStructure;
 import org.apache.maven.shared.filtering.MavenFilteringException;
-import org.apache.maven.shared.filtering.ReflectionProperties;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.InterpolationFilterReader;
 
 /**
  * @author Stephane Nicoll
+ * @version $Id$
  */
 public abstract class AbstractWarPackagingTask
     implements WarPackagingTask
@@ -202,27 +198,7 @@
             {
                 // fix for MWAR-36, ensures that the parent dir are created first
                 targetFile.getParentFile().mkdirs();
-
-                List defaultFilterWrappers = context.getMavenFileFilter().getDefaultFilterWrappers(
-                                                                                        
           context
-                                                                                        
               .getProject(),
-                                                                                        
           context
-                                                                                        
               .getFilters(),
-                                                                                        
           true );
-
-                List filterWrappers = new ArrayList( defaultFilterWrappers );
-                FileUtils.FilterWrapper filterWrapper = new FileUtils.FilterWrapper()
-                {
-                    public Reader getReader( Reader reader )
-                    {
-                        ReflectionProperties reflectionProperties = new ReflectionProperties(
context.getProject(),
-                                                                                        
     true );
-                        return new InterpolationFilterReader( reader, reflectionProperties,
"@", "@" );
-                    }
-                };
-                filterWrappers.add( filterWrapper );
-
-                context.getMavenFileFilter().copyFile( file, targetFile, true, filterWrappers,
null );
+                context.getMavenFileFilter().copyFile( file, targetFile, true, context.getFilterWrappers(),
null );
             }
             catch ( MavenFilteringException e )
             {

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java?rev=620222&r1=620221&r2=620222&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/packaging/WarPackagingContext.java
Sat Feb  9 15:53:54 2008
@@ -29,11 +29,13 @@
 import org.apache.maven.shared.filtering.MavenFileFilter;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
 import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.util.FileUtils.FilterWrapper;
 
 /**
  * The packaging context.
  *
  * @author Stephane Nicoll
+ * @version $Id$
  */
 public interface WarPackagingContext
 {
@@ -161,5 +163,11 @@
      * @since 2.1-alpha-2
      */
     MavenFileFilter getMavenFileFilter();
+    
+    /**
+     * @return {@link List} of {@link FilterWrapper}
+     * @since 2.1-alpha-2
+     */
+    List getFilterWrappers();
 
 }



Mime
View raw message