mirror of https://github.com/apache/maven.git
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
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168141 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
427d466bcb
commit
7f7a1049e6
|
@ -351,7 +351,9 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
String groupId = PluginDescriptor.getDefaultPluginGroupId();
|
||||
|
||||
String artifactId = PluginDescriptor.getPluginArtifactIdFromGoal( task );
|
||||
String pluginId = PluginDescriptor.getPrefixFromGoal( task );
|
||||
|
||||
String artifactId = PluginDescriptor.getDefaultPluginArtifactId( pluginId );
|
||||
|
||||
injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId );
|
||||
|
||||
|
|
|
@ -103,16 +103,15 @@ public class PluginDescriptor
|
|||
/**
|
||||
* @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 class PluginDescriptor
|
|||
*/
|
||||
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-?", "" );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,14 +19,11 @@ public class PluginUtilsTest
|
|||
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue