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 groupId = PluginDescriptor.getDefaultPluginGroupId();
|
||||||
|
|
||||||
String artifactId = PluginDescriptor.getPluginArtifactIdFromGoal( task );
|
String pluginId = PluginDescriptor.getPrefixFromGoal( task );
|
||||||
|
|
||||||
|
String artifactId = PluginDescriptor.getDefaultPluginArtifactId( pluginId );
|
||||||
|
|
||||||
injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId );
|
injectHandlerPluginConfiguration( session.getProject(), groupId, artifactId );
|
||||||
|
|
||||||
|
|
|
@ -103,16 +103,15 @@ public class PluginDescriptor
|
||||||
/**
|
/**
|
||||||
* @todo remove - harcoding.
|
* @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 prefix;
|
||||||
return getDefaultPluginArtifactId( pluginId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,11 +137,7 @@ public class PluginDescriptor
|
||||||
*/
|
*/
|
||||||
public static String getGoalPrefixFromArtifactId( String artifactId )
|
public static String getGoalPrefixFromArtifactId( String artifactId )
|
||||||
{
|
{
|
||||||
int firstHyphen = artifactId.indexOf( "-" );
|
return artifactId.replaceAll( "-?maven-?", "" ).replaceAll( "-?plugin-?", "" );
|
||||||
|
|
||||||
int lastHyphen = artifactId.lastIndexOf( "-" );
|
|
||||||
|
|
||||||
return artifactId.substring( firstHyphen + 1, lastHyphen );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,14 +19,11 @@ public class PluginUtilsTest
|
||||||
|
|
||||||
public void testShouldTrimArtifactIdToFindPluginId()
|
public void testShouldTrimArtifactIdToFindPluginId()
|
||||||
{
|
{
|
||||||
Model model = new Model();
|
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-artifactId-plugin" ) );
|
||||||
model.setArtifactId( "maven-artifactId-plugin" );
|
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "maven-plugin-artifactId" ) );
|
||||||
|
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "artifactId-maven-plugin" ) );
|
||||||
MavenProject project = new MavenProject( model );
|
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "artifactId" ) );
|
||||||
|
assertEquals( "artifactId", PluginDescriptor.getGoalPrefixFromArtifactId( "artifactId-plugin" ) );
|
||||||
String pluginId = PluginDescriptor.getGoalPrefixFromArtifactId( project.getArtifactId() );
|
|
||||||
|
|
||||||
assertEquals( "artifactId", pluginId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testShouldWriteDependencies()
|
public void testShouldWriteDependencies()
|
||||||
|
|
Loading…
Reference in New Issue