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/13 23:16:22 UTC
svn commit: r280661 - in
/maven/components/trunk/maven-plugins/maven-projecthelp-plugin: ./
src/main/java/org/apache/maven/plugins/projecthelp/
Author: jdcasey
Date: Tue Sep 13 14:16:15 2005
New Revision: 280661
URL: http://svn.apache.org/viewcvs?rev=280661&view=rev
Log:
Added beginnings of DescribeMojo, and added setters for all mojo parameters in the plugin.
Added:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java (with props)
Modified:
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml?rev=280661&r1=280660&r2=280661&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/pom.xml Tue Sep 13 14:16:15 2005
@@ -19,6 +19,21 @@
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0-beta-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0-beta-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>2.0-beta-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-beta-1-SNAPSHOT</version>
</dependency>
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java?rev=280661&r1=280660&r2=280661&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/ActiveProfilesPlugin.java Tue Sep 13 14:16:15 2005
@@ -73,4 +73,14 @@
}
+ protected final List getProfiles()
+ {
+ return profiles;
+ }
+
+ protected final void setProfiles( List profiles )
+ {
+ this.profiles = profiles;
+ }
+
}
Added: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java?rev=280661&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java (added)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java Tue Sep 13 14:16:15 2005
@@ -0,0 +1,358 @@
+package org.apache.maven.plugins.projecthelp;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.PluginManager;
+import org.apache.maven.plugin.PluginManagerException;
+import org.apache.maven.plugin.descriptor.MojoDescriptor;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.apache.maven.plugin.version.PluginVersionResolutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.settings.Settings;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Iterator;
+
+/**
+ * @goal describe
+ */
+public class DescribeMojo
+ extends AbstractMojo
+{
+
+ /**
+ * @parameter expression="${plugin}"
+ */
+ private String plugin;
+
+ /**
+ * @parameter
+ */
+ private String groupId;
+
+ /**
+ * @parameter
+ */
+ private String artifactId;
+
+ /**
+ * @parameter
+ */
+ private String version;
+
+ /**
+ * @parameter
+ */
+ private String mojo;
+
+ /**
+ * @component role="org.apache.maven.plugin.PluginManager"
+ */
+ private PluginManager pluginManager;
+
+ /**
+ * @parameter expression="${project}"
+ * @required
+ * @readonly
+ */
+ private MavenProject project;
+
+ /**
+ * @parameter expression="${settings}"
+ * @required
+ * @readonly
+ */
+ private Settings settings;
+
+ /**
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * @parameter
+ */
+ private File output;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ String pluginPrefix = null;
+
+ if ( plugin != null && plugin.length() > 0 )
+ {
+ if ( plugin.indexOf( ":" ) > -1 )
+ {
+ String[] pluginParts = plugin.split( ":" );
+
+ switch ( pluginParts.length )
+ {
+ case ( 1 ):
+ {
+ pluginPrefix = pluginParts[0];
+ break;
+ }
+ case ( 2 ):
+ {
+ groupId = pluginParts[0];
+ artifactId = pluginParts[1];
+ break;
+ }
+ case ( 3 ):
+ {
+ groupId = pluginParts[0];
+ artifactId = pluginParts[1];
+ version = pluginParts[2];
+ break;
+ }
+ default:
+ {
+ throw new MojoExecutionException(
+ "plugin parameter must be a plugin prefix, or conform to: 'groupId:artifactId[:version]." );
+ }
+ }
+ }
+ else
+ {
+ pluginPrefix = plugin;
+ }
+ }
+
+ PluginDescriptor descriptor;
+
+ if ( pluginPrefix != null )
+ {
+ try
+ {
+ descriptor = pluginManager.getPluginDescriptorForPrefix( pluginPrefix );
+ }
+ catch ( PluginManagerException e )
+ {
+ throw new MojoExecutionException( "Error retrieving plugin descriptor for prefix: \'" + pluginPrefix
+ + "\'.", e );
+ }
+ }
+ else if ( groupId != null && artifactId != null )
+ {
+ Plugin plugin = new Plugin();
+
+ plugin.setGroupId( groupId );
+ plugin.setArtifactId( artifactId );
+
+ if ( version != null )
+ {
+ plugin.setVersion( version );
+ }
+
+ try
+ {
+ descriptor = pluginManager.verifyPlugin( plugin, project, settings, localRepository );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId
+ + "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
+ }
+ catch ( PluginManagerException e )
+ {
+ throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId
+ + "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
+ }
+ catch ( PluginVersionResolutionException e )
+ {
+ throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId
+ + "\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
+ }
+ }
+ else
+ {
+ throw new MojoExecutionException(
+ "You must either specify \'groupId\' and \'artifactId\', or a valid \'plugin\' parameter." );
+ }
+
+ StringBuffer descriptionBuffer = new StringBuffer();
+
+ if ( mojo != null && mojo.length() > 0 )
+ {
+ describeMojo( descriptor.getMojo( mojo ), descriptionBuffer );
+ }
+ else
+ {
+ describePlugin( descriptor, descriptionBuffer );
+ }
+
+ if ( output != null )
+ {
+ Writer out = null;
+ try
+ {
+ out = new FileWriter( output );
+
+ out.write( descriptionBuffer.toString() );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Cannot write plugin/mojo description.", e );
+ }
+ finally
+ {
+ if ( out != null )
+ {
+ try
+ {
+ out.close();
+ }
+ catch ( IOException e )
+ {
+ getLog().debug( "Error closing file output.", e );
+ }
+ }
+ }
+ }
+ else
+ {
+ System.out.println( descriptionBuffer.toString() );
+ }
+ }
+
+ private void describePlugin( PluginDescriptor pd, StringBuffer buffer )
+ {
+ buffer.append( "Description of Plugin" ).append( "\n-----------------------------------------------" )
+ .append( "\n\nGroup Id: " ).append( pd.getGroupId() ).append( "\nArtifact Id: " )
+ .append( pd.getArtifactId() ).append( "\nVersion: " ).append( pd.getVersion() )
+ .append( "\nGoal Prefix: " ).append( pd.getGoalPrefix() ).append( "\n\nMojos:" )
+ .append( "\n-----------------------------------------------" ).append( "\n\n" );
+
+ for ( Iterator it = pd.getMojos().iterator(); it.hasNext(); )
+ {
+ MojoDescriptor md = (MojoDescriptor) it.next();
+
+ describeMojoGuts( md, buffer );
+
+ buffer.append( "\n-----------------------------------------------" ).append( "\n\n" );
+ }
+ }
+
+ private void describeMojo( MojoDescriptor md, StringBuffer buffer )
+ {
+ buffer.append( "Description of Mojo" ).append( "\n-----------------------------------------------" )
+ .append( "\n\n" );
+
+ describeMojoGuts( md, buffer );
+ }
+
+ private void describeMojoGuts( MojoDescriptor md, StringBuffer buffer )
+ {
+ // TODO Complete mojo description dump.
+ buffer.append( "TODO!" );
+ }
+
+ public final String getPlugin()
+ {
+ return plugin;
+ }
+
+ public final void setPlugin( String plugin )
+ {
+ this.plugin = plugin;
+ }
+
+ public final PluginManager getPluginManager()
+ {
+ return pluginManager;
+ }
+
+ public final void setPluginManager( PluginManager pluginManager )
+ {
+ this.pluginManager = pluginManager;
+ }
+
+ public final String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public final void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ public final String getGroupId()
+ {
+ return groupId;
+ }
+
+ public final void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ public final ArtifactRepository getLocalRepository()
+ {
+ return localRepository;
+ }
+
+ public final void setLocalRepository( ArtifactRepository localRepository )
+ {
+ this.localRepository = localRepository;
+ }
+
+ public final String getMojo()
+ {
+ return mojo;
+ }
+
+ public final void setMojo( String mojo )
+ {
+ this.mojo = mojo;
+ }
+
+ public final File getOutput()
+ {
+ return output;
+ }
+
+ public final void setOutput( File output )
+ {
+ this.output = output;
+ }
+
+ public final MavenProject getProject()
+ {
+ return project;
+ }
+
+ public final void setProject( MavenProject project )
+ {
+ this.project = project;
+ }
+
+ public final Settings getSettings()
+ {
+ return settings;
+ }
+
+ public final void setSettings( Settings settings )
+ {
+ this.settings = settings;
+ }
+
+ public final String getVersion()
+ {
+ return version;
+ }
+
+ public final void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+}
Propchange: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/DescribeMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java?rev=280661&r1=280660&r2=280661&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectivePomPlugin.java Tue Sep 13 14:16:15 2005
@@ -113,4 +113,24 @@
}
}
+ protected final String getOutput()
+ {
+ return output;
+ }
+
+ protected final void setOutput( String output )
+ {
+ this.output = output;
+ }
+
+ protected final Model getPom()
+ {
+ return pom;
+ }
+
+ protected final void setPom( Model pom )
+ {
+ this.pom = pom;
+ }
+
}
Modified: maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java?rev=280661&r1=280660&r2=280661&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java (original)
+++ maven/components/trunk/maven-plugins/maven-projecthelp-plugin/src/main/java/org/apache/maven/plugins/projecthelp/EffectiveSettingsMojo.java Tue Sep 13 14:16:15 2005
@@ -115,4 +115,24 @@
}
}
+ protected final String getOutput()
+ {
+ return output;
+ }
+
+ protected final void setOutput( String output )
+ {
+ this.output = output;
+ }
+
+ protected final Settings getSettings()
+ {
+ return settings;
+ }
+
+ protected final void setSettings( Settings settings )
+ {
+ this.settings = settings;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org