maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r631768 - in /maven/sandbox/trunk/shared/maven-filtering/src: main/java/org/apache/maven/shared/filtering/ site/apt/ test/java/org/apache/maven/shared/filtering/
Date Wed, 27 Feb 2008 22:58:40 GMT
Author: olamy
Date: Wed Feb 27 14:58:39 2008
New Revision: 631768

URL: http://svn.apache.org/viewvc?rev=631768&view=rev
Log:
add filterWrappers coming from the execution configuration bean
update documentation


Modified:
    maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
    maven/sandbox/trunk/shared/maven-filtering/src/site/apt/usage.apt
    maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java

Modified: maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java?rev=631768&r1=631767&r2=631768&view=diff
==============================================================================
--- maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
(original)
+++ maven/sandbox/trunk/shared/maven-filtering/src/main/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFiltering.java
Wed Feb 27 14:58:39 2008
@@ -138,10 +138,15 @@
         
         if ( mavenResourcesExecution.isUseDefaultFilterWrappers() )
         {
-            List filterWrappers = mavenFileFilter.getDefaultFilterWrappers( mavenResourcesExecution.getMavenProject(),
-                                                                            mavenResourcesExecution.getFileFilters(),
-                                                                            true, mavenResourcesExecution
-                                                                                .getMavenSession()
);
+            List filterWrappers = new ArrayList();
+            if ( mavenResourcesExecution.getFilterWrappers() != null )
+            {
+                filterWrappers.addAll( mavenResourcesExecution.getFilterWrappers() );
+            }
+            filterWrappers.addAll( mavenFileFilter.getDefaultFilterWrappers( mavenResourcesExecution.getMavenProject(),
+                                                                             mavenResourcesExecution.getFileFilters(),
+                                                                             true, mavenResourcesExecution
+                                                                                 .getMavenSession()
) );
             mavenResourcesExecution.setFilterWrappers( filterWrappers );
         }
 
@@ -209,8 +214,8 @@
 
             getLogger().info(
                               "Copying " + includedFiles.size() + " resource" + ( includedFiles.size()
> 1 ? "s" : "" )
-                                  + ( targetPath == null ? "" : " to " + targetPath ) );
           
-            
+                                  + ( targetPath == null ? "" : " to " + targetPath ) );
+
             for ( Iterator j = includedFiles.iterator(); j.hasNext(); )
             {
                 String name = (String) j.next();
@@ -230,8 +235,10 @@
                 {
                     destinationFile.getParentFile().mkdirs();
                 }
+                
                 boolean filteredExt = filteredFileExtension( source.getName(), mavenResourcesExecution
                     .getNonFilteredFileExtensions() );
+                
                 mavenFileFilter.copyFile( source, destinationFile, resource.isFiltering()
&& filteredExt,
                                           mavenResourcesExecution.getFilterWrappers(), mavenResourcesExecution
                                               .getEncoding() );

Modified: maven/sandbox/trunk/shared/maven-filtering/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-filtering/src/site/apt/usage.apt?rev=631768&r1=631767&r2=631768&view=diff
==============================================================================
--- maven/sandbox/trunk/shared/maven-filtering/src/site/apt/usage.apt (original)
+++ maven/sandbox/trunk/shared/maven-filtering/src/site/apt/usage.apt Wed Feb 27 14:58:39
2008
@@ -43,11 +43,24 @@
 
 +-----+
 
-encoding can be null platform default will be used
+resources : List of org.apache.maven.model.Resource
+
+outputDirectory : base output directory for Resource.targetPath
+
+mavenProject : a mavenProject 
+
+encoding : output encoding for filtered files (can be null platform default will be used)
+
+filtersFile : List of String pointed to a properties file 
 
 nonFilteredFileExtensions : is a List of String which file extensions to not apply filtering
(default List contains jpg,jpeg,gif,bmp,png)
 
-mavenResourcesFiltering.filterResources( resources, outputDirectory, mavenProject, encoding,
filtersFile, nonFilteredFileExtensions, mavenSession );
+mavenSession : executionProperties will be used for file filtering
+
+MavenResourcesExecution mavenResourcesExecution = 
+  new MavenResourcesExecution ( resources, outputDirectory, mavenProject, encoding, filtersFile,
nonFilteredFileExtensions, mavenSession );
+
+mavenResourcesFiltering.filterResources( mavenResourcesExecution );
 
 +-----+
 
@@ -58,11 +71,8 @@
 
 +-----+
 
-MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(),
"default" );
-List defaultFilterWrappers = mavenFileFilter.getDefaultFilterWrappers( mavenProject, null,
true, mavenSession );
+Create your FilterWrapper.
 
