You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2009/01/03 10:48:23 UTC

svn commit: r730948 - in /maven/plugins/trunk/maven-ear-plugin: ./ src/main/java/org/apache/maven/plugin/ear/ src/site/ src/site/apt/ src/site/apt/examples/ src/test/java/org/apache/maven/plugin/ear/it/ src/test/resources/projects/project-045/ src/test...

Author: snicoll
Date: Sat Jan  3 01:48:22 2009
New Revision: 730948

URL: http://svn.apache.org/viewvc?rev=730948&view=rev
Log:
MEAR-43: Content in the src/main/application can be filtered the usual way

Added:
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-advanced.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-sources.apt
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/expected-META-INF/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/pom.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/application/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/application/README.txt
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/expected-META-INF/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/pom.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/application/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/application/README.txt
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/filters/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/filters/config.properties
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/expected-META-INF/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/expected-META-INF/application.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/pom.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/application/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/application/README.txt
Modified:
    maven/plugins/trunk/maven-ear-plugin/pom.xml
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt
    maven/plugins/trunk/maven-ear-plugin/src/site/site.xml
    maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java

Modified: maven/plugins/trunk/maven-ear-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/pom.xml?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-ear-plugin/pom.xml Sat Jan  3 01:48:22 2009
@@ -36,7 +36,7 @@
   <description>Generates a J2EE Enterprise Archive (EAR) file.</description>
 
   <prerequisites>
-    <maven>2.0</maven>
+    <maven>2.0.6</maven>
   </prerequisites>
 
   <scm>
@@ -53,17 +53,17 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
-      <version>2.0.4</version>
+      <version>2.0.6</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0.4</version>
+      <version>2.0.6</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
-      <version>2.0.4</version>
+      <version>2.0.6</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -77,6 +77,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-filtering</artifactId>
+      <version>1.0-beta-2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
       <artifactId>maven-verifier</artifactId>
       <version>1.0</version>
       <scope>test</scope>

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java Sat Jan  3 01:48:22 2009
@@ -24,6 +24,11 @@
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProjectHelper;
+import org.apache.maven.shared.filtering.MavenFileFilter;
+import org.apache.maven.shared.filtering.MavenResourcesExecution;
+import org.apache.maven.shared.filtering.MavenFilteringException;
+import org.apache.maven.shared.filtering.MavenResourcesFiltering;
+import org.apache.maven.execution.MavenSession;
 import org.codehaus.plexus.archiver.ArchiverException;
 import org.codehaus.plexus.archiver.UnArchiver;
 import org.codehaus.plexus.archiver.jar.JarArchiver;
@@ -52,6 +57,9 @@
 public class EarMojo
     extends AbstractEarMojo
 {
+    private static final String[] EMPTY_STRING_ARRAY = {};
+
+
     /**
      * Single directory for extra files to include in the EAR.
      *
@@ -75,7 +83,48 @@
      */
     private String earSourceExcludes;
 
-    private static final String[] EMPTY_STRING_ARRAY = {};
+    /**
+     * Specify that the ear sources should be filtered.
+     *
+     * @parameter
+     * @since 2.3.2     
+     */
+    private boolean filtering = false;
+
+    /**
+     * Filters (property files) to include during the interpolation of the pom.xml.
+     *
+     * @parameter
+     * @since 2.3.2
+     */
+    private List filters;
+
+    /**
+     * A list of file extensions that should not be filtered if
+     * filtering is actived.
+     *
+     * @parameter
+     * @since 2.3.2
+     */
+    private List nonFilteredFileExtensions;
+
+    /**
+     * To escape interpolated value with windows path
+     * c:\foo\bar will be replaced with c:\\foo\\bar
+     *
+     * @parameter expression="${maven.ear.escapedBackslashesInFilePath}" default-value="false"
+     * @since 2.3.2
+     */
+    private boolean escapedBackslashesInFilePath = false;
+
+    /**
+     * Expression preceded with the String won't be interpolated
+     * \${foo} will be replaced with ${foo}
+     *
+     * @parameter expression="${maven.ear.escapeString}"
+     * @since 2.3.2
+     */
+    protected String escapeString;
 
     /**
      * The location of the manifest file to be used within the ear file.
@@ -128,7 +177,7 @@
      * The directory to get the resources from.
      *
      * @parameter
-     * @deprecated
+     * @deprecated please use earSourcesDirectory instead
      */
     private File resourcesDir;
 
@@ -160,6 +209,32 @@
      */
     private ArchiverManager archiverManager;
 
+    /**
+     *
+     * @component role="org.apache.maven.shared.filtering.MavenFileFilter" role-hint="default"
+     * @required
+     */
+    private MavenFileFilter mavenFileFilter;
+
+    /**
+     *
+     * @component role="org.apache.maven.shared.filtering.MavenResourcesFiltering" role-hint="default"
+     * @required
+     */
+    private MavenResourcesFiltering mavenResourcesFiltering;
+
+    /**
+     * @parameter expression="${session}"
+     * @readonly
+     * @required
+     * @since 2.3.2
+     */
+    private MavenSession session;
+
+
+    private List filterWrappers;
+
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -258,8 +333,8 @@
                 String[] fileNames = getEarFiles( earSourceDir );
                 for ( int i = 0; i < fileNames.length; i++ )
                 {
-                    FileUtils.copyFile( new File( earSourceDir, fileNames[i] ),
-                                        new File( getWorkDirectory(), fileNames[i] ) );
+                    copyFile( new File( earSourceDir, fileNames[i] ),
+                              new File( getWorkDirectory(), fileNames[i] ) );
                 }
             }
 
