You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Olivier Lamy <ol...@apache.org> on 2009/08/20 00:11:29 UTC
Re: svn commit: r805991 - in /maven/plugins/trunk/maven-resources-plugin/src:
main/java/org/apache/maven/plugin/resources/ test/java/org/apache/maven/plugin/resources/
test/java/org/apache/maven/plugin/resources/stub/
Hi John,
AFAIK current resources plugin trunk already depends about
org.apache.maven.shared:maven-filtering:1.0-beta-3-SNAPSHOT
Thanks,
--
Olivier
2009/8/19 <jd...@apache.org>:
> Author: jdcasey
> Date: Wed Aug 19 21:53:17 2009
> New Revision: 805991
>
> URL: http://svn.apache.org/viewvc?rev=805991&view=rev
> Log:
> [MRESOURCES-81] Adding a flag to enable/disable escaping windows paths when filtering, then passing this on to the filtering wrappers directly, rather than allowing the filtering components to create the default wrappers by forcing windows-path-escaping. This can be simplified if the flag is passed through the resources execution instance, but that will require a new release of maven-filtering.
>
> Also adding unit tests for enabled and disabled path-escaping modes, along with a new method to clean up a build environment on the project stub class.
>
> Modified:
> maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
> maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
> maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java
>
> 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=805991&r1=805990&r2=805991&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 Wed Aug 19 21:53:17 2009
> @@ -30,6 +30,7 @@
> import org.apache.maven.plugin.AbstractMojo;
> import org.apache.maven.plugin.MojoExecutionException;
> import org.apache.maven.project.MavenProject;
> +import org.apache.maven.shared.filtering.MavenFileFilter;
> import org.apache.maven.shared.filtering.MavenFilteringException;
> import org.apache.maven.shared.filtering.MavenResourcesExecution;
> import org.apache.maven.shared.filtering.MavenResourcesFiltering;
> @@ -132,6 +133,18 @@
> * @since 2.3
> */
> protected List nonFilteredFileExtensions;
> +
> + /**
> + * Whether to escape backslashes and colons in windows-style paths.
> + * @parameter expression="${maven.resources.escapeWindowsPaths} default-value="false"
> + * @since 2.4
> + */
> + protected boolean escapeWindowsPaths;
> +
> + /**
> + * @component role-hint="default"
> + */
> + private MavenFileFilter mavenFileFilter;
>
> public void execute()
> throws MojoExecutionException
> @@ -152,6 +165,13 @@
> project, encoding, filters,
> Collections.EMPTY_LIST,
> session );
> +
> + List filterWrappers = mavenFileFilter.getDefaultFilterWrappers( project, filters, escapeWindowsPaths,
> + session, mavenResourcesExecution, null );
> +
> + mavenResourcesExecution.setFilterWrappers( filterWrappers );
> + mavenResourcesExecution.setUseDefaultFilterWrappers( false );
> +
> mavenResourcesExecution.setEscapeString( escapeString );
> mavenResourcesExecution.setOverwrite( overwrite );
> mavenResourcesExecution.setIncludeEmptyDirs( includeEmptyDirs );
>
> Modified: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
> URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java?rev=805991&r1=805990&r2=805991&view=diff
> ==============================================================================
> --- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java (original)
> +++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java Wed Aug 19 21:53:17 2009
> @@ -31,6 +31,7 @@
> import org.apache.maven.execution.MavenSession;
> import org.apache.maven.plugin.resources.stub.MavenProjectResourcesStub;
> import org.apache.maven.plugin.testing.AbstractMojoTestCase;
> +import org.apache.maven.shared.filtering.MavenFileFilter;
> import org.codehaus.plexus.util.FileUtils;
>
> public class ResourcesMojoTest
> @@ -40,7 +41,7 @@
>
> /**
> * test mojo lookup, test harness should be working fine
> - *
> + *
> * @throws Exception
> */
> public void testHarnessEnvironment()
> @@ -310,12 +311,13 @@
> project.setResourceFiltering( 0, true );
> project.setupBuildEnvironment();
>
> - //setVariableValueToObject(mojo,"encoding","UTF-8");
> + // setVariableValueToObject(mojo,"encoding","UTF-8");
> setVariableValueToObject( mojo, "project", project );
> setVariableValueToObject( mojo, "resources", resources );
> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> setVariableValueToObject( mojo, "filters", new LinkedList() );
> - MavenSession mavenSession = new MavenSession( null, null, null, null, null, null, null, System.getProperties(), null );
> + MavenSession mavenSession = new MavenSession( null, null, null, null, null, null, null, System.getProperties(),
> + null );
> setVariableValueToObject( mojo, "session", mavenSession );
> mojo.execute();
>
> @@ -323,7 +325,7 @@
>
> File userDir = new File( System.getProperty( "user.dir" ) );
> assertTrue( userDir.exists() );
> -
> +
> Properties props = new Properties();
> props.load( new FileInputStream( new File( resourcesDir + "/file4.txt" ) ) );
> File fileFromFiltering = new File( props.getProperty( "current-working-directory" ) );
> @@ -349,7 +351,7 @@
> project.addProperty( "user.dir", "FPJ kami!!!" );
> project.setupBuildEnvironment();
>
> - //setVariableValueToObject(mojo,"encoding","UTF-8");
> + // setVariableValueToObject(mojo,"encoding","UTF-8");
> setVariableValueToObject( mojo, "project", project );
> setVariableValueToObject( mojo, "resources", resources );
> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> @@ -370,8 +372,8 @@
> {
> File testPom = new File( getBasedir(), defaultPomFilePath );
> ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
> - MavenProjectResourcesStub project =
> - new MavenProjectResourcesStub( "resourcePojectProperty_Filtering_PropertyDestination" );
> + MavenProjectResourcesStub project = new MavenProjectResourcesStub(
> + "resourcePojectProperty_Filtering_PropertyDestination" );
> List resources = project.getBuild().getResources();
>
> assertNotNull( mojo );
> @@ -383,7 +385,7 @@
> // setup dummy property
> project.setDescription( "c:\\\\org\\apache\\test" );
>
> - //setVariableValueToObject(mojo,"encoding","UTF-8");
> + // setVariableValueToObject(mojo,"encoding","UTF-8");
> setVariableValueToObject( mojo, "project", project );
> setVariableValueToObject( mojo, "resources", resources );
> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> @@ -416,7 +418,7 @@
> project.setupBuildEnvironment();
> filterList.add( project.getResourcesDirectory() + "filter.properties" );
>
> - //setVariableValueToObject(mojo,"encoding","UTF-8");
> + // setVariableValueToObject(mojo,"encoding","UTF-8");
> setVariableValueToObject( mojo, "project", project );
> setVariableValueToObject( mojo, "resources", resources );
> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> @@ -430,41 +432,157 @@
> }
>
> /**
> - * Validates that a Filter token containing a project property will be
> - * resolved before the Filter is applied to the resources.
> - *
> + * Validates that a Filter token containing a project property will be resolved before the Filter is applied to the
> + * resources.
> + *
> * @throws Exception
> */
> public void testPropertyFiles_Filtering_TokensInFilters()
> throws Exception
> {
> - final File testPom = new File(getBasedir(), defaultPomFilePath);
> - final ResourcesMojo mojo = (ResourcesMojo) lookupMojo("resources", testPom);
> + final File testPom = new File( getBasedir(), defaultPomFilePath );
> + final ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
> final MavenProjectResourcesStub project = new MavenProjectResourcesStub(
> - "resourcePropertyFiles_Filtering_TokensInFilters");
> + "resourcePropertyFiles_Filtering_TokensInFilters" );
> final List resources = project.getBuild().getResources();
> final LinkedList filterList = new LinkedList();
>
> - assertNotNull(mojo);
> + assertNotNull( mojo );
>
> - project.addFile("file4.properties", "current working directory=${filter.token}");
> - project.addFile("filter.properties", "filter.token=${pom-property}");
> - project.setResourceFiltering(0, true);
> - project.addProperty("pom-property", "foobar");
> + project.addFile( "file4.properties", "current working directory=${filter.token}" );
> + project.addFile( "filter.properties", "filter.token=${pom-property}" );
> + project.setResourceFiltering( 0, true );
> + project.addProperty( "pom-property", "foobar" );
> project.setupBuildEnvironment();
> - filterList.add(project.getResourcesDirectory() + "filter.properties");
> + filterList.add( project.getResourcesDirectory() + "filter.properties" );
>
> // setVariableValueToObject(mojo,"encoding","UTF-8");
> - setVariableValueToObject(mojo, "project", project);
> - setVariableValueToObject(mojo, "resources", resources);
> - setVariableValueToObject(mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> - setVariableValueToObject(mojo, "filters", filterList);
> + setVariableValueToObject( mojo, "project", project );
> + setVariableValueToObject( mojo, "resources", resources );
> + setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> + setVariableValueToObject( mojo, "filters", filterList );
> mojo.execute();
> final String resourcesDir = project.getOutputDirectory();
> -
> +
> final String checkString = "current working directory=foobar";
>
> - assertContent(resourcesDir + "/file4.properties", checkString);
> + assertContent( resourcesDir + "/file4.properties", checkString );
> + }
> +
> + public void testWindowsPathEscapingDisabled()
> + throws Exception
> + {
> + File testPom = new File( getBasedir(), defaultPomFilePath );
> + ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
> + MavenProjectResourcesStub project = new MavenProjectResourcesStub( "windows-paths" );
> + List resources = project.getBuild().getResources();
> +
> + assertNotNull( mojo );
> +
> + project.getProperties().setProperty( "basePath", "C:\\Users\\Administrator" );
> + project.getProperties().setProperty( "docsPath", "${basePath}\\Documents" );
> +
> + project.addFile( "path-listing.txt", "base path is ${basePath}\ndocuments path is ${docsPath}" );
> + project.setResourceFiltering( 0, true );
> +
> + project.cleanBuildEnvironment();
> + project.setupBuildEnvironment();
> +
> + setVariableValueToObject( mojo, "project", project );
> + setVariableValueToObject( mojo, "resources", resources );
> + setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> + setVariableValueToObject( mojo, "filters", new LinkedList() );
> +
> + MavenFileFilter mff = null;
> + try
> + {
> + mff = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" );
> + setVariableValueToObject( mojo, "mavenFileFilter", mff );
> +
> + setVariableValueToObject( mojo, "escapeWindowsPaths", Boolean.FALSE );
> +
> + mojo.execute();
> + }
> + finally
> + {
> + if ( mff != null )
> + {
> + try
> + {
> + release( mff );
> + }
> + catch ( Exception e )
> + {
> + }
> + }
> + }
> +
> + String resourcesDir = project.getOutputDirectory();
> +
> + assertTrue( FileUtils.fileExists( new File( resourcesDir, "path-listing.txt" ).getAbsolutePath() ) );
> +
> + assertEquals( "base path is C:\\Users\\Administrator\ndocuments path is C:\\Users\\Administrator\\Documents",
> + FileUtils.fileRead( new File( resourcesDir, "path-listing.txt" ) ) );
> + }
> +
> + public void testWindowsPathEscapingEnabled()
> + throws Exception
> + {
> + File testPom = new File( getBasedir(), defaultPomFilePath );
> + ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
> + MavenProjectResourcesStub project = new MavenProjectResourcesStub( "windows-paths" );
> + List resources = project.getBuild().getResources();
> +
> + assertNotNull( mojo );
> +
> + project.getProperties().setProperty( "basePath", "C:\\Users\\Administrator" );
> + project.getProperties().setProperty( "docsPath", "${basePath}\\Documents" );
> +
> + project.addFile( "path-listing.txt", "base path is ${basePath}\ndocuments path is ${docsPath}" );
> + project.setResourceFiltering( 0, true );
> +
> + project.cleanBuildEnvironment();
> + project.setupBuildEnvironment();
> +
> + setVariableValueToObject( mojo, "project", project );
> + setVariableValueToObject( mojo, "resources", resources );
> + setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
> + setVariableValueToObject( mojo, "filters", new LinkedList() );
> +
> + MavenFileFilter mff = null;
> + try
> + {
> + mff = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" );
> + setVariableValueToObject( mojo, "mavenFileFilter", mff );
> +
> + setVariableValueToObject( mojo, "escapeWindowsPaths", Boolean.TRUE );
> +
> + mojo.execute();
> + }
> + finally
> + {
> + if ( mff != null )
> + {
> + try
> + {
> + release( mff );
> + }
> + catch ( Exception e )
> + {
> + }
> + }
> + }
> +
> + String resourcesDir = project.getOutputDirectory();
> +
> + assertTrue( FileUtils.fileExists( new File( resourcesDir, "path-listing.txt" ).getAbsolutePath() ) );
> +
> + // FIXME See http://jira.codehaus.org/browse/MSHARED-121
> +// assertEquals( "base path is C:\\\\Users\\\\Administrator\ndocuments path is C:\\\\Users\\\\Administrator\\\\Documents",
> +// FileUtils.fileRead( new File( resourcesDir, "path-listing.txt" ) ) );
> +
> + assertEquals( "base path is C:\\\\Users\\\\Administrator\ndocuments path is C:\\\\Users\\\\Administrator\\Documents",
> + FileUtils.fileRead( new File( resourcesDir, "path-listing.txt" ) ) );
> }
>
> /**
>
> Modified: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java
> URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java?rev=805991&r1=805990&r2=805991&view=diff
> ==============================================================================
> --- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java (original)
> +++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java Wed Aug 19 21:53:17 2009
> @@ -161,6 +161,30 @@
> build.setOutputDirectory( outputDirectory );
> build.setTestOutputDirectory( testOutputDirectory );
> }
> +
> + public void cleanBuildEnvironment()
> + throws Exception
> + {
> + if ( FileUtils.fileExists( resourcesDirectory ) )
> + {
> + FileUtils.deleteDirectory( resourcesDirectory );
> + }
> +
> + if ( FileUtils.fileExists( testResourcesDirectory ) )
> + {
> + FileUtils.deleteDirectory( testResourcesDirectory );
> + }
> +
> + if ( FileUtils.fileExists( outputDirectory ) )
> + {
> + FileUtils.deleteDirectory( outputDirectory );
> + }
> +
> + if ( FileUtils.fileExists( testOutputDirectory ) )
> + {
> + FileUtils.deleteDirectory( testOutputDirectory );
> + }
> + }
>
> public void setupBuildEnvironment()
> throws Exception
>
>
>
--
Olivier
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r805991 - in /maven/plugins/trunk/maven-resources-plugin/src:
main/java/org/apache/maven/plugin/resources/ test/java/org/apache/maven/plugin/resources/
test/java/org/apache/maven/plugin/resources/stub/
Posted by Benjamin Bentmann <be...@udo.edu>.
John Casey wrote:
> Since maven-filtering is recently released (or in the process of
> releasing) is this snapshot dependency really necessary
IIRC, the reason for the snapshot dependency was to get MSHARED-93 out
into IDEs.
Benjamin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: svn commit: r805991 - in /maven/plugins/trunk/maven-resources-plugin/src:
main/java/org/apache/maven/plugin/resources/ test/java/org/apache/maven/plugin/resources/
test/java/org/apache/maven/plugin/resources/stub/
Posted by John Casey <jd...@commonjava.org>.
Since maven-filtering is recently released (or in the process of
releasing) is this snapshot dependency really necessary, or is it a
matter of upgrading something out of habit to the next snapshot? I'm
hoping to get a release of this plugin out before long, and didn't want
to clog up the release train unnecessarily with more dependencies than I
needed...
-j
Olivier Lamy wrote:
> Hi John,
> AFAIK current resources plugin trunk already depends about
> org.apache.maven.shared:maven-filtering:1.0-beta-3-SNAPSHOT
>
> Thanks,
> --
> Olivier
>
> 2009/8/19 <jd...@apache.org>:
>> Author: jdcasey
>> Date: Wed Aug 19 21:53:17 2009
>> New Revision: 805991
>>
>> URL: http://svn.apache.org/viewvc?rev=805991&view=rev
>> Log:
>> [MRESOURCES-81] Adding a flag to enable/disable escaping windows paths when filtering, then passing this on to the filtering wrappers directly, rather than allowing the filtering components to create the default wrappers by forcing windows-path-escaping. This can be simplified if the flag is passed through the resources execution instance, but that will require a new release of maven-filtering.
>>
>> Also adding unit tests for enabled and disabled path-escaping modes, along with a new method to clean up a build environment on the project stub class.
>>
>> Modified:
>> maven/plugins/trunk/maven-resources-plugin/src/main/java/org/apache/maven/plugin/resources/ResourcesMojo.java
>> maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
>> maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java
>>
>> 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=805991&r1=805990&r2=805991&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 Wed Aug 19 21:53:17 2009
>> @@ -30,6 +30,7 @@
>> import org.apache.maven.plugin.AbstractMojo;
>> import org.apache.maven.plugin.MojoExecutionException;
>> import org.apache.maven.project.MavenProject;
>> +import org.apache.maven.shared.filtering.MavenFileFilter;
>> import org.apache.maven.shared.filtering.MavenFilteringException;
>> import org.apache.maven.shared.filtering.MavenResourcesExecution;
>> import org.apache.maven.shared.filtering.MavenResourcesFiltering;
>> @@ -132,6 +133,18 @@
>> * @since 2.3
>> */
>> protected List nonFilteredFileExtensions;
>> +
>> + /**
>> + * Whether to escape backslashes and colons in windows-style paths.
>> + * @parameter expression="${maven.resources.escapeWindowsPaths} default-value="false"
>> + * @since 2.4
>> + */
>> + protected boolean escapeWindowsPaths;
>> +
>> + /**
>> + * @component role-hint="default"
>> + */
>> + private MavenFileFilter mavenFileFilter;
>>
>> public void execute()
>> throws MojoExecutionException
>> @@ -152,6 +165,13 @@
>> project, encoding, filters,
>> Collections.EMPTY_LIST,
>> session );
>> +
>> + List filterWrappers = mavenFileFilter.getDefaultFilterWrappers( project, filters, escapeWindowsPaths,
>> + session, mavenResourcesExecution, null );
>> +
>> + mavenResourcesExecution.setFilterWrappers( filterWrappers );
>> + mavenResourcesExecution.setUseDefaultFilterWrappers( false );
>> +
>> mavenResourcesExecution.setEscapeString( escapeString );
>> mavenResourcesExecution.setOverwrite( overwrite );
>> mavenResourcesExecution.setIncludeEmptyDirs( includeEmptyDirs );
>>
>> Modified: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java
>> URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java?rev=805991&r1=805990&r2=805991&view=diff
>> ==============================================================================
>> --- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java (original)
>> +++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/ResourcesMojoTest.java Wed Aug 19 21:53:17 2009
>> @@ -31,6 +31,7 @@
>> import org.apache.maven.execution.MavenSession;
>> import org.apache.maven.plugin.resources.stub.MavenProjectResourcesStub;
>> import org.apache.maven.plugin.testing.AbstractMojoTestCase;
>> +import org.apache.maven.shared.filtering.MavenFileFilter;
>> import org.codehaus.plexus.util.FileUtils;
>>
>> public class ResourcesMojoTest
>> @@ -40,7 +41,7 @@
>>
>> /**
>> * test mojo lookup, test harness should be working fine
>> - *
>> + *
>> * @throws Exception
>> */
>> public void testHarnessEnvironment()
>> @@ -310,12 +311,13 @@
>> project.setResourceFiltering( 0, true );
>> project.setupBuildEnvironment();
>>
>> - //setVariableValueToObject(mojo,"encoding","UTF-8");
>> + // setVariableValueToObject(mojo,"encoding","UTF-8");
>> setVariableValueToObject( mojo, "project", project );
>> setVariableValueToObject( mojo, "resources", resources );
>> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> setVariableValueToObject( mojo, "filters", new LinkedList() );
>> - MavenSession mavenSession = new MavenSession( null, null, null, null, null, null, null, System.getProperties(), null );
>> + MavenSession mavenSession = new MavenSession( null, null, null, null, null, null, null, System.getProperties(),
>> + null );
>> setVariableValueToObject( mojo, "session", mavenSession );
>> mojo.execute();
>>
>> @@ -323,7 +325,7 @@
>>
>> File userDir = new File( System.getProperty( "user.dir" ) );
>> assertTrue( userDir.exists() );
>> -
>> +
>> Properties props = new Properties();
>> props.load( new FileInputStream( new File( resourcesDir + "/file4.txt" ) ) );
>> File fileFromFiltering = new File( props.getProperty( "current-working-directory" ) );
>> @@ -349,7 +351,7 @@
>> project.addProperty( "user.dir", "FPJ kami!!!" );
>> project.setupBuildEnvironment();
>>
>> - //setVariableValueToObject(mojo,"encoding","UTF-8");
>> + // setVariableValueToObject(mojo,"encoding","UTF-8");
>> setVariableValueToObject( mojo, "project", project );
>> setVariableValueToObject( mojo, "resources", resources );
>> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> @@ -370,8 +372,8 @@
>> {
>> File testPom = new File( getBasedir(), defaultPomFilePath );
>> ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
>> - MavenProjectResourcesStub project =
>> - new MavenProjectResourcesStub( "resourcePojectProperty_Filtering_PropertyDestination" );
>> + MavenProjectResourcesStub project = new MavenProjectResourcesStub(
>> + "resourcePojectProperty_Filtering_PropertyDestination" );
>> List resources = project.getBuild().getResources();
>>
>> assertNotNull( mojo );
>> @@ -383,7 +385,7 @@
>> // setup dummy property
>> project.setDescription( "c:\\\\org\\apache\\test" );
>>
>> - //setVariableValueToObject(mojo,"encoding","UTF-8");
>> + // setVariableValueToObject(mojo,"encoding","UTF-8");
>> setVariableValueToObject( mojo, "project", project );
>> setVariableValueToObject( mojo, "resources", resources );
>> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> @@ -416,7 +418,7 @@
>> project.setupBuildEnvironment();
>> filterList.add( project.getResourcesDirectory() + "filter.properties" );
>>
>> - //setVariableValueToObject(mojo,"encoding","UTF-8");
>> + // setVariableValueToObject(mojo,"encoding","UTF-8");
>> setVariableValueToObject( mojo, "project", project );
>> setVariableValueToObject( mojo, "resources", resources );
>> setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> @@ -430,41 +432,157 @@
>> }
>>
>> /**
>> - * Validates that a Filter token containing a project property will be
>> - * resolved before the Filter is applied to the resources.
>> - *
>> + * Validates that a Filter token containing a project property will be resolved before the Filter is applied to the
>> + * resources.
>> + *
>> * @throws Exception
>> */
>> public void testPropertyFiles_Filtering_TokensInFilters()
>> throws Exception
>> {
>> - final File testPom = new File(getBasedir(), defaultPomFilePath);
>> - final ResourcesMojo mojo = (ResourcesMojo) lookupMojo("resources", testPom);
>> + final File testPom = new File( getBasedir(), defaultPomFilePath );
>> + final ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
>> final MavenProjectResourcesStub project = new MavenProjectResourcesStub(
>> - "resourcePropertyFiles_Filtering_TokensInFilters");
>> + "resourcePropertyFiles_Filtering_TokensInFilters" );
>> final List resources = project.getBuild().getResources();
>> final LinkedList filterList = new LinkedList();
>>
>> - assertNotNull(mojo);
>> + assertNotNull( mojo );
>>
>> - project.addFile("file4.properties", "current working directory=${filter.token}");
>> - project.addFile("filter.properties", "filter.token=${pom-property}");
>> - project.setResourceFiltering(0, true);
>> - project.addProperty("pom-property", "foobar");
>> + project.addFile( "file4.properties", "current working directory=${filter.token}" );
>> + project.addFile( "filter.properties", "filter.token=${pom-property}" );
>> + project.setResourceFiltering( 0, true );
>> + project.addProperty( "pom-property", "foobar" );
>> project.setupBuildEnvironment();
>> - filterList.add(project.getResourcesDirectory() + "filter.properties");
>> + filterList.add( project.getResourcesDirectory() + "filter.properties" );
>>
>> // setVariableValueToObject(mojo,"encoding","UTF-8");
>> - setVariableValueToObject(mojo, "project", project);
>> - setVariableValueToObject(mojo, "resources", resources);
>> - setVariableValueToObject(mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> - setVariableValueToObject(mojo, "filters", filterList);
>> + setVariableValueToObject( mojo, "project", project );
>> + setVariableValueToObject( mojo, "resources", resources );
>> + setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> + setVariableValueToObject( mojo, "filters", filterList );
>> mojo.execute();
>> final String resourcesDir = project.getOutputDirectory();
>> -
>> +
>> final String checkString = "current working directory=foobar";
>>
>> - assertContent(resourcesDir + "/file4.properties", checkString);
>> + assertContent( resourcesDir + "/file4.properties", checkString );
>> + }
>> +
>> + public void testWindowsPathEscapingDisabled()
>> + throws Exception
>> + {
>> + File testPom = new File( getBasedir(), defaultPomFilePath );
>> + ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
>> + MavenProjectResourcesStub project = new MavenProjectResourcesStub( "windows-paths" );
>> + List resources = project.getBuild().getResources();
>> +
>> + assertNotNull( mojo );
>> +
>> + project.getProperties().setProperty( "basePath", "C:\\Users\\Administrator" );
>> + project.getProperties().setProperty( "docsPath", "${basePath}\\Documents" );
>> +
>> + project.addFile( "path-listing.txt", "base path is ${basePath}\ndocuments path is ${docsPath}" );
>> + project.setResourceFiltering( 0, true );
>> +
>> + project.cleanBuildEnvironment();
>> + project.setupBuildEnvironment();
>> +
>> + setVariableValueToObject( mojo, "project", project );
>> + setVariableValueToObject( mojo, "resources", resources );
>> + setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> + setVariableValueToObject( mojo, "filters", new LinkedList() );
>> +
>> + MavenFileFilter mff = null;
>> + try
>> + {
>> + mff = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" );
>> + setVariableValueToObject( mojo, "mavenFileFilter", mff );
>> +
>> + setVariableValueToObject( mojo, "escapeWindowsPaths", Boolean.FALSE );
>> +
>> + mojo.execute();
>> + }
>> + finally
>> + {
>> + if ( mff != null )
>> + {
>> + try
>> + {
>> + release( mff );
>> + }
>> + catch ( Exception e )
>> + {
>> + }
>> + }
>> + }
>> +
>> + String resourcesDir = project.getOutputDirectory();
>> +
>> + assertTrue( FileUtils.fileExists( new File( resourcesDir, "path-listing.txt" ).getAbsolutePath() ) );
>> +
>> + assertEquals( "base path is C:\\Users\\Administrator\ndocuments path is C:\\Users\\Administrator\\Documents",
>> + FileUtils.fileRead( new File( resourcesDir, "path-listing.txt" ) ) );
>> + }
>> +
>> + public void testWindowsPathEscapingEnabled()
>> + throws Exception
>> + {
>> + File testPom = new File( getBasedir(), defaultPomFilePath );
>> + ResourcesMojo mojo = (ResourcesMojo) lookupMojo( "resources", testPom );
>> + MavenProjectResourcesStub project = new MavenProjectResourcesStub( "windows-paths" );
>> + List resources = project.getBuild().getResources();
>> +
>> + assertNotNull( mojo );
>> +
>> + project.getProperties().setProperty( "basePath", "C:\\Users\\Administrator" );
>> + project.getProperties().setProperty( "docsPath", "${basePath}\\Documents" );
>> +
>> + project.addFile( "path-listing.txt", "base path is ${basePath}\ndocuments path is ${docsPath}" );
>> + project.setResourceFiltering( 0, true );
>> +
>> + project.cleanBuildEnvironment();
>> + project.setupBuildEnvironment();
>> +
>> + setVariableValueToObject( mojo, "project", project );
>> + setVariableValueToObject( mojo, "resources", resources );
>> + setVariableValueToObject( mojo, "outputDirectory", new File( project.getBuild().getOutputDirectory() ) );
>> + setVariableValueToObject( mojo, "filters", new LinkedList() );
>> +
>> + MavenFileFilter mff = null;
>> + try
>> + {
>> + mff = (MavenFileFilter) lookup( MavenFileFilter.class.getName(), "default" );
>> + setVariableValueToObject( mojo, "mavenFileFilter", mff );
>> +
>> + setVariableValueToObject( mojo, "escapeWindowsPaths", Boolean.TRUE );
>> +
>> + mojo.execute();
>> + }
>> + finally
>> + {
>> + if ( mff != null )
>> + {
>> + try
>> + {
>> + release( mff );
>> + }
>> + catch ( Exception e )
>> + {
>> + }
>> + }
>> + }
>> +
>> + String resourcesDir = project.getOutputDirectory();
>> +
>> + assertTrue( FileUtils.fileExists( new File( resourcesDir, "path-listing.txt" ).getAbsolutePath() ) );
>> +
>> + // FIXME See http://jira.codehaus.org/browse/MSHARED-121
>> +// assertEquals( "base path is C:\\\\Users\\\\Administrator\ndocuments path is C:\\\\Users\\\\Administrator\\\\Documents",
>> +// FileUtils.fileRead( new File( resourcesDir, "path-listing.txt" ) ) );
>> +
>> + assertEquals( "base path is C:\\\\Users\\\\Administrator\ndocuments path is C:\\\\Users\\\\Administrator\\Documents",
>> + FileUtils.fileRead( new File( resourcesDir, "path-listing.txt" ) ) );
>> }
>>
>> /**
>>
>> Modified: maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java
>> URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java?rev=805991&r1=805990&r2=805991&view=diff
>> ==============================================================================
>> --- maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java (original)
>> +++ maven/plugins/trunk/maven-resources-plugin/src/test/java/org/apache/maven/plugin/resources/stub/MavenProjectBuildStub.java Wed Aug 19 21:53:17 2009
>> @@ -161,6 +161,30 @@
>> build.setOutputDirectory( outputDirectory );
>> build.setTestOutputDirectory( testOutputDirectory );
>> }
>> +
>> + public void cleanBuildEnvironment()
>> + throws Exception
>> + {
>> + if ( FileUtils.fileExists( resourcesDirectory ) )
>> + {
>> + FileUtils.deleteDirectory( resourcesDirectory );
>> + }
>> +
>> + if ( FileUtils.fileExists( testResourcesDirectory ) )
>> + {
>> + FileUtils.deleteDirectory( testResourcesDirectory );
>> + }
>> +
>> + if ( FileUtils.fileExists( outputDirectory ) )
>> + {
>> + FileUtils.deleteDirectory( outputDirectory );
>> + }
>> +
>> + if ( FileUtils.fileExists( testOutputDirectory ) )
>> + {
>> + FileUtils.deleteDirectory( testOutputDirectory );
>> + }
>> + }
>>
>> public void setupBuildEnvironment()
>> throws Exception
>>
>>
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org