From 7a8c848b0167f41c321d66b1c08d7baefbbd310d Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Sun, 28 Aug 2005 07:18:35 +0000 Subject: [PATCH] PR: MNG-788 bring back the "filtering" attribute in resources from m1 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@263841 13f79535-47bb-0310-9956-ffa450edef68 --- maven-model/maven.mdo | 2 +- .../maven/plugin/resources/ResourcesMojo.java | 54 ++++++++----------- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/maven-model/maven.mdo b/maven-model/maven.mdo index 0278c5bd70..f1d62fd81e 100644 --- a/maven-model/maven.mdo +++ b/maven-model/maven.mdo @@ -1935,7 +1935,7 @@ filtering - 3.0.0 + 3.0.0+ boolean false diff --git a/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java b/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java index 83229d1c07..65dfcb97be 100644 --- a/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java +++ b/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java @@ -97,40 +97,14 @@ public class ResourcesMojo public void execute() throws MojoExecutionException { - initializeFiltering(); copyResources( resources, outputDirectory ); } protected void copyResources( List resources, String outputDirectory ) throws MojoExecutionException { - try - { - for ( Iterator i = getJarResources( resources ).entrySet().iterator(); i.hasNext(); ) - { - Map.Entry entry = (Map.Entry) i.next(); - File source = (File) entry.getKey(); - String destination = (String) entry.getValue(); + initializeFiltering(); - File destinationFile = new File( outputDirectory, destination ); - - if ( !destinationFile.getParentFile().exists() ) - { - destinationFile.getParentFile().mkdirs(); - } - - copyFile( source, destinationFile ); - } - } - catch ( Exception e ) - { - // TODO: handle exception - throw new MojoExecutionException( "Error copying resources", e ); - } - } - - private Map getJarResources( List resources ) - { Map resourceEntries = new TreeMap(); for ( Iterator i = resources.iterator(); i.hasNext(); ) @@ -170,18 +144,32 @@ public class ResourcesMojo { String name = (String) j.next(); - String entryName = name; + String destination = name; if ( targetPath != null ) { - entryName = targetPath + "/" + name; + destination = targetPath + "/" + name; } - resourceEntries.put( new File( resource.getDirectory(), name ), entryName ); + File source = new File( resource.getDirectory(), name ); + + File destinationFile = new File( outputDirectory, destination ); + + if ( !destinationFile.getParentFile().exists() ) + { + destinationFile.getParentFile().mkdirs(); + } + + try + { + copyFile( source, destinationFile, resource.isFiltering() && filtering ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error copying resources", e ); + } } } - - return resourceEntries; } private void initializeFiltering() @@ -200,7 +188,7 @@ public class ResourcesMojo } } - private void copyFile( File from, File to ) + private void copyFile( File from, File to, boolean filtering ) throws IOException { if ( !filtering )