Author: jdcasey Date: Mon Jun 20 13:11:01 2005 New Revision: 191552 URL: http://svn.apache.org/viewcvs?rev=191552&view=rev Log: Resolving: MNG-496
o Adding extraction of mojo-specific configuration from the merged config for the plugin o Warning at the DEBUG log-level for unused plugin configuration during the extraction process above o Added integration test it0028 to test with unused plugin configuration present. Added: maven/components/trunk/maven-core-it/it0028/ maven/components/trunk/maven-core-it/it0028/expected-results.txt (with props) maven/components/trunk/maven-core-it/it0028/goals.txt (with props) maven/components/trunk/maven-core-it/it0028/pom.xml (with props) maven/components/trunk/maven-core-it/it0028/src/ maven/components/trunk/maven-core-it/it0028/src/main/ maven/components/trunk/maven-core-it/it0028/src/main/java/ maven/components/trunk/maven-core-it/it0028/src/main/java/org/ maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/ maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/ maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/ maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/Person.java (with props) maven/components/trunk/maven-core-it/it0028/src/test/ maven/components/trunk/maven-core-it/it0028/src/test/java/ maven/components/trunk/maven-core-it/it0028/src/test/java/org/ maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/ maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/ maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/ maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/PersonTest.java (with props) Modified: maven/components/trunk/maven-core-it/README.txt maven/components/trunk/maven-core-it/integration-tests.txt maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Modified: maven/components/trunk/maven-core-it/README.txt URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=191552&r1=191551&r2=191552&view=diff ============================================================================== --- maven/components/trunk/maven-core-it/README.txt (original) +++ maven/components/trunk/maven-core-it/README.txt Mon Jun 20 13:11:01 2005 @@ -84,6 +84,10 @@ it0026: Test merging of global- and user-level settings.xml files. it0027: Test @execute with a custom lifecycle, including configuration + +it0028: Test that unused configuration parameters from the POM don't cause the + mojo to fail...they will show up as warnings in the -X output instead. + ------------------------------------------------------------------------------- - generated sources Modified: maven/components/trunk/maven-core-it/integration-tests.txt URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=191552&r1=191551&r2=191552&view=diff ============================================================================== --- maven/components/trunk/maven-core-it/integration-tests.txt (original) +++ maven/components/trunk/maven-core-it/integration-tests.txt Mon Jun 20 13:11:01 2005 @@ -1,3 +1,4 @@ +it0028 #Cannot find core-it:fork... #it0027 it0026 Added: maven/components/trunk/maven-core-it/it0028/expected-results.txt URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0028/expected-results.txt?rev=191552&view=auto ============================================================================== --- maven/components/trunk/maven-core-it/it0028/expected-results.txt (added) +++ maven/components/trunk/maven-core-it/it0028/expected-results.txt Mon Jun 20 13:11:01 2005 @@ -0,0 +1 @@ +target/classes/org/apache/maven/it0001/Person.class Propchange: maven/components/trunk/maven-core-it/it0028/expected-results.txt ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author" Added: maven/components/trunk/maven-core-it/it0028/goals.txt URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0028/goals.txt?rev=191552&view=auto ============================================================================== --- maven/components/trunk/maven-core-it/it0028/goals.txt (added) +++ maven/components/trunk/maven-core-it/it0028/goals.txt Mon Jun 20 13:11:01 2005 @@ -0,0 +1 @@ +test Propchange: maven/components/trunk/maven-core-it/it0028/goals.txt ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author" Added: maven/components/trunk/maven-core-it/it0028/pom.xml URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0028/pom.xml?rev=191552&view=auto ============================================================================== --- maven/components/trunk/maven-core-it/it0028/pom.xml (added) +++ maven/components/trunk/maven-core-it/it0028/pom.xml Mon Jun 20 13:11:01 2005 @@ -0,0 +1,29 @@ +<model> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core-it0028</artifactId> + <packaging>jar</packaging> + <version>1.0</version> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <type>jar</type> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.4</source> + <target>1.4</target> + <unused>something</unused> + </configuration> + </plugin> + </plugins> + </build> +</model> Propchange: maven/components/trunk/maven-core-it/it0028/pom.xml ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author" Propchange: maven/components/trunk/maven-core-it/it0028/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/Person.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/Person.java?rev=191552&view=auto ============================================================================== --- maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/Person.java (added) +++ maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/Person.java Mon Jun 20 13:11:01 2005 @@ -0,0 +1,18 @@ +package org.apache.maven.it0001; + +public class Person +{ + private String name; + + public void setName( String name ) + { + this.name = name; + + assert true; + } + + public String getName() + { + return name; + } +} Propchange: maven/components/trunk/maven-core-it/it0028/src/main/java/org/apache/maven/it0001/Person.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author" Added: maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/PersonTest.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/PersonTest.java?rev=191552&view=auto ============================================================================== --- maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/PersonTest.java (added) +++ maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/PersonTest.java Mon Jun 20 13:11:01 2005 @@ -0,0 +1,16 @@ +package org.apache.maven.it0001; + +import junit.framework.TestCase; + +public class PersonTest + extends TestCase +{ + public void testPerson() + { + Person person = new Person(); + + person.setName( "foo" ); + + assertEquals( "foo", person.getName() ); + } +} Propchange: maven/components/trunk/maven-core-it/it0028/src/test/java/org/apache/maven/it0001/PersonTest.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author" Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=191552&r1=191551&r2=191552&view=diff ============================================================================== --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original) +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Mon Jun 20 13:11:01 2005 @@ -551,12 +551,41 @@ pathTranslator, getLogger(), project ); - checkRequiredParameters( mojoDescriptor, mergedConfiguration, expressionEvaluator, plugin ); + PlexusConfiguration extractedMojoConfiguration = extractMojoConfiguration( mergedConfiguration, mojoDescriptor ); - populatePluginFields( plugin, mojoDescriptor, mergedConfiguration, pluginContainer, expressionEvaluator ); + checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator, plugin ); + + populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer, expressionEvaluator ); return plugin; } + private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration, MojoDescriptor mojoDescriptor ) + { + Map parameterMap = mojoDescriptor.getParameterMap(); + + PlexusConfiguration[] mergedChildren = mergedConfiguration.getChildren(); + + XmlPlexusConfiguration extractedConfiguration = new XmlPlexusConfiguration( "configuration" ); + + for ( int i = 0; i < mergedChildren.length; i++ ) + { + PlexusConfiguration child = mergedChildren[i]; + + if ( parameterMap.containsKey( child.getName() ) ) + { + extractedConfiguration.addChild( DefaultPluginManager.copyConfiguration( child ) ); + } + else + { + // TODO: I defy anyone to find these messages in the '-X' output! Do we need a new log level? + // ideally, this would be elevated above the true debug output, but below the default INFO level... + getLogger().debug( "*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" + mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***"); + } + } + + return extractedConfiguration; + } + private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, Mojo plugin ) throws PluginConfigurationException @@ -758,6 +787,8 @@ String configuratorId = mojoDescriptor.getComponentConfigurator(); // TODO: should this be known to the component factory instead? And if so, should configuration be part of lookup? + // [jc]: I don't think we can be that strict with the configurator. It makes some measure of sense that + // people may want different configurators for their java mojos... if ( StringUtils.isNotEmpty( configuratorId ) ) { configurator = (ComponentConfigurator) pluginContainer.lookup( ComponentConfigurator.ROLE, --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]