You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/09/23 09:56:53 UTC
svn commit: r449205 - in /maven/plugins/trunk/maven-war-plugin/src:
main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
Author: brett
Date: Sat Sep 23 00:56:52 2006
New Revision: 449205
URL: http://svn.apache.org/viewvc?view=rev&rev=449205
Log:
[MWAR-67] webResource filtering needs filter
Submitted by: Franz Allan Valencia See
Modified:
maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?view=diff&rev=449205&r1=449204&r2=449205
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java Sat Sep 23 00:56:52 2006
@@ -352,9 +352,12 @@
private Map getBuildFilterProperties()
throws MojoExecutionException
{
+
+ Map filterProperties = new Properties();
+
// System properties
- Map filterProperties = new Properties( System.getProperties() );
-
+ filterProperties.putAll( System.getProperties() );
+
// Project properties
filterProperties.putAll( project.getProperties() );
Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java?view=diff&rev=449205&r1=449204&r2=449205
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java Sat Sep 23 00:56:52 2006
@@ -661,26 +661,20 @@
File webAppResource = new File( getTestDirectory(), testId + "-test-data/resources" );
File sampleResource = new File( webAppResource, "custom-setting.cfg" );
File sampleResourceWDir = new File( webAppResource, "custom-config/custom-setting.cfg" );
- File filterFile = new File( getTestDirectory(), testId + "-test-data/filters/filter.properties" );
List filterList = new LinkedList();
ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
createFile( sampleResource );
createFile( sampleResourceWDir );
- createFile( filterFile );
- filterList.add( filterFile.getAbsolutePath() );
- // prepare web resources and filters
- String content = "resource_key=${resource_value}\n";
- content += "system_key=${user.dir}\n";
+ // prepare web resources
+ String content = "system_key=${user.dir}\n";
content += "project_key=${is_this_simple}\n";
content += "project_name=${project.name}\n";
content += "system_property=${system.property}\n";
FileUtils.fileWrite( sampleResourceWDir.getAbsolutePath(), content );
FileUtils.fileWrite( sampleResource.getAbsolutePath(), content );
- FileUtils.fileWrite( filterFile.getAbsolutePath(), "resource_value=this_is_filtered" );
-
System.setProperty( "system.property", "system-property-value" );
// configure mojo
@@ -707,8 +701,6 @@
content = FileUtils.fileRead( expectedResourceWDirFile );
BufferedReader reader = new BufferedReader( new StringReader( content ) );
- assertEquals( "error in filtering using filter files", "resource_key=this_is_filtered", reader.readLine() );
-
assertEquals( "error in filtering using System properties", "system_key=" + System.getProperty( "user.dir" ),
reader.readLine() );
@@ -728,6 +720,31 @@
content = FileUtils.fileRead( expectedResourceWDirFile );
reader = new BufferedReader( new StringReader( content ) );
+ assertEquals( "error in filtering using System properties", "system_key=" + System.getProperty( "user.dir" ),
+ reader.readLine() );
+
+ assertEquals( "error in filtering using project properties", "project_key=i_think_so", reader.readLine() );
+
+ assertEquals( "error in filtering using project properties", "project_name=Test Project ", reader.readLine() );
+
+ assertEquals( "error in filtering using System properties", "system_property=new-system-property-value",
+ reader.readLine() );
+
+ // update property, and generate again
+ File filterFile = new File( getTestDirectory(), testId + "-test-data/filters/filter.properties" );
+ createFile( filterFile );
+ filterList.add( filterFile.getAbsolutePath() );
+ content = "resource_key=${resource_value}\n" + content;
+ FileUtils.fileWrite( sampleResourceWDir.getAbsolutePath(), content );
+ FileUtils.fileWrite( sampleResource.getAbsolutePath(), content );
+ FileUtils.fileWrite( filterFile.getAbsolutePath(), "resource_value=this_is_filtered" );
+
+ mojo.execute();
+
+ // validate filtered file
+ content = FileUtils.fileRead( expectedResourceWDirFile );
+ reader = new BufferedReader( new StringReader( content ) );
+
assertEquals( "error in filtering using filter files", "resource_key=this_is_filtered", reader.readLine() );
assertEquals( "error in filtering using System properties", "system_key=" + System.getProperty( "user.dir" ),
@@ -739,16 +756,15 @@
assertEquals( "error in filtering using System properties", "system_property=new-system-property-value",
reader.readLine() );
+
// house keeping
expectedWebSourceFile.delete();
expectedWebSource2File.delete();
expectedResourceFile.delete();
expectedResourceWDirFile.delete();
-
-
}
-
+
public void testExplodedWar_WithSourceIncludeExclude()
throws Exception
{