From 26de9f77d085b990e888e569de338490ae5ff899 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Fri, 12 Aug 2005 02:25:26 +0000 Subject: [PATCH] Fixing problem with mojo configuration merges between parameter configuration keyed by alias and by name within the POM, along with configuration within the MojoDescriptor. Also adding an IT that will indirectly test that default parameter values are not being disturbed during the merge process. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@232185 13f79535-47bb-0310-9956-ffa450edef68 --- maven-core-it/README.txt | 7 ++-- maven-core-it/integration-tests.txt | 2 +- maven-core-it/it0048/expected-results.txt | 1 + maven-core-it/it0048/goals.txt | 1 + maven-core-it/it0048/pom.xml | 16 ++++++++ .../java/org/apache/maven/it0001/Person.java | 16 ++++++++ .../src/main/resources/it0001.properties | 1 + .../org/apache/maven/it0001/PersonTest.java | 40 +++++++++++++++++++ .../maven/plugin/DefaultPluginManager.java | 18 +++++---- 9 files changed, 90 insertions(+), 12 deletions(-) create mode 100644 maven-core-it/it0048/expected-results.txt create mode 100644 maven-core-it/it0048/goals.txt create mode 100644 maven-core-it/it0048/pom.xml create mode 100644 maven-core-it/it0048/src/main/java/org/apache/maven/it0001/Person.java create mode 100644 maven-core-it/it0048/src/main/resources/it0001.properties create mode 100644 maven-core-it/it0048/src/test/java/org/apache/maven/it0001/PersonTest.java diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index 40635c7027..2bbaf8f40a 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -131,10 +131,11 @@ it0045: Test non-reactor behavior when plugin declares "@requiresProject false" it0046: Test fail-never reactor behavior. Forces an exception to be thrown in the first module, but checks that the second modules is built. -it0047: Test the use case for having a compile time dependency be transitive: when you extend a class you need its - dependencies at compile time. +it0047: Test the use case for having a compile time dependency be transitive: + when you extend a class you need its dependencies at compile time. -it0048: REMOVED. REPLACED WITH UNIT TESTS IN maven-project. +it0048: Verify that default values for mojo parameters are working (indirectly, + by verifying that the Surefire mojo is functioning correctly). it0049: Test parameter alias usage. diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 3f1aef5ca3..17248120fb 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,5 +1,5 @@ it0049 -#it0048 +it0048 it0047 it0046 it0045 diff --git a/maven-core-it/it0048/expected-results.txt b/maven-core-it/it0048/expected-results.txt new file mode 100644 index 0000000000..676397c4a1 --- /dev/null +++ b/maven-core-it/it0048/expected-results.txt @@ -0,0 +1 @@ +target/testFileOutput.txt diff --git a/maven-core-it/it0048/goals.txt b/maven-core-it/it0048/goals.txt new file mode 100644 index 0000000000..9daeafb986 --- /dev/null +++ b/maven-core-it/it0048/goals.txt @@ -0,0 +1 @@ +test diff --git a/maven-core-it/it0048/pom.xml b/maven-core-it/it0048/pom.xml new file mode 100644 index 0000000000..23964c320f --- /dev/null +++ b/maven-core-it/it0048/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + org.apache.maven + maven-core-it0048 + jar + 1.0 + + + junit + junit + 3.8.1 + jar + test + + + diff --git a/maven-core-it/it0048/src/main/java/org/apache/maven/it0001/Person.java b/maven-core-it/it0048/src/main/java/org/apache/maven/it0001/Person.java new file mode 100644 index 0000000000..613e499ae0 --- /dev/null +++ b/maven-core-it/it0048/src/main/java/org/apache/maven/it0001/Person.java @@ -0,0 +1,16 @@ +package org.apache.maven.it0001; + +public class Person +{ + private String name; + + public void setName( String name ) + { + this.name = name; + } + + public String getName() + { + return name; + } +} diff --git a/maven-core-it/it0048/src/main/resources/it0001.properties b/maven-core-it/it0048/src/main/resources/it0001.properties new file mode 100644 index 0000000000..f54f8ab106 --- /dev/null +++ b/maven-core-it/it0048/src/main/resources/it0001.properties @@ -0,0 +1 @@ +name = jason diff --git a/maven-core-it/it0048/src/test/java/org/apache/maven/it0001/PersonTest.java b/maven-core-it/it0048/src/test/java/org/apache/maven/it0001/PersonTest.java new file mode 100644 index 0000000000..e046cd5c95 --- /dev/null +++ b/maven-core-it/it0048/src/test/java/org/apache/maven/it0001/PersonTest.java @@ -0,0 +1,40 @@ +package org.apache.maven.it0001; + +import junit.framework.TestCase; +import java.net.URL; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +public class PersonTest + extends TestCase +{ + public void testPerson() throws IOException + { + ClassLoader cloader = getClass().getClassLoader(); + + String path = getClass().getName().replace( '.', '/' ) + ".class"; + + URL resource = cloader.getResource( path ); + + File resourceFile = new File( resource.getPath() ); + + String dirPath = resourceFile.getAbsolutePath(); + + dirPath = dirPath.substring( 0, dirPath.length() - path.length() ); + + File dir = new File( dirPath ); + + dir = dir.getParentFile(); + + File testFile = new File( dir, "testFileOutput.txt" ); + + FileWriter writer = new FileWriter( testFile ); + + writer.write( "Test" ); + + writer.flush(); + + writer.close(); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index b4209ee31d..0ee4a5750e 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -865,19 +865,21 @@ public class DefaultPluginManager pomConfig = buildTopDownMergedConfiguration( pomConfig, aliased ); } + boolean addedPomConfig = false; + if ( pomConfig != null ) { pomConfig = buildTopDownMergedConfiguration( pomConfig, mojoConfig ); -// if ( StringUtils.isEmpty( pomConfig.getValue( null ) ) && pomConfig.getChildCount() == 0 ) -// { -// // if we still can't find a value for this parameter, set to ${paramName} -// result.setValue( "${" + pomConfig.getName() + "}" ); -// } - - result.addChild( pomConfig ); + if ( StringUtils.isNotEmpty( pomConfig.getValue( null ) ) || pomConfig.getChildCount() > 0 ) + { + result.addChild( pomConfig ); + + addedPomConfig = true; + } } - else if ( mojoConfig != null ) + + if ( !addedPomConfig && mojoConfig != null ) { result.addChild( copyConfiguration( mojoConfig ) ); }