You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jd...@apache.org on 2005/09/30 16:33:28 UTC
svn commit: r292750 - in /maven/components/trunk:
maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/
maven-core-it/it1016/ maven-core-it/it1017/
maven-core/src/main/java/org/apache/maven/
maven-core/src/main/java/org/apache/maven/usabil...
Author: jdcasey
Date: Fri Sep 30 07:33:10 2005
New Revision: 292750
URL: http://svn.apache.org/viewcvs?rev=292750&view=rev
Log:
Resolving: MNG-1032, MNG-1033
o Improved the error diagnostics related to artifact resolution errors.
o Added xml-based documentation of supported plugin parameter expressions, including info about how to affect them ('-o' for example), how to specify them (<distributionManagement><repository/> for example in ${project.distributionManagementArtifactRepository}), and what the expressions are actually used for. This can also serve as a basis for creating documentation for plugin parameter expressions on the website.
o Improved the error diagnostics for plugin configuration errors.
o Added a couple of ITs in the 1000 series to test these two error conditions.
Added:
maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java (with props)
maven/components/trunk/maven-core-it/it1016/
maven/components/trunk/maven-core-it/it1016/goals.txt (with props)
maven/components/trunk/maven-core-it/it1016/pom.xml (with props)
maven/components/trunk/maven-core-it/it1017/
maven/components/trunk/maven-core-it/it1017/goals.txt (with props)
maven/components/trunk/maven-core-it/it1017/pom.xml (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java (with props)
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java (with props)
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml (with props)
maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml (with props)
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/DiagnosisUtils.java
maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java
maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/PluginErrorDiagnoserTest.java
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/SummaryPluginDescriptor.java
Added: maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java (added)
+++ maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java Fri Sep 30 07:33:10 2005
@@ -0,0 +1,39 @@
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Check that tricky things having to do with parameter injection are handled correctly,
+ * by using the tricky params here!
+ *
+ * @goal tricky-params
+ */
+public class TrickyParameterMojo
+ extends AbstractMojo
+{
+
+ /**
+ * @parameter expression="${project.distributionManagementArtifactRepository}"
+ * @required
+ * @readonly
+ */
+ private ArtifactRepository deploymentRepo;
+
+ /**
+ * @parameter expression="${requiredParam}"
+ * @required
+ */
+ private String requiredParam;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+
+ getLog().info( "Id of repository: " + deploymentRepo.getId() );
+ getLog().info( "requiredParam: " + requiredParam );
+
+ }
+
+}
Propchange: maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/TrickyParameterMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it1016/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1016/goals.txt?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1016/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it1016/goals.txt Fri Sep 30 07:33:10 2005
@@ -0,0 +1 @@
+org.apache.maven.plugins:maven-core-it-plugin:1.0-SNAPSHOT:tricky-params
Propchange: maven/components/trunk/maven-core-it/it1016/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it1016/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it1016/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1016/pom.xml?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1016/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it1016/pom.xml Fri Sep 30 07:33:10 2005
@@ -0,0 +1,6 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.it</groupId>
+ <artifactId>maven-core-it1016</artifactId>
+ <version>1.0-SNAPSHOT</version>
+</project>
Propchange: maven/components/trunk/maven-core-it/it1016/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it1016/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it1017/goals.txt
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1017/goals.txt?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1017/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it1017/goals.txt Fri Sep 30 07:33:10 2005
@@ -0,0 +1 @@
+compile
Propchange: maven/components/trunk/maven-core-it/it1017/goals.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it1017/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core-it/it1017/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it1017/pom.xml?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it1017/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it1017/pom.xml Fri Sep 30 07:33:10 2005
@@ -0,0 +1,14 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.it</groupId>
+ <artifactId>maven-core-it1016</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>non.existant</groupId>
+ <artifactId>missing</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: maven/components/trunk/maven-core-it/it1017/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core-it/it1017/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Fri Sep 30 07:33:10 2005
@@ -43,6 +43,7 @@
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
import org.apache.maven.settings.SettingsUtils;
+import org.apache.maven.usability.DiagnosisUtils;
import org.apache.maven.usability.ErrorDiagnoser;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@@ -104,7 +105,7 @@
{
if ( request.getSettings().isOffline() )
{
- getLogger().info( "\n\nNOTE: Maven is running in offline mode.\n\n" );
+ getLogger().info( DiagnosisUtils.getOfflineWarning() );
WagonManager wagonManager = null;
@@ -560,6 +561,10 @@
diagnoseError( error );
line();
+
+ getLogger().error( "FATAL ERROR" );
+
+ line();
}
protected void logError( MavenExecutionResponse r )
@@ -574,6 +579,10 @@
line();
+ getLogger().error( "BUILD ERROR" );
+
+ line();
+
stats( r.getStart(), r.getFinish() );
line();
@@ -591,6 +600,9 @@
if ( diagnoser.canDiagnose( error ) )
{
message = diagnoser.diagnose( error );
+
+ // first one wins.
+ break;
}
}
}
@@ -632,6 +644,9 @@
if ( diagnoser.canDiagnose( error ) )
{
message = diagnoser.diagnose( error );
+
+ // first one wins.
+ break;
}
}
}
@@ -659,6 +674,10 @@
line();
}
+
+ getLogger().info( "BUILD FAILURE" );
+
+ line();
stats( r.getStart(), r.getFinish() );
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/ArtifactResolverDiagnoser.java Fri Sep 30 07:33:10 2005
@@ -16,12 +16,14 @@
* limitations under the License.
*/
+import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.TransitiveArtifactResolutionException;
public class ArtifactResolverDiagnoser
implements ErrorDiagnoser
{
+
+ private WagonManager wagonManager;
public boolean canDiagnose( Throwable error )
{
@@ -35,25 +37,22 @@
StringBuffer message = new StringBuffer();
message.append( "Failed to resolve artifact." );
- message.append( "\n");
- message.append( "\nGroupId: " ).append( exception.getGroupId() );
- message.append( "\nArtifactId: " ).append( exception.getArtifactId() );
- message.append( "\nVersion: " ).append( exception.getVersion() );
- message.append( "\nType: " ).append( exception.getType() );
+ message.append( "\n\n");
+ message.append( exception.getMessage() );
- if ( exception instanceof TransitiveArtifactResolutionException )
+ if ( !wagonManager.isOnline() )
{
- message.append( exception.getArtifactPath() );
+ message.append( "\n" ).append( DiagnosisUtils.getOfflineWarning() );
}
-
- message.append( DiagnosisUtils.getOfflineWarning() );
Throwable root = DiagnosisUtils.getRootCause( exception );
if ( root != null )
{
- message.append( "\n\nRoot Cause: " ).append( root.getMessage() ).append( "\n" );
+ message.append( "\nRoot Cause: " ).append( root.getMessage() );
}
+
+ message.append( "\n" );
return message.toString();
}
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/DiagnosisUtils.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/DiagnosisUtils.java?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/DiagnosisUtils.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/DiagnosisUtils.java Fri Sep 30 07:33:10 2005
@@ -25,8 +25,8 @@
public static String getOfflineWarning()
{
- return "\nNOTE: If Maven is executing in offline mode, some artifacts may be missing from your" +
- "\nlocal repository.\n";
+ return "\nNOTE: Maven is executing in offline mode. Any artifacts not already in your local\n" +
+ "repository will be inaccessible.\n";
}
public static boolean containsInCausality( Throwable error, Class test )
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/PluginConfigurationDiagnoser.java Fri Sep 30 07:33:10 2005
@@ -20,12 +20,18 @@
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.Parameter;
+import org.apache.maven.usability.plugin.ExpressionDocumenter;
+import org.apache.maven.usability.plugin.ExpressionDocumentationException;
+import org.apache.maven.usability.plugin.ExpressionDocumentation;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import org.codehaus.plexus.util.StringUtils;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
@@ -43,6 +49,9 @@
exprs.add( "localRepository" );
exprs.add( "settings" );
+ exprs.add( "project" );
+ exprs.add( "session" );
+ exprs.add( "plugin" );
exprs.add( "basedir" );
UNMODIFIABLE_EXPRESSIONS = exprs;
@@ -50,25 +59,27 @@
public boolean canDiagnose( Throwable error )
{
- return error instanceof PluginConfigurationException;
+ return DiagnosisUtils.containsInCausality(error, PluginConfigurationException.class );
}
public String diagnose( Throwable error )
{
- if ( error instanceof PluginParameterException )
+ PluginConfigurationException pce = (PluginConfigurationException) DiagnosisUtils.getFromCausality(error, PluginConfigurationException.class );
+
+ if ( pce instanceof PluginParameterException )
{
- PluginParameterException exception = (PluginParameterException) error;
+ PluginParameterException exception = (PluginParameterException) pce;
return buildParameterDiagnosticMessage( exception );
}
- else if( DiagnosisUtils.containsInCausality(error, ComponentConfigurationException.class ) )
+ else if( DiagnosisUtils.containsInCausality(pce, ComponentConfigurationException.class ) )
{
- ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils.getFromCausality( error, ComponentConfigurationException.class );
+ ComponentConfigurationException cce = (ComponentConfigurationException) DiagnosisUtils.getFromCausality( pce, ComponentConfigurationException.class );
return buildInvalidPluginConfigurationDiagnosisMessage( cce );
}
else
{
- return error.getMessage();
+ return pce.getMessage();
}
}
@@ -101,7 +112,7 @@
messageBuffer.append( "\n[" ).append( idx++ ).append( "] " );
decomposeParameterIntoUserInstructions( mojo, param, messageBuffer );
-
+
messageBuffer.append( "\n" );
}
@@ -115,16 +126,13 @@
if ( param.isEditable() )
{
- messageBuffer.append( "specify configuration for <" + param.getName() + ">VALUE</" + param.getName() + ">" );
+ messageBuffer.append( "inside the definition for plugin: \'" + mojo.getPluginDescriptor().getArtifactId() + "\'specify the following:\n\n<configuration>\n ...\n <" + param.getName() + ">VALUE</" + param.getName() + ">\n</configuration>" );
String alias = param.getAlias();
if ( StringUtils.isNotEmpty( alias ) )
{
- messageBuffer.append( " (aliased as: <" + alias + ">VALUE</" + alias + ">)" );
+ messageBuffer.append( "\n\n-OR-\n\n<configuration>\n ...\n <" + alias + ">VALUE</" + alias + ">\n</configuration>\n" );
}
-
- messageBuffer.append( "\n inside the <configuration/> section for " +
- mojo.getPluginDescriptor().getArtifactId() );
}
if ( StringUtils.isEmpty( expression ) )
@@ -137,7 +145,7 @@
if ( param.isEditable() )
{
- expressionMessageBuffer.append( ", or\n " );
+ expressionMessageBuffer.append( "\n\n-OR-\n\n" );
}
Matcher exprMatcher = Pattern.compile( "\\$\\{(.+)\\}" ).matcher( expression );
@@ -159,14 +167,9 @@
String firstPart = expressionParts.nextToken();
- if ( "project".equals( firstPart ) && expressionParts.hasMoreTokens() )
+ if ( expressionParts.hasMoreTokens() && ( "project".equals( firstPart ) || "settings".equals( firstPart ) ) )
{
- appendProjectSection( expressionParts, expressionMessageBuffer );
- }
- else if ( "reports".equals( firstPart ) )
- {
- expressionMessageBuffer.append(
- "make sure the <reports/> section of the pom.xml contains valid report names\n" );
+ addParameterConfigDocumentation( firstPart, exprMatcher.group( 0 ), subExpression, expressionMessageBuffer );
}
else if ( UNMODIFIABLE_EXPRESSIONS.contains( subExpression ) )
{
@@ -174,8 +177,7 @@
}
else
{
- expressionMessageBuffer.append( "Please provide the system property: " ).append( subExpression ).append(
- "\n (specified as \'-D" + subExpression + "=VALUE\' on the command line)\n" );
+ expressionMessageBuffer.append( "on the command line, specify: \'-D" ).append( subExpression ).append("=VALUE\'" );
}
}
@@ -204,52 +206,61 @@
}
}
- private void appendProjectSection( StringTokenizer expressionParts, StringBuffer messageBuffer )
+ private void addParameterConfigDocumentation( String firstPart, String wholeExpression, String subExpression, StringBuffer expressionMessageBuffer )
{
- messageBuffer.append( "check that the following section of the pom.xml is present and correct:\n\n" );
-
- Stack nestedParts = new Stack();
-
- String indentation = " ";
-
- messageBuffer.append( indentation ).append( "<project>\n" );
-
- nestedParts.push( "project" );
-
- indentation += " ";
-
- while ( expressionParts.hasMoreTokens() )
+ try
{
- String nextPart = expressionParts.nextToken();
+ Map expressionDoco = ExpressionDocumenter.load();
- messageBuffer.append( indentation ).append( "<" ).append( nextPart );
+ ExpressionDocumentation info = (ExpressionDocumentation) expressionDoco.get( subExpression );
- if ( expressionParts.hasMoreTokens() )
+ if ( info != null )
{
- messageBuffer.append( ">\n" );
-
- indentation += " ";
+ expressionMessageBuffer.append( "check that the following section of " );
+ if ( "project".equals( firstPart ) )
+ {
+ expressionMessageBuffer.append( "the pom.xml " );
+ }
+ else if ( "settings".equals( firstPart ) )
+ {
+ expressionMessageBuffer.append( "your ~/.m2/settings.xml file " );
+ }
- nestedParts.push( nextPart );
+ expressionMessageBuffer.append( "is present and correct:\n\n" );
+
+ String message = info.getOrigin();
+
+ if ( message == null )
+ {
+ message = info.getUsage();
+ }
+
+ expressionMessageBuffer.append( message );
+
+ String addendum = info.getAddendum();
+
+ if ( addendum != null )
+ {
+ expressionMessageBuffer.append("\n\n").append( addendum );
+ }
}
else
{
- messageBuffer.append( "/>\n" );
-
- indentation = indentation.substring( 2 );
+ expressionMessageBuffer.append( "ensure that the expression: \'"
+ + wholeExpression + "\' is satisfied" );
}
- }
- if ( !nestedParts.isEmpty() )
+ }
+ catch ( ExpressionDocumentationException e )
{
- while ( nestedParts.size() > 0 )
- {
- String prevPart = (String) nestedParts.pop();
+ expressionMessageBuffer.append( "\n\nERROR!! Failed to load expression documentation!" );
- messageBuffer.append( indentation ).append( "</" ).append( prevPart ).append( ">\n" );
+ StringWriter sWriter = new StringWriter();
+ PrintWriter pWriter = new PrintWriter( sWriter );
- indentation = indentation.substring( 2 );
- }
+ e.printStackTrace( pWriter );
+
+ expressionMessageBuffer.append( "\n\nException:\n\n" ).append( sWriter.toString() );
}
}
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java Fri Sep 30 07:33:10 2005
@@ -0,0 +1,80 @@
+package org.apache.maven.usability.plugin;
+
+public final class ExpressionDocumentation
+{
+ private String origin;
+
+ private String usage;
+
+ private String bannedMessage;
+
+ private String deprecationMessage;
+
+ private String expression;
+
+ private String addendum;
+
+ ExpressionDocumentation()
+ {
+ }
+
+ void setExpression( String expression )
+ {
+ this.expression = expression;
+ }
+
+ public String getExpression()
+ {
+ return expression;
+ }
+
+ void setOrigin( String origin )
+ {
+ this.origin = origin;
+ }
+
+ public String getOrigin()
+ {
+ return origin;
+ }
+
+ void setUsage( String usage )
+ {
+ this.usage = usage;
+ }
+
+ public String getUsage()
+ {
+ return usage;
+ }
+
+ void setBanMessage( String bannedMessage )
+ {
+ this.bannedMessage = bannedMessage;
+ }
+
+ public String getBanMessage()
+ {
+ return bannedMessage;
+ }
+
+ void setDeprecationMessage( String deprecationMessage )
+ {
+ this.deprecationMessage = deprecationMessage;
+ }
+
+ public String getDeprecationMessage()
+ {
+ return deprecationMessage;
+ }
+
+ void setAddendum( String addendum )
+ {
+ this.addendum = addendum;
+ }
+
+ public String getAddendum()
+ {
+ return addendum;
+ }
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentation.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java Fri Sep 30 07:33:10 2005
@@ -0,0 +1,18 @@
+package org.apache.maven.usability.plugin;
+
+public class ExpressionDocumentationException
+ extends Exception
+{
+ static final long serialVersionUID = 1;
+
+ public ExpressionDocumentationException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public ExpressionDocumentationException( String message )
+ {
+ super( message );
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumentationException.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java (added)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java Fri Sep 30 07:33:10 2005
@@ -0,0 +1,287 @@
+package org.apache.maven.usability.plugin;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+public class ExpressionDocumenter
+{
+
+ private static final String[] EXPRESSION_ROOTS = { "project", "settings", "session", "plugin" };
+
+ private static final String EXPRESSION_DOCO_ROOTPATH = "META-INF/maven/plugin-expressions/";
+
+ private static Map expressionDocumentation;
+
+ public static Map load()
+ throws ExpressionDocumentationException
+ {
+ if ( expressionDocumentation == null )
+ {
+ expressionDocumentation = new HashMap();
+
+ ClassLoader docLoader = initializeDocLoader();
+
+ for ( int i = 0; i < EXPRESSION_ROOTS.length; i++ )
+ {
+ InputStream docStream = null;
+ try
+ {
+ docStream = docLoader
+ .getResourceAsStream( EXPRESSION_DOCO_ROOTPATH + EXPRESSION_ROOTS[i] + ".paramdoc.xml" );
+
+ if ( docStream != null )
+ {
+ Map doco = parseExpressionDocumentation( docStream );
+
+ expressionDocumentation.putAll( doco );
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new ExpressionDocumentationException( "Failed to read documentation for expression root: " + EXPRESSION_ROOTS[i], e );
+ }
+ catch ( ParserConfigurationException e )
+ {
+ throw new ExpressionDocumentationException( "Failed to parse documentation for expression root: " + EXPRESSION_ROOTS[i], e );
+ }
+ catch ( SAXException e )
+ {
+ throw new ExpressionDocumentationException( "Failed to parse documentation for expression root: " + EXPRESSION_ROOTS[i], e.getException() );
+ }
+ finally
+ {
+ IOUtil.close( docStream );
+ }
+ }
+ }
+
+ return expressionDocumentation;
+ }
+
+ /**
+ * <expressions>
+ * <expression>
+ * <syntax>project.distributionManagementArtifactRepository</syntax>
+ * <origin><![CDATA[
+ * <distributionManagement>
+ * <repository>
+ * <id>some-repo</id>
+ * <url>scp://host/path</url>
+ * </repository>
+ * <snapshotRepository>
+ * <id>some-snap-repo</id>
+ * <url>scp://host/snapshot-path</url>
+ * </snapshotRepository>
+ * </distributionManagement>
+ * ]]></origin>
+ * <usage><![CDATA[
+ * The repositories onto which artifacts should be deployed.
+ * One is for releases, the other for snapshots.
+ * ]]></usage>
+ * </expression>
+ * <expressions>
+ * @throws IOException
+ * @throws ParserConfigurationException
+ * @throws SAXException
+ */
+ private static Map parseExpressionDocumentation( InputStream docStream )
+ throws IOException, ParserConfigurationException, SAXException
+ {
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ SAXParser parser = factory.newSAXParser();
+
+ ExpressionInfoParser eiParser = new ExpressionInfoParser();
+
+ InputSource is = new InputSource( docStream );
+
+ parser.parse( new InputSource( docStream ), eiParser );
+
+ return eiParser.getExpressionInfoMappings();
+ }
+
+ private static ClassLoader initializeDocLoader()
+ throws ExpressionDocumentationException
+ {
+ String myResourcePath = ExpressionDocumenter.class.getName().replace( '.', '/' ) + ".class";
+
+ URL myResource = ExpressionDocumenter.class.getClassLoader().getResource( myResourcePath );
+
+ String myClasspathEntry = myResource.getPath();
+
+ myClasspathEntry = myClasspathEntry.substring( 0, myClasspathEntry.length() - ( myResourcePath.length() + 2 ) );
+
+ if ( myClasspathEntry.startsWith( "file:" ) )
+ {
+ myClasspathEntry = myClasspathEntry.substring( "file:".length() );
+ }
+
+ URL docResource;
+ try
+ {
+ docResource = new File( myClasspathEntry ).toURL();
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new ExpressionDocumentationException(
+ "Cannot construct expression documentation classpath resource base.",
+ e );
+ }
+
+ return new URLClassLoader( new URL[] { docResource } );
+ }
+
+ private static final class ExpressionInfoParser
+ extends DefaultHandler
+ {
+
+ private static final String EXPRESSION = "expression";
+
+ private static final String SYNTAX = "syntax";
+
+ private static final String ORIGIN = "origin";
+
+ private static final String USAGE = "usage";
+
+ private static final String BAN = "ban";
+
+ private static final String DEPRECATION = "deprecation";
+
+ private static final String ADDENDUM = "addendum";
+
+ private Map expressionInfos = new HashMap();
+
+ private StringBuffer currentBuffer;
+
+ private StringBuffer currentExpressionName;
+
+ private StringBuffer currentUsage;
+
+ private StringBuffer currentOrigin;
+
+ private StringBuffer currentAddendum;
+
+ private StringBuffer currentBan;
+
+ private StringBuffer currentDeprecation;
+
+ Map getExpressionInfoMappings()
+ {
+ return expressionInfos;
+ }
+
+ public void characters( char[] ch, int start, int length )
+ throws SAXException
+ {
+ if ( currentBuffer != null )
+ {
+ currentBuffer.append( ch, start, length );
+ }
+ }
+
+ public void endElement( String uri, String localName, String qName )
+ throws SAXException
+ {
+ if ( EXPRESSION.equals( qName ) )
+ {
+ String expression = currentExpressionName.toString().trim();
+
+ ExpressionDocumentation ei = new ExpressionDocumentation();
+ ei.setExpression( expression );
+
+ if ( currentUsage != null )
+ {
+ ei.setUsage( currentUsage.toString().trim() );
+ }
+
+ if ( currentOrigin != null )
+ {
+ ei.setOrigin( currentOrigin.toString().trim() );
+ }
+
+ if ( currentBan != null )
+ {
+ ei.setBanMessage( currentBan.toString().trim() );
+ }
+
+ if ( currentDeprecation != null )
+ {
+ ei.setDeprecationMessage( currentDeprecation.toString().trim() );
+ }
+
+ if ( currentAddendum != null )
+ {
+ ei.setAddendum( currentAddendum.toString().trim() );
+ }
+
+ expressionInfos.put( expression, ei );
+
+ reset();
+ }
+ }
+
+ private void reset()
+ {
+ currentExpressionName = null;
+ currentUsage = null;
+ currentOrigin = null;
+ currentBan = null;
+ currentDeprecation = null;
+ currentAddendum = null;
+ currentBuffer = null;
+ }
+
+ public void startElement( String uri, String localName, String qName, Attributes attributes )
+ throws SAXException
+ {
+ if ( SYNTAX.equals( qName ) )
+ {
+ currentExpressionName = new StringBuffer();
+ currentBuffer = currentExpressionName;
+ }
+ else if ( ORIGIN.equals( qName ) )
+ {
+ currentOrigin = new StringBuffer();
+ currentBuffer = currentOrigin;
+ }
+ else if ( USAGE.equals( qName ) )
+ {
+ currentUsage = new StringBuffer();
+ currentBuffer = currentUsage;
+ }
+ else if ( BAN.equals( qName ) )
+ {
+ currentBan = new StringBuffer();
+ currentBuffer = currentBan;
+ }
+ else if ( DEPRECATION.equals( qName ) )
+ {
+ currentDeprecation = new StringBuffer();
+ currentBuffer = currentDeprecation;
+ }
+ else if ( ADDENDUM.equals( qName ) )
+ {
+ currentAddendum = new StringBuffer();
+ currentBuffer = currentAddendum;
+ }
+ }
+ }
+
+}
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/java/org/apache/maven/usability/plugin/ExpressionDocumenter.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml (added)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml Fri Sep 30 07:33:10 2005
@@ -0,0 +1,139 @@
+<expressions>
+ <expression>
+ <syntax>project.distributionManagementArtifactRepository</syntax>
+ <origin><![CDATA[
+<distributionManagement>
+ <!-- use the following if you're not using a snapshot version. -->
+ <repository>
+ <id>repo</id>
+ <name>Repository Name</name>
+ <url>scp://host/path/to/repo</url>
+ </repository>
+ <!-- use the following if you ARE using a snapshot version. -->
+ <snapshotRepository>
+ <id>repo</id>
+ <name>Repository Name</name>
+ <url>scp://host/path/to/repo</url>
+ </snapshotRepository>
+</distributionManagement>
+ ]]></origin>
+ <usage>
+ This is the ArtifactRepository used to deploy artifacts built by this Maven.
+ </usage>
+ </expression>
+ <expression>
+ <syntax>project.artifact</syntax>
+ <origin><![CDATA[
+<groupId>project.group</groupId>
+<artifactId>project-artifact</artifactId>
+<version>0.0.0.0</version>
+<packaging>type</packaging>
+ ]]></origin>
+ <usage>
+ This is the Artifact instance created from the essential project attributes:
+ groupId, artifactId, version, and packaging (with a default packaging of 'jar').
+ </usage>
+ </expression>
+ <expression>
+ <syntax>project.parent</syntax>
+ <origin><![CDATA[
+<parent>
+ <groupId>project.group</groupId>
+ <artifactId>project-artifact</artifactId>
+ <version>0.0.0.0</version>
+</parent>
+ ]]></origin>
+ <usage>
+ This is the MavenProject instance for the parent of the current POM.
+ </usage>
+ </expression>
+ <expression>
+ <syntax>project.file</syntax>
+ <usage>
+ This is the File instance that refers to the location of the current POM on disk.
+ </usage>
+ </expression>
+ <expression>
+ <syntax>project.artifacts</syntax>
+ <origin><![CDATA[
+<dependencies>
+ ...
+</dependencies>
+ ]]></origin>
+ <usage><![CDATA[
+ This is a set of Artifact instances resolved from the set of dependencies for
+ the current project.
+
+ NOTE: This will likely contain much more than the direct dependencies of the
+ current POM, since Maven uses transitive, or chained, dependency resolution.
+ ]]></usage>
+ </expression>
+ <expression>
+ <syntax>project.parentArtifact</syntax>
+ <origin><![CDATA[
+ <parent>
+ <groupId>project.group</groupId>
+ <artifactId>project-artifact</artifactId>
+ <version>0.0.0.0</version>
+ </parent>
+ ]]></origin>
+ <usage>
+ This is the Artifact instance for the parent of the current POM.
+ </usage>
+ </expression>
+ <expression>
+ <syntax>project.pluginArtifacts</syntax>
+ <origin><![CDATA[
+<build>
+ <plugins>
+ ...
+ </plugins>
+</build>
+ ]]></origin>
+ <usage><![CDATA[
+ This is the list of Artifact instances for plugins used in the current build
+ for this project.
+
+ NOTE: This list may contain plugin Artifacts which are implied by the current POM's
+ packaging and the lifecycle phase being built.
+ ]]></usage>
+ </expression>
+ <expression>
+ <syntax>project.remoteArtifactRepositories</syntax>
+ <origin><![CDATA[
+<repositories>
+ ...
+</repositories>
+ ]]></origin>
+ <usage><![CDATA[
+ This is a list of ArtifactRepository instances used to resolve the Artifacts associated
+ with the current POM.
+
+ NOTE: This list will contain entries for repositories specified by ancestor POMs, including
+ the default built-in super-POM, which is the parent of all POMs.
+ ]]></usage>
+ </expression>
+ <expression>
+ <syntax>project.pluginArtifactRepositories</syntax>
+ <origin><![CDATA[
+<pluginRepositories>
+ ...
+</pluginRepositories>
+ ]]></origin>
+ <usage><![CDATA[
+ This is a list of ArtifactRepository instances used to resolve the Artifacts associated
+ with plugins used in building the current POM.
+
+ NOTE: This list will contain entries for repositories specified by ancestor POMs, including
+ the default built-in super-POM, which is the parent of all POMs.
+ ]]></usage>
+ </expression>
+ <expression>
+ <syntax>project.attachedArtifacts</syntax>
+ <usage><![CDATA[
+ This is a list of attachments to the main artifact produced by building the current POM.
+ Attachments are derived works, based on the main build process, such as an ejb-client jar,
+ project sources jar, etc.
+ ]]></usage>
+ </expression>
+</expressions>
\ No newline at end of file
Propchange: maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/project.paramdoc.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Added: maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml?rev=292750&view=auto
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml (added)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml Fri Sep 30 07:33:10 2005
@@ -0,0 +1,27 @@
+<expressions>
+ <expression>
+ <syntax>settings.offline</syntax>
+ <origin><![CDATA[
+ <offline>true</offline>
+ ]]></origin>
+ <usage>
+ Flags the system as offline, to prevent accessing the network to resolve artifacts or execute plugins.
+ </usage>
+ <addendum><![CDATA[
+ NOTE: It's also possible to switch to offline mode on a per-build basis, using the '-o' command-line option.
+ ]]></addendum>
+ </expression>
+ <expression>
+ <syntax>settings.interactiveMode</syntax>
+ <origin><![CDATA[
+ <interactiveMode>true</interactiveMode>
+ ]]></origin>
+ <usage>
+ If false, flags the system to skip prompting the user for any information, or holding up the build
+ waiting for any input.
+ </usage>
+ <addendum><![CDATA[
+ NOTE: It's also possible to switch to batch (ie. non-interactive) mode using the '-B' command-line option.
+ ]]></addendum>
+ </expression>
+</expressions>
\ No newline at end of file
Propchange: maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-core/src/main/resources/META-INF/maven/plugin-expressions/settings.paramdoc.xml
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-core/src/main/resources/META-INF/plexus/components.xml Fri Sep 30 07:33:10 2005
@@ -120,6 +120,11 @@
<role>org.apache.maven.usability.ErrorDiagnoser</role>
<role-hint>ArtifactResolverDiagnoser</role-hint>
<implementation>org.apache.maven.usability.ArtifactResolverDiagnoser</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.artifact.manager.WagonManager</role>
+ </requirement>
+ </requirements>
</component>
<!--
|
Modified: maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/PluginErrorDiagnoserTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/PluginErrorDiagnoserTest.java?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/PluginErrorDiagnoserTest.java (original)
+++ maven/components/trunk/maven-core/src/test/java/org/apache/maven/usability/PluginErrorDiagnoserTest.java Fri Sep 30 07:33:10 2005
@@ -33,7 +33,7 @@
public class PluginErrorDiagnoserTest
extends TestCase
{
-
+
private PluginConfigurationDiagnoser diagnoser = new PluginConfigurationDiagnoser();
private PluginParameterException buildException( String prefix, String goal, List params )
@@ -54,16 +54,17 @@
return new PluginParameterException( mojoDescriptor, params );
}
-
+
public void testShouldDiagnoseInvalidPluginConfiguration()
{
printMethodHeader();
- ComponentConfigurationException cce = new ComponentConfigurationException( "Class \'org.apache.maven.plugin.jar.JarMojo\' does not contain a field named \'addClasspath\'" );
+ ComponentConfigurationException cce = new ComponentConfigurationException(
+ "Class \'org.apache.maven.plugin.jar.JarMojo\' does not contain a field named \'addClasspath\'" );
PluginConfigurationException pce = new PluginConfigurationException( "test", cce );
-
+
assertTrue( diagnoser.canDiagnose( pce ) );
-
+
String userMessage = diagnoser.diagnose( pce );
System.out.println( userMessage );
@@ -220,6 +221,26 @@
assertNotNull( userMessage );
}
+ public void testParamWithOneProjectAPIBasedExpression()
+ throws DuplicateParameterException
+ {
+ printMethodHeader();
+
+ Parameter param = new Parameter();
+ param.setName( "testName" );
+ param.setExpression( "${project.distributionManagementArtifactRepository}" );
+ param.setRequired( true );
+ param.setEditable( false );
+
+ PluginParameterException error = buildException( "test", "test", Collections.singletonList( param ) );
+
+ String userMessage = diagnoser.diagnose( error );
+
+ System.out.println( userMessage );
+
+ assertNotNull( userMessage );
+ }
+
public void testNonEditableParamWithOneProjectBasedExpression()
throws DuplicateParameterException
{
@@ -244,9 +265,9 @@
{
IllegalArgumentException marker = new IllegalArgumentException();
- System.out.println( "---------------------------------------------------------------------\n" +
- "Visual output for " + marker.getStackTrace()[1].getMethodName() +
- ":\n---------------------------------------------------------------------" );
+ System.out.println( "---------------------------------------------------------------------\n"
+ + "Visual output for " + marker.getStackTrace()[1].getMethodName()
+ + ":\n---------------------------------------------------------------------" );
}
}
Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/SummaryPluginDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/SummaryPluginDescriptor.java?rev=292750&r1=292749&r2=292750&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/SummaryPluginDescriptor.java (original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/SummaryPluginDescriptor.java Fri Sep 30 07:33:10 2005
@@ -16,7 +16,7 @@
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version $Id:$
+ * @version $Id$
*/
public class SummaryPluginDescriptor
{
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org