brett 2005/04/13 04:34:09 Modified: maven-plugin-api/src/main/java/org/apache/maven/plugin AbstractPlugin.java maven-core/src/main/java/org/apache/maven/lifecycle DefaultLifecycleExecutor.java maven-core/src/main/java/org/apache/maven/plugin DefaultPluginManager.java MavenPluginDescriptor.java maven-core/src/main/java/org/apache/maven/project/inheritance DefaultModelInheritanceAssembler.java maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java JavaMojoDescriptorExtractor.java maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy Main.java maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly JellyHarnessGenerator.java maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator PluginDescriptorGenerator.java maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util PluginUtils.java maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util PluginUtilsTest.java maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor PluginDescriptor.java PluginDescriptorBuilder.java Log: PR: MNG-225
use both groupId and artifactId in mojo descriptor Revision Changes Path 1.2 +1 -16 maven-components/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractPlugin.java Index: AbstractPlugin.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-api/src/main/java/org/apache/maven/plugin/AbstractPlugin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractPlugin.java 13 Apr 2005 05:07:51 -0000 1.1 +++ AbstractPlugin.java 13 Apr 2005 11:34:09 -0000 1.2 @@ -86,19 +86,4 @@ throw new PluginExecutionException( "You must override execute() if you implement the new paradigm" ); } - /** - * @todo remove - harcoding. - */ - public static String getDefaultPluginArtifactId( String id ) - { - return "maven-" + id + "-plugin"; - } - - /** - * @todo remove - harcoding. - */ - public static String getDefaultPluginGroupId() - { - return "org.apache.maven.plugins"; - } } 1.33 +10 -15 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Index: DefaultLifecycleExecutor.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- DefaultLifecycleExecutor.java 8 Apr 2005 09:53:22 -0000 1.32 +++ DefaultLifecycleExecutor.java 13 Apr 2005 11:34:09 -0000 1.33 @@ -16,40 +16,37 @@ * limitations under the License. */ +import org.apache.maven.MavenConstants; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.execution.MavenExecutionResponse; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Goal; +import org.apache.maven.model.Model; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginManagement; -import org.apache.maven.model.Model; import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.MavenEvents; -import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionException; import org.apache.maven.plugin.PluginManager; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.project.DefaultMavenProjectBuilder; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; -import org.apache.maven.project.DefaultMavenProjectBuilder; -import org.apache.maven.project.ProjectBuildingException; -import org.apache.maven.MavenConstants; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import java.io.InputStreamReader; +import java.net.URL; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.io.InputStreamReader; -import java.io.IOException; -import java.net.URL; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl </a> @@ -120,9 +117,9 @@ if ( artifactHandler.additionalPlugin() != null ) { - String additionalPluginGroupId = AbstractPlugin.getDefaultPluginGroupId(); + String additionalPluginGroupId = PluginDescriptor.getDefaultPluginGroupId(); - String additionalPluginArtifactId = AbstractPlugin.getDefaultPluginArtifactId( + String additionalPluginArtifactId = PluginDescriptor.getDefaultPluginArtifactId( artifactHandler.additionalPlugin() ); injectHandlerPluginConfiguration( project, additionalPluginGroupId, additionalPluginArtifactId ); @@ -275,9 +272,7 @@ // TODO: Right now this maven-foo-plugin so this is a hack right now. - pluginId = pluginId.substring( 6 ); - - pluginId = pluginId.substring( 0, pluginId.lastIndexOf( "-" ) ); + pluginId = PluginDescriptor.getPluginIdFromArtifactId( pluginId ); for ( Iterator i = plugin.getGoals().iterator(); i.hasNext(); ) { @@ -363,7 +358,7 @@ if ( mojoDescriptor == null ) { - String groupId = AbstractPlugin.getDefaultPluginGroupId(); + String groupId = PluginDescriptor.getDefaultPluginGroupId(); String pluginId = task; @@ -372,7 +367,7 @@ pluginId = pluginId.substring( 0, pluginId.indexOf( ":" ) ); } - String artifactId = AbstractPlugin.getDefaultPluginArtifactId( pluginId ); + String artifactId = PluginDescriptor.getDefaultPluginArtifactId( pluginId ); injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId ); 1.77 +11 -28 maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Index: DefaultPluginManager.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java,v retrieving revision 1.76 retrieving revision 1.77 diff -u -r1.76 -r1.77 --- DefaultPluginManager.java 13 Apr 2005 05:11:48 -0000 1.76 +++ DefaultPluginManager.java 13 Apr 2005 11:34:09 -0000 1.77 @@ -16,7 +16,6 @@ * limitations under the License. */ -import org.apache.maven.artifact.resolver.filter.AndArtifactFilter; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.MavenMetadataSource; import org.apache.maven.artifact.factory.ArtifactFactory; @@ -126,12 +125,7 @@ public PluginDescriptor getPluginDescriptor( String groupId, String artifactId ) { - return (PluginDescriptor) pluginDescriptors.get( constructPluginKey( groupId, artifactId ) ); - } - - private static String constructPluginKey( String groupId, String artifactId ) - { - return groupId + ":" + artifactId; + return (PluginDescriptor) pluginDescriptors.get( PluginDescriptor.constructPluginKey( groupId, artifactId ) ); } // ---------------------------------------------------------------------- @@ -143,14 +137,15 @@ public void processPluginDescriptor( MavenPluginDescriptor mavenPluginDescriptor ) throws CycleDetectedException { - if ( pluginsInProcess.contains( mavenPluginDescriptor.getPluginId() ) ) + PluginDescriptor pluginDescriptor = mavenPluginDescriptor.getPluginDescriptor(); + String key = pluginDescriptor.getId(); + + if ( pluginsInProcess.contains( key ) ) { return; } - pluginsInProcess.add( mavenPluginDescriptor.getPluginId() ); - - PluginDescriptor pluginDescriptor = mavenPluginDescriptor.getPluginDescriptor(); + pluginsInProcess.add( key ); for ( Iterator it = mavenPluginDescriptor.getMavenMojoDescriptors().iterator(); it.hasNext(); ) { @@ -161,7 +156,6 @@ mojoDescriptors.put( mojoDescriptor.getId(), mojoDescriptor ); } - String key = constructPluginKey( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId() ); pluginDescriptors.put( key, pluginDescriptor ); } @@ -196,28 +190,16 @@ public boolean isPluginInstalled( String groupId, String artifactId ) { - return pluginDescriptors.containsKey( constructPluginKey( groupId, artifactId ) ); - } - - private static String getPluginId( String goalName ) - { - String pluginId = goalName; - - if ( pluginId.indexOf( ":" ) > 0 ) - { - pluginId = pluginId.substring( 0, pluginId.indexOf( ":" ) ); - } - - return AbstractPlugin.getDefaultPluginArtifactId( pluginId ); + return pluginDescriptors.containsKey( PluginDescriptor.constructPluginKey( groupId, artifactId ) ); } // TODO: don't throw Exception public void verifyPluginForGoal( String goalName, MavenSession session ) throws Exception { - String pluginId = getPluginId( goalName ); + String pluginId = PluginDescriptor.getPluginIdFromGoal( goalName ); - verifyPlugin( AbstractPlugin.getDefaultPluginGroupId(), pluginId, session ); + verifyPlugin( PluginDescriptor.getDefaultPluginGroupId(), pluginId, session ); } // TODO: don't throw Exception @@ -397,7 +379,8 @@ } // TODO: can probable refactor these a little when only the new plugin technique is in place - Xpp3Dom dom = session.getProject().getGoalConfiguration( getPluginId( goalName ), goalId ); + Xpp3Dom dom = session.getProject().getGoalConfiguration( PluginDescriptor.getPluginIdFromGoal( goalName ), + goalId ); PlexusConfiguration configuration; if ( dom == null ) 1.5 +2 -7 maven-components/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginDescriptor.java Index: MavenPluginDescriptor.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginDescriptor.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MavenPluginDescriptor.java 10 Mar 2005 01:35:14 -0000 1.4 +++ MavenPluginDescriptor.java 13 Apr 2005 11:34:09 -0000 1.5 @@ -38,12 +38,6 @@ this.pluginDescriptor = pluginDescriptor; } - public String getPluginId() - { - // TODO: groupID - return pluginDescriptor.getArtifactId(); - } - // ---------------------------------------------------------------------- // Accessors // ---------------------------------------------------------------------- @@ -62,4 +56,5 @@ { return pluginDescriptor.isIsolatedRealm(); } + } 1.29 +0 -2 maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java Index: DefaultModelInheritanceAssembler.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- DefaultModelInheritanceAssembler.java 12 Apr 2005 23:51:21 -0000 1.28 +++ DefaultModelInheritanceAssembler.java 13 Apr 2005 11:34:09 -0000 1.29 @@ -27,7 +27,6 @@ import org.apache.maven.model.Repository; import org.apache.maven.model.Scm; import org.apache.maven.util.Xpp3DomUtils; -import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -44,7 +43,6 @@ * model. */ public class DefaultModelInheritanceAssembler - extends AbstractLogEnabled implements ModelInheritanceAssembler { public void assembleModelInheritance( Model child, Model parent ) 1.9 +2 -2 maven-components/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java Index: JavaMojoDescriptorExtractor.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-java/src/main/java/org/apache/maven/tools/plugin/extractor/java/JavaMojoDescriptorExtractor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- JavaMojoDescriptorExtractor.java 5 Apr 2005 08:17:28 -0000 1.8 +++ JavaMojoDescriptorExtractor.java 13 Apr 2005 11:34:09 -0000 1.9 @@ -22,10 +22,10 @@ import com.thoughtworks.qdox.model.JavaSource; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.tools.plugin.extractor.InvalidParameterException; import org.apache.maven.tools.plugin.extractor.MojoDescriptorExtractor; -import org.apache.maven.tools.plugin.util.PluginUtils; import java.io.File; import java.util.ArrayList; @@ -121,7 +121,7 @@ DocletTag tag; - String pluginId = PluginUtils.pluginId( project ); + String pluginId = PluginDescriptor.getPluginIdFromArtifactId( project.getArtifactId() ); mojoDescriptor.setId( pluginId ); 1.3 +11 -1 maven-components/maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-pluggy/src/main/java/org/apache/maven/tools/plugin/pluggy/Main.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Main.java 10 Mar 2005 01:35:25 -0000 1.2 +++ Main.java 13 Apr 2005 11:34:09 -0000 1.3 @@ -71,6 +71,16 @@ Model model = modelReader.read( reader ); + // Not doing inheritence, except for groupId and version + if ( model.getGroupId() == null ) + { + model.setGroupId( model.getParent().getGroupId() ); + } + if ( model.getVersion() == null ) + { + model.setVersion( model.getParent().getVersion() ); + } + MavenProject project = new MavenProject( model ); project.setFile( new File( pom ) ); project.addCompileSourceRoot( sourceDirectory ); 1.3 +12 -10 maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java Index: JellyHarnessGenerator.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/jelly/JellyHarnessGenerator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JellyHarnessGenerator.java 24 Feb 2005 05:12:30 -0000 1.2 +++ JellyHarnessGenerator.java 13 Apr 2005 11:34:09 -0000 1.3 @@ -18,6 +18,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.Parameter; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.tools.plugin.generator.Generator; import org.apache.maven.tools.plugin.util.PluginUtils; @@ -32,11 +33,11 @@ /** * @todo use the descriptions in the descriptor for the javadoc pushed into the - * source code. + * source code. * @todo write plugin.properties (as a place holder, we don't technially need - * it) + * it) * @todo convert POM or just strip out the dependencies to create a project.xml - * that will serve as the trigger to download dependencies. + * that will serve as the trigger to download dependencies. */ public class JellyHarnessGenerator implements Generator @@ -46,13 +47,14 @@ return pluginDescriptor.getImplementation() + "Bean"; } - public void execute( String destinationDirectory, Set mojoDescriptors, MavenProject project ) throws Exception + public void execute( String destinationDirectory, Set mojoDescriptors, MavenProject project ) + throws Exception { FileWriter writer = new FileWriter( new File( destinationDirectory, "plugin.jelly" ) ); PrettyPrintXMLWriter w = new PrettyPrintXMLWriter( writer ); - String pluginId = PluginUtils.pluginId( project ); + String pluginId = PluginDescriptor.getPluginIdFromArtifactId( project.getArtifactId() ); // ---------------------------------------------------------------------- // @@ -133,7 +135,7 @@ protected void processPluginDescriptor( MojoDescriptor mojoDescriptor, XMLWriter w, MavenProject project ) throws Exception { - String pluginId = PluginUtils.pluginId( project ); + String pluginId = PluginDescriptor.getPluginIdFromArtifactId( project.getArtifactId() ); String goalName = mojoDescriptor.getGoal(); @@ -252,7 +254,8 @@ if ( projectIndex > 0 ) { - expression = expression.substring( 0, projectIndex ) + "pom" + expression.substring( projectIndex + 7 ); + expression = expression.substring( 0, projectIndex ) + "pom" + + expression.substring( projectIndex + 7 ); } if ( expression.startsWith( "#" ) ) @@ -275,8 +278,7 @@ return str; } - return new StringBuffer( str.length() ).append( Character.toTitleCase( str.charAt( 0 ) ) ) - .append( str.substring( 1 ) ) - .toString(); + return new StringBuffer( str.length() ).append( Character.toTitleCase( str.charAt( 0 ) ) ).append( + str.substring( 1 ) ).toString(); } } \ No newline at end of file 1.7 +3 -1 maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java Index: PluginDescriptorGenerator.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorGenerator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- PluginDescriptorGenerator.java 5 Apr 2005 08:17:28 -0000 1.6 +++ PluginDescriptorGenerator.java 13 Apr 2005 11:34:09 -0000 1.7 @@ -53,7 +53,9 @@ w.startElement( "plugin" ); - element( w, "id", PluginUtils.pluginId( project ) ); + element( w, "groupId", project.getGroupId() ); + + element( w, "artifactId", project.getArtifactId() ); element( w, "isolatedRealm", "true" ); 1.3 +4 -22 maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java Index: PluginUtils.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/util/PluginUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PluginUtils.java 24 Feb 2005 05:12:30 -0000 1.2 +++ PluginUtils.java 13 Apr 2005 11:34:09 -0000 1.3 @@ -34,25 +34,6 @@ { } - public static String pluginId( MavenProject project ) - { - // ---------------------------------------------------------------------- - // We will take the id from the artifactId of the POM. The artifactId is - // always of the form maven-<pluginId>-plugin so we can extract the - // pluginId from the artifactId. - // ---------------------------------------------------------------------- - - String artifactId = project.getArtifactId(); - - int firstHyphen = artifactId.indexOf( "-" ); - - int lastHyphen = artifactId.lastIndexOf( "-" ); - - String pluginId = artifactId.substring( firstHyphen + 1, lastHyphen ); - - return pluginId; - } - public static String[] findSources( String basedir, String include ) { return PluginUtils.findSources( basedir, include, null ); @@ -62,10 +43,10 @@ { DirectoryScanner scanner = new DirectoryScanner(); scanner.setBasedir( basedir ); - scanner.setIncludes( new String[] { include } ); + scanner.setIncludes( new String[]{include} ); if ( !StringUtils.isEmpty( exclude ) ) { - scanner.setExcludes( new String[] { exclude } ); + scanner.setExcludes( new String[]{exclude} ); } scanner.scan(); @@ -73,7 +54,8 @@ return scanner.getIncludedFiles(); } - public static void writeDependencies( XMLWriter w, MavenProject project ) throws Exception + public static void writeDependencies( XMLWriter w, MavenProject project ) + throws Exception { w.startElement( "dependencies" ); 1.3 +8 -7 maven-components/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java Index: PluginUtilsTest.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PluginUtilsTest.java 24 Feb 2005 05:12:29 -0000 1.2 +++ PluginUtilsTest.java 13 Apr 2005 11:34:09 -0000 1.3 @@ -1,15 +1,15 @@ package org.apache.maven.tools.plugin.util; +import junit.framework.TestCase; import org.apache.maven.model.Dependency; import org.apache.maven.model.Model; +import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.CompactXMLWriter; import org.codehaus.plexus.util.xml.XMLWriter; import java.io.StringWriter; -import junit.framework.TestCase; - /** * @author jdcasey */ @@ -24,12 +24,13 @@ MavenProject project = new MavenProject( model ); - String pluginId = PluginUtils.pluginId( project ); + String pluginId = PluginDescriptor.getPluginIdFromArtifactId( project.getArtifactId() ); System.out.println( pluginId ); } - public void testShouldWriteDependencies() throws Exception + public void testShouldWriteDependencies() + throws Exception { Dependency dependency = new Dependency(); dependency.setArtifactId( "testArtifactId" ); @@ -49,9 +50,9 @@ String output = sWriter.toString(); - String pattern = "<dependencies>" + "<dependency>" + "<groupId>testGroupId</groupId>" - + "<artifactId>testArtifactId</artifactId>" + "<type>pom</type>" + "<version>0.0.0</version>" - + "</dependency>" + "</dependencies>"; + String pattern = "<dependencies>" + "<dependency>" + "<groupId>testGroupId</groupId>" + + "<artifactId>testArtifactId</artifactId>" + "<type>pom</type>" + "<version>0.0.0</version>" + + "</dependency>" + "</dependencies>"; assertEquals( pattern, output ); } 1.2 +56 -1 maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Index: PluginDescriptor.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PluginDescriptor.java 13 Apr 2005 05:08:29 -0000 1.1 +++ PluginDescriptor.java 13 Apr 2005 11:34:09 -0000 1.2 @@ -87,4 +87,59 @@ { return isolatedRealm; } + + public static String constructPluginKey( String groupId, String artifactId ) + { + return groupId + ":" + artifactId; + } + + public String getId() + { + return constructPluginKey( groupId, artifactId ); + } + + /** + * @todo remove - harcoding. + */ + public static String getPluginIdFromGoal( String goalName ) + { + String pluginId = goalName; + + if ( pluginId.indexOf( ":" ) > 0 ) + { + pluginId = pluginId.substring( 0, pluginId.indexOf( ":" ) ); + } + + return getDefaultPluginArtifactId( pluginId ); + } + + /** + * @todo remove - harcoding. + */ + public static String getDefaultPluginArtifactId( String id ) + { + return "maven-" + id + "-plugin"; + } + + /** + * @todo remove - harcoding. + */ + public static String getDefaultPluginGroupId() + { + return "org.apache.maven.plugins"; + } + + /** + * Parse maven-...-plugin. + * + * @todo remove - harcoding. What about clashes? + */ + public static String getPluginIdFromArtifactId( String artifactId ) + { + int firstHyphen = artifactId.indexOf( "-" ); + + int lastHyphen = artifactId.lastIndexOf( "-" ); + + return artifactId.substring( firstHyphen + 1, lastHyphen ); + } } 1.2 +13 -4 maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java Index: PluginDescriptorBuilder.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PluginDescriptorBuilder.java 13 Apr 2005 05:08:29 -0000 1.1 +++ PluginDescriptorBuilder.java 13 Apr 2005 11:34:09 -0000 1.2 @@ -1,6 +1,5 @@ package org.apache.maven.plugin.descriptor; -import org.apache.maven.plugin.AbstractPlugin; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; @@ -24,8 +23,18 @@ PluginDescriptor pluginDescriptor = new PluginDescriptor(); - pluginDescriptor.setGroupId( AbstractPlugin.getDefaultPluginGroupId() ); - pluginDescriptor.setArtifactId( AbstractPlugin.getDefaultPluginArtifactId( c.getChild( "id" ).getValue() ) ); + String id = c.getChild( "id" ).getValue(); + if ( id != null ) + { + // TODO: remove. This is old style mojos (alpha-1) + pluginDescriptor.setGroupId( PluginDescriptor.getDefaultPluginGroupId() ); + pluginDescriptor.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( id ) ); + } + else + { + pluginDescriptor.setGroupId( c.getChild( "groupId" ).getValue() ); + pluginDescriptor.setArtifactId( c.getChild( "artifactId" ).getValue() ); + } // ---------------------------------------------------------------------- // Components