-List filterWrappers = new ArrayList( );
-filterWrappers.addAll( defaultFilterWrappers );
 FileUtils.FilterWrapper filterWrapper = new FileUtils.FilterWrapper()
 {
     public Reader getReader( Reader reader )
@@ -71,15 +81,14 @@
         return new InterpolationFilterReader( reader, reflectionProperties, "@", "@" );
     }
 };
-filterWrappers.add( filterWrapper );
 
-here you can apply filtering on your resources.
+Create your MavenResourcesExecution instance and add a new filterWrapper.
 
-encoding can be null platform default will be used
+mavenResourcesExecution.addFilterWrapper( filterWrapper ); 
+If the mavenResourcesExecution.useDefaultFilterWrappers is set to true default FilterWrapper
will be added first. 
 
-nonFilteredFileExtensions : is a List of String which file extensions to not apply filtering
(default List contains jpg,jpeg,gif,bmp,png)
+here you can apply filtering on your resources.
 
-mavenResourcesFiltering.filterResources( resources, outputDirectory, encoding, filterWrappers,
-                                         outputDirectory, nonFilteredFileExtensions, mavenSession
);
+mavenResourcesFiltering.filterResources( mavenResourcesExecution );
 
 +-----+

Modified: maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java?rev=631768&r1=631767&r2=631768&view=diff
==============================================================================
--- maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
(original)
+++ maven/sandbox/trunk/shared/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java
Wed Feb 27 14:58:39 2008
@@ -28,7 +28,9 @@
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Resource;
+import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
@@ -194,12 +196,6 @@
 
         List nonFilteredFileExtensions = Collections.singletonList( "gif" );
 
-        MavenFileFilter mavenFileFilter = (MavenFileFilter) lookup( MavenFileFilter.class.getName(),
"default" );
-        List defaultFilterWrappers = mavenFileFilter.getDefaultFilterWrappers( mavenProject,
null, true,
-                                                                               new StubMavenSession()
);
-
-        List filterWrappers = new ArrayList();
-        filterWrappers.addAll( defaultFilterWrappers );
         FileUtils.FilterWrapper filterWrapper = new FileUtils.FilterWrapper()
         {
             public Reader getReader( Reader reader )
@@ -208,9 +204,13 @@
                 return new InterpolationFilterReader( reader, reflectionProperties, "@",
"@" );
             }
         };
-        filterWrappers.add( filterWrapper );
-        mavenResourcesFiltering.filterResources( resources, outputDirectory, null, filterWrappers,
-                                                 new File( getBasedir() ), nonFilteredFileExtensions
);
+
+        MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution( resources,
outputDirectory,
+                                                                                       mavenProject,
null, null,
+                                                                                       nonFilteredFileExtensions,
+                                                                                       new
StubMavenSession() );
+        mavenResourcesExecution.addFilterWrapper( filterWrapper );
+        mavenResourcesFiltering.filterResources( mavenResourcesExecution );
 
         Properties result = PropertyUtils
             .loadPropertyFile( new File( outputDirectory, "maven-resources-filtering.txt"
), null );



Mime
View raw message