Author: olamy Date: Wed Sep 10 04:05:15 2008 New Revision: 693786 URL: http://svn.apache.org/viewvc?rev=693786&view=rev Log: more simple as this
Modified: maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java maven/shared/trunk/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java Modified: maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java?rev=693786&r1=693785&r2=693786&view=diff ============================================================================== --- maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java (original) +++ maven/shared/trunk/maven-filtering/src/main/java/org/apache/maven/shared/filtering/MavenResourcesExecution.java Wed Sep 10 04:05:15 2008 @@ -261,7 +261,7 @@ * @param endRegExp * @param startToken * @param endToken - * @deprecated this doesn't support escaping + * @deprecated this doesn't support escaping use [EMAIL PROTECTED] #addFilerWrapperWithEscaping(ValueSource, String, String, String)} */ public void addFilerWrapper( final ValueSource valueSource, final String startRegExp, final String endRegExp, final String startToken, final String endToken ) @@ -279,24 +279,27 @@ /** * @param valueSource - * @param startRegExp - * @param endRegExp - * @param startToken - * @param endToken + * @param startExp start token like ${ + * @param endExp endToken } * @since 1.0-beta-2 * @param escapeString */ - public void addFilerWrapperWithEscaping( final ValueSource valueSource, final String startRegExp, final String endRegExp, - final String startToken, final String endToken, final String escapeString ) + public void addFilerWrapperWithEscaping( final ValueSource valueSource, final String startExp, final String endExp, + final String escapeString ) { addFilterWrapper( new FileUtils.FilterWrapper() { public Reader getReader( Reader reader ) { - StringSearchInterpolator propertiesInterpolator = new StringSearchInterpolator( startRegExp, endRegExp ); + StringSearchInterpolator propertiesInterpolator = new StringSearchInterpolator( startExp, endExp ); propertiesInterpolator.addValueSource( valueSource ); propertiesInterpolator.setEscapeString( escapeString ); - return new InterpolatorFilterReader( reader, propertiesInterpolator, startToken, endToken ); + InterpolatorFilterReader interpolatorFilterReader = new InterpolatorFilterReader( + reader, + propertiesInterpolator, + startExp, endExp ); + interpolatorFilterReader.setInterpolateWithPrefixPattern( false ); + return interpolatorFilterReader; } } ); } Modified: maven/shared/trunk/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java?rev=693786&r1=693785&r2=693786&view=diff ============================================================================== --- maven/shared/trunk/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java (original) +++ maven/shared/trunk/maven-filtering/src/test/java/org/apache/maven/shared/filtering/DefaultMavenResourcesFilteringTest.java Wed Sep 10 04:05:15 2008 @@ -1,22 +1,18 @@ package org.apache.maven.shared.filtering; /* - * 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. + * 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.File; @@ -33,19 +29,19 @@ import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; -/** +/* * @author <a href="mailto:[EMAIL PROTECTED]">olamy</a> + * * @since 28 janv. 08 + * * @version $Id$ */ public class DefaultMavenResourcesFilteringTest extends PlexusTestCase { - File outputDirectory = new File(getBasedir(), "target/DefaultMavenResourcesFilteringTest"); - + File outputDirectory = new File( getBasedir(), "target/DefaultMavenResourcesFilteringTest" ); - protected void setUp() throws Exception { @@ -152,7 +148,7 @@ assertEquals( "org.apache", result.get( "groupId" ) ); assertEquals( "bar", result.get( "foo" ) ); assertEquals( "${foo.version}", result.get( "fooVersion" ) ); - + assertEquals( "@@", result.getProperty( "emptyexpression" ) ); assertEquals( "${}", result.getProperty( "emptyexpression2" ) ); assertEquals( System.getProperty( "user.dir" ), result.getProperty( "userDir" ) ); @@ -208,7 +204,8 @@ nonFilteredFileExtensions, new StubMavenSession() ); - mavenResourcesExecution.addFilerWrapper( new MavenProjectValueSource( mavenProject, true ), "\\@", "(.+?)\\@", "@", "@" ); + mavenResourcesExecution.addFilerWrapperWithEscaping( new MavenProjectValueSource( mavenProject, true ), "@", + "@", null ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); Properties result = PropertyUtils .loadPropertyFile( new File( outputDirectory, "maven-resources-filtering.txt" ), null ); @@ -320,13 +317,13 @@ Collections.EMPTY_LIST, new StubMavenSession() ); mavenResourcesFiltering.filterResources( mavenResourcesExecution ); - + File[] files = outputDirectory.listFiles(); assertEquals( 1, files.length ); assertEquals( "includefile.txt", files[0].getName() ); - - } - + + } + public void testIncludeOneFileAndDirectory() throws Exception { @@ -367,8 +364,8 @@ includeFile = new File( new File( outputDirectory, "includedir" ), "include.txt" ); assertTrue( includeFile.exists() ); - } - + } + public void testExcludeOneFile() throws Exception { @@ -414,6 +411,6 @@ File excludeDir = new File( outputDirectory, "excludedir" ); assertFalse( excludeDir.exists() ); - } - + } + }