Author: olamy Date: Tue Sep 23 15:04:22 2008 New Revision: 698374 URL: http://svn.apache.org/viewvc?rev=698374&view=rev Log: [MRESOURCES-74] configuring file extension to not filtering
Added: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml (with props) maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/duke-beerjpg.img (with props) maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt (with props) maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/happy_duke.gif (with props) maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh (with props) Modified: maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java Added: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml?rev=698374&view=auto ============================================================================== --- maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml (added) +++ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml Tue Sep 23 15:04:22 2008 @@ -0,0 +1,56 @@ +<?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>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin-binaries-filtering</artifactId> + <packaging>jar</packaging> + <version>1.0-SNAPSHOT</version> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + <pluginManagement> + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>@pom.version@</version> + </plugin> + </plugins> + </pluginManagement> + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>@pom.version@</version> + <!--configuration> + <nonFilteredFileExtensions> + <nonFilteredFileExtension>pdf</nonFilteredFileExtension> + </nonFilteredFileExtensions> + </configuration--> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/duke-beerjpg.img URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/duke-beerjpg.img?rev=698374&view=auto ============================================================================== Binary file - no diff available. Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/duke-beerjpg.img ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt?rev=698374&view=auto ============================================================================== --- maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt (added) +++ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt Tue Sep 23 15:04:22 2008 @@ -0,0 +1 @@ +version=${pom.version} \ No newline at end of file Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/file.txt ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/happy_duke.gif URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/happy_duke.gif?rev=698374&view=auto ============================================================================== Binary file - no diff available. Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/src/main/resources/happy_duke.gif ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh?rev=698374&view=auto ============================================================================== --- maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh (added) +++ maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh Tue Sep 23 15:04:22 2008 @@ -0,0 +1,95 @@ + +/* + * 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 java.io.*; +import org.codehaus.plexus.util.*; + +boolean result = true; + +filesAreIdentical( File expected, File current ) + throws IOException +{ + if ( expected.length() != current.length() ) + { + return false; + } + FileInputStream expectedIn = new FileInputStream( expected ); + FileInputStream currentIn = new FileInputStream( current ); + try + { + byte[] expectedBuffer = IOUtil.toByteArray( expectedIn ); + + byte[] currentBuffer = IOUtil.toByteArray( currentIn ); + if (expectedBuffer.length != currentBuffer.length) + { + return false; + } + for (int i = 0,size = expectedBuffer.length;i<size;i++) + { + if(expectedBuffer[i]!= currentBuffer[i]) + { + return false; + } + } + } + finally + { + expectedIn.close(); + currentIn.close(); + } + return true; +} + +try +{ + + File originalImg = new File( basedir, "src/main/resources/happy_duke.gif" ); + + File targetImg = new File( basedir, "target/classes/happy_duke.gif" ); + + boolean identical = filesAreIdentical( originalImg, targetImg ); + + if (!identical) + { + System.err.println( "filtered images happy_duke.gif are not identical." ); + return false; + } + + originalImg = new File( basedir, "src/main/resources/duke-beerjpg.img" ); + + targetImg = new File( basedir, "target/classes/duke-beerjpg.img" ); + + identical = filesAreIdentical( originalImg, targetImg ); + + if (!identical) + { + System.err.println( "filtered .img duke-beer.jpg.img are not identical." ); + return false; + } + +} +catch( Throwable e ) +{ + e.printStackTrace(); + result = false; +} + +return result; + Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-resources-plugin/src/it/binaries-filtering/verify.bsh ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java?rev=698374&r1=698373&r2=698374&view=diff ============================================================================== --- maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java (original) +++ maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java Tue Sep 23 15:04:22 2008 @@ -125,6 +125,13 @@ * @since 2.3 */ protected boolean includeEmptyDirs; + + /** + * Additionnal file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png) + * @parameter + * @since 2.3 + */ + protected List nonFilteredFileExtensions; public void execute() throws MojoExecutionException @@ -148,6 +155,10 @@ mavenResourcesExecution.setEscapeString( escapeString ); mavenResourcesExecution.setOverwrite( overwrite ); mavenResourcesExecution.setIncludeEmptyDirs( includeEmptyDirs ); + if ( nonFilteredFileExtensions != null ) + { + mavenResourcesExecution.setNonFilteredFileExtensions( nonFilteredFileExtensions ); + } mavenResourcesFiltering.filterResources( mavenResourcesExecution ); } catch ( MavenFilteringException e )