@@ -268,7 +343,7 @@
                 //rename to application.xml
                 getLog().info( "Including custom application.xml[" + applicationXml + "]" );
                 File metaInfDir = new File( getWorkDirectory(), META_INF );
-                FileUtils.copyFile( new File( applicationXml ), new File( metaInfDir, "/application.xml" ) );
+                copyFile( new File( applicationXml ), new File( metaInfDir, "/application.xml" ) );
             }
 
         }
@@ -276,12 +351,17 @@
         {
             throw new MojoExecutionException( "Error copying EAR sources", e );
         }
+        catch ( MavenFilteringException e )
+        {
+            throw new MojoExecutionException( "Error filetering EAR sources", e );
+        }
 
         // Copy resources files
         try
         {
             if ( resourcesDir != null && resourcesDir.exists() )
             {
+                getLog().warn( "resourcesDir is deprecated. Please use the earSourceDirectory property instead.");
                 getLog().info( "Copy ear resources to " + getWorkDirectory().getAbsolutePath() );
                 String[] fileNames = getEarFiles( resourcesDir );
                 for ( int i = 0; i < fileNames.length; i++ )
@@ -471,5 +551,39 @@
         return jarArchiver;
     }
 
+    private void copyFile(File source, File target)
+            throws MavenFilteringException, IOException, MojoExecutionException {
+        if ( filtering && !isNonFilteredExtension( source.getName() ) )
+        {
+           mavenFileFilter.copyFile( source, target, true, getFilterWrappers(), null );
+        }
+        else
+        {
+             FileUtils.copyFile(source,target);
+        }
+    }
+
+    public boolean isNonFilteredExtension( String fileName )
+    {
+        return !mavenResourcesFiltering.filteredFileExtension( fileName, nonFilteredFileExtensions );
+    }
 
+    private List getFilterWrappers() throws MojoExecutionException {
+        if (filterWrappers == null)
+        {
+            try
+            {
+                MavenResourcesExecution mavenResourcesExecution = new MavenResourcesExecution();
+                mavenResourcesExecution.setEscapeString( escapeString );
+                filterWrappers = mavenFileFilter.getDefaultFilterWrappers( project, filters,
+                        escapedBackslashesInFilePath, this.session, mavenResourcesExecution );
+            }
+            catch ( MavenFilteringException e )
+            {
+                getLog().error( "fail to build filering wrappers " + e.getMessage() );
+                throw new MojoExecutionException( e.getMessage(), e );
+            }
+        }
+        return filterWrappers;
+    }
 }

Added: maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-advanced.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-advanced.apt?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-advanced.apt (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-advanced.apt Sat Jan  3 01:48:22 2009
@@ -0,0 +1,103 @@
+  ------
+  Filtering Advanced Techniques
+  ------
+  Stephane Nicoll
+  <sn...@apache.org>
+  ------
+  January 3, 2009
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+
+Filtering: Advanced techniques
+
+  The following features are described in this document:
+
+  * Escaping properties that should not be filtered
+
+  * Ignoring files based on its extension
+
+
+* Escaping properties
+
+  It may be necessary to filters some properties in a file and ignore another. The
+  filtering mechanism won't touch a token that is not recognized (i.e. that
+  represents an unknown property). This won't work if the property is known
+  obviously so it should be escaped explicitely.
+
+  The following configuration defines the value of the <<<escapeString>>> which will
+  stop the interpolation of a property if it starts with that value
+
++--------
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+           <filtering>true</filtering>
+           <escapeString>\</escapeString>
+           [...]
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
++---------
+
+  Assuming the following file
+
++--------
+jdbc.url=${db.url}
+jdbc.user=${db.username}
+jdbc.password=\${db.password}
++--------
+
+  Filtering the content of such a file with this config will produce this content.
+  Note that that the escaped property can now be filtered the usual way later if
+  necessary!
+
++--------
+jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl
+jdbc.user=someuser
+jdbc.password=${db.password}
++--------
+
+
+* Ignoring files based on its extension
+
+  Filtering binary files corrupt them so it may be necessary to exclude files from
+  filtering based on the extension. To do so, configure the plugin as follow
+
++--------
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+           <filtering>true</filtering>
+           <nonFilteredFileExtensions>
+             <nonFilteredFileExtension>png</nonFilteredFileExtension>
+             <nonFilteredFileExtension>jpeg</nonFilteredFileExtension>
+           </nonFilteredFileExtensions>
+           [...]
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
++---------

