You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/05/04 18:23:44 UTC
svn commit: r168141 -
/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle
/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor
/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util
Author: brett
Date: Wed May 4 09:23:42 2005
New Revision: 168141
URL: http://svn.apache.org/viewcvs?rev=168141&view=rev
Log:
improve the artifact ID parsing - any maven or plugin is removed to get the default prefix. If you want something different, use the configuration for plugin:descriptor
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java?rev=168141&r1=168140&r2=168141&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/DefaultLifecycleExecutor.java Wed May 4 09:23:42 2005
@@ -351,7 +351,9 @@
{
String groupId = PluginDescriptor.getDefaultPluginGroupId();
- String artifactId = PluginDescriptor.getPluginArtifactIdFromGoal( task );
+ String pluginId = PluginDescriptor.getPrefixFromGoal( task );
+
+ String artifactId = PluginDescriptor.getDefaultPluginArtifactId( pluginId );
injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId );
Modified: maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java?rev=168141&r1=168140&r2=168141&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java (original)
+++ maven/components/trunk/maven-plugin-descriptor/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Wed May 4 09:23:42 2005
@@ -103,16 +103,15 @@
/**
* @todo remove - harcoding.
*/
- public static String getPluginArtifactIdFromGoal( String goalName )
+ public static String getPrefixFromGoal( String goalName )
{
- String pluginId = goalName;
+ String prefix = goalName;
- if ( pluginId.indexOf( ":" ) > 0 )
+ if ( prefix.indexOf( ":" ) > 0 )
{
- pluginId = pluginId.substring( 0, pluginId.indexOf( ":" ) );
+ prefix = prefix.substring( 0, prefix.indexOf( ":" ) );
}
-
- return getDefaultPluginArtifactId( pluginId );
+ return prefix;
}
/**
@@ -138,11 +137,7 @@
*/
public static String getGoalPrefixFromArtifactId( String artifactId )
{
- int firstHyphen = artifactId.indexOf( "-" );
-
- int lastHyphen = artifactId.lastIndexOf( "-" );
-
- return artifactId.substring( firstHyphen + 1, lastHyphen );
+ return artifactId.replaceAll( "-?maven-?", "" ).replaceAll( "-?plugin-?", "" );
}
/**
Modified: maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java?rev=168141&r1=168140&r2=168141&view=diff
==============================================================================
--- maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java (original)
+++ maven/components/trunk/maven-plugin-tools/maven-plugin-tools-api/src/test/java/org/apache/maven/tools/plugin/util/PluginUtilsTest.java Wed May 4 09:23:42 2005
@@ -19,14 +19,11 @@
public void testShouldTrimArtifactIdToFindPluginId()
{
- Model model = new Model();
- model.setArtifactId( "maven-artifactId-plugin" );
-
- MavenProject project = new MavenProject( model );
-
- String pluginId = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
-
- assertEquals( "artifactId", pluginId );
+ assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-artifactId-plugin" ) );
+ assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-plugin-artifactId" ) );
+ assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "artifactId-maven-plugin" ) );
+ assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "artifactId" ) );
+ assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "artifactId-plugin" ) );
}
public void testShouldWriteDependencies()
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org