Added: maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-sources.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-sources.apt?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-sources.apt (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/examples/filtering-sources.apt Sat Jan  3 01:48:22 2009
@@ -0,0 +1,68 @@
+  ------
+  Filtering the sources
+  ------
+  Stephane Nicoll
+  <sn...@apache.org>
+  ------
+  January 3, 2009
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+
+Filtering the sources
+
+  Filtering the content of the <<<src/main/application>>> directory or the
+  one defined by the <<<earSourcesDirectory>>> parameter is as easy as:
+
++--------
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+           <filtering>true</filtering>
+           [...]
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
++---------
+
+  Note that the standard properties are available for filtering. It is also
+  possible to specify a set of property files to add extra values if
+  necessary. The configuration below uses also the properties defined in
+  <<<src/main/filters/config.properties>>>
+
++--------
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+           <filtering>true</filtering>
+           <filters>
+             <filter>src/main/filters/config.properties</filter>
+           </filters>
+           [...]
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
++---------

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/index.apt Sat Jan  3 01:48:22 2009
@@ -94,6 +94,10 @@
   To provide you with better understanding on some usages of the EAR Plugin,
   you can take a look into the following examples:
 
+  * {{{examples/filtering-sources.html}Filtering EAR Resources}}
+
+  * {{{examples/filtering-advanced.html}Advanced Filtering Techniques}}
+
   * {{{examples/customizing-a-module-filename.html}Customizing A Module
   Filename}}
 

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/tests.apt Sat Jan  3 01:48:22 2009
@@ -117,4 +117,10 @@
   * project-043: builds an EAR with a custom descriptor location (generatedDescriptorLocation setting)
 
   * project-044: builds an EAR with a custom library-directory
+
+  * project-045: builds an EAR and filter the content of the sources directory
+
+  * project-046: builds an EAR and filter the content of the sources directory using a custom filter file
+
+  * project-047: builds an EAR and filter the content with a list of extensions
    
\ No newline at end of file

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/apt/usage.apt Sat Jan  3 01:48:22 2009
@@ -68,6 +68,14 @@
 mvn package
 +-----
 
+* Copying resources
+
+  The default resource directory for an EAR is <<<src/main/application>>> as
+  defined by the <<<earSourcesDirectory>>> parameter. The content of this
+  directory may be filterd if necessary using the <<<filtering>>> parameter.
+
+  For more details, have a look to the examples.
+
 * Advanced Configuration
 
   Any EAR module might be further customized as follows:

Modified: maven/plugins/trunk/maven-ear-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/site/site.xml?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/site/site.xml Sat Jan  3 01:48:22 2009
@@ -32,6 +32,8 @@
     </menu>
 
     <menu name="Examples">
+      <item name="Filtering EAR Resources" href="examples/filtering-sources.html"/>
+      <item name="Advanced Filtering Techniques" href="examples/filtering-advanced.html"/>
       <item name="Customizing A Module Filename" href="examples/customizing-a-module-filename.html"/>
       <item name="Customizing The Context Root" href="examples/customizing-context-root.html"/>
       <item name="Customizing A Module Location" href="examples/customizing-module-location.html"/>

Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java?rev=730948&r1=730947&r2=730948&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/it/EarMojoIT.java Sat Jan  3 01:48:22 2009
@@ -20,8 +20,10 @@
  */
 
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
 
 import java.io.File;
+import java.io.FileReader;
 import java.util.Properties;
 
 /**
@@ -471,4 +473,52 @@
         doTestProject( "project-044", new String[]{"ejb-sample-one-1.0.jar", "myLibs/jar-sample-one-1.0.jar"} );
     }
 
+    /**
+     * Builds an EAR and filter the content of the sources directory.
+     */
+    public void testProject045()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-045", new String[]{"README.txt", "ejb-sample-one-1.0.jar"} );
+        final File actualReadme = new File( getEarDirectory( baseDir, "project-045" ), "README.txt" );
+        final String content = IOUtil.toString(new FileReader(actualReadme));
+        assertTrue("application name and version was not filtered properly",
+                content.indexOf("my-app 99.0") != -1);
+        assertTrue("Escaping did not work properly",
+                content.indexOf("will not be filtered ${application.name}.") != -1);
+    }
+
+    /**
+     * Builds an EAR and filter the content of the sources directory using
+     * a custom filter file.
+     */
+    public void testProject046()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-046", new String[]{"README.txt", "ejb-sample-one-1.0.jar"} );
+        final File actualReadme = new File( getEarDirectory( baseDir, "project-046" ), "README.txt" );
+        final String content = IOUtil.toString(new FileReader(actualReadme));
+        assertTrue("application name and version was not filtered properly",
+                content.indexOf("my-app 99.0") != -1);
+        assertTrue("application build was not filtered properly",
+                content.indexOf("(Build 2)") != -1);
+        assertTrue("Unknown property should not have been filtered",
+                content.indexOf("will not be filtered ${application.unknown}.") != -1);
+    }
+
+    /**
+     * Builds an EAR and filter the content with a list of extensions.
+     */
+    public void testProject047()
+        throws Exception
+    {
+        final File baseDir = doTestProject( "project-047", new String[]{"README.txt", "ejb-sample-one-1.0.jar"} );
+        final File actualReadme = new File( getEarDirectory( baseDir, "project-047" ), "README.txt" );
+        final String content = IOUtil.toString(new FileReader(actualReadme));
+        assertTrue("application name and version should not have been filtered",
+                content.indexOf("my-app 99.0") == -1);
+        assertTrue("orignial properties not found",
+                content.indexOf("${application.name} ${project.version}") != -1);
+    }
+
 }

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/expected-META-INF/application.xml?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/expected-META-INF/application.xml Sat Jan  3 01:48:22 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE application PUBLIC
+	"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+	"http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+  <display-name>maven-ear-plugin-test-project-045</display-name>
+  <module>
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+</application>
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/pom.xml?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/pom.xml Sat Jan  3 01:48:22 2009
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-045</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>  
+  <properties>
+    <application.name>my-app</application.name>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+          <filtering>true</filtering>
+          <escapeString>\</escapeString>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/application/README.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/application/README.txt?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/application/README.txt (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-045/src/main/application/README.txt Sat Jan  3 01:48:22 2009
@@ -0,0 +1,14 @@
+#####
+#
+# ${application.name} ${project.version}
+#
+#####
+
+Bla bla bla bla bla.
+
+This property will not be filtered \${application.name}.
+
+Enjoy!
+
+
+--The Maven team
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/expected-META-INF/application.xml?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/expected-META-INF/application.xml Sat Jan  3 01:48:22 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE application PUBLIC
+	"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+	"http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+  <display-name>maven-ear-plugin-test-project-046</display-name>
+  <module>
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+</application>
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/pom.xml?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/pom.xml Sat Jan  3 01:48:22 2009
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-046</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>  
+  <properties>
+    <application.name>my-app</application.name>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+          <filtering>true</filtering>
+          <filters>
+            <filter>src/main/filters/config.properties</filter>
+          </filters>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/application/README.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/application/README.txt?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/application/README.txt (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/application/README.txt Sat Jan  3 01:48:22 2009
@@ -0,0 +1,14 @@
+#####
+#
+# ${application.name} ${project.version} (Build ${application.build})
+#
+#####
+
+Bla bla bla bla bla.
+
+This property will not be filtered ${application.unknown}.
+
+Enjoy!
+
+
+--The Maven team
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/filters/config.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/filters/config.properties?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/filters/config.properties (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-046/src/main/filters/config.properties Sat Jan  3 01:48:22 2009
@@ -0,0 +1,6 @@
+application.build=2
+
+# WARNING: settings specified in the pom takes precedence so
+# the properties below won't be used
+application.name=my-other-app
+application.version=1.0
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/expected-META-INF/application.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/expected-META-INF/application.xml?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/expected-META-INF/application.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/expected-META-INF/application.xml Sat Jan  3 01:48:22 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE application PUBLIC
+	"-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+	"http://java.sun.com/dtd/application_1_3.dtd">
+<application>
+  <display-name>maven-ear-plugin-test-project-047</display-name>
+  <module>
+    <ejb>ejb-sample-one-1.0.jar</ejb>
+  </module>
+</application>
\ No newline at end of file

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/pom.xml?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/pom.xml Sat Jan  3 01:48:22 2009
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>ear</groupId>
+  <artifactId>maven-ear-plugin-test-project-047</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>  
+  <properties>
+    <application.name>my-app</application.name>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>
+        <configuration>
+          <filtering>true</filtering>
+          <nonFilteredFileExtensions>
+            <nonFilteredFileExtension>txt</nonFilteredFileExtension>
+          </nonFilteredFileExtensions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/application/README.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/application/README.txt?rev=730948&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/application/README.txt (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-047/src/main/application/README.txt Sat Jan  3 01:48:22 2009
@@ -0,0 +1,12 @@
+#####
+#
+# ${application.name} ${project.version}
+#
+#####
+
+Bla bla bla bla bla.
+
+Enjoy!
+
+
+--The Maven team
\ No newline at end of file