Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public List<TaskSegment> calculateTaskSegments( MavenSession session, List<Strin
{
if ( isGoalSpecification( task ) )
{
// "pluginPrefix:goal" or "groupId:artifactId[:version]:goal"
// "pluginPrefix[:version]:goal" or "groupId:artifactId[:version]:goal"

lifecyclePluginResolver.resolveMissingPluginVersions( session.getTopLevelProject(), session );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,31 @@ public MojoDescriptor getMojoDescriptor( String task, MavenSession session, Mave
}
else if ( numTokens == 3 )
{
// We have everything that we need except the version
//
// org.apache.maven.plugins:maven-remote-resources-plugin:???:process
//
// groupId
// artifactId
// ???
// goal
//
plugin = new Plugin();
plugin.setGroupId( tok.nextToken() );
plugin.setArtifactId( tok.nextToken() );
// groupId:artifactId:goal or pluginPrefix:version:goal (since Maven 3.9.0)

String firstToken = tok.nextToken();
// groupId or pluginPrefix? heuristics: groupId contains dot (.) but not pluginPrefix
if ( firstToken.contains( "." ) )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can make this assumption for sure since for testing or other reasong the groupId could be: foo, bar-baz

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to test a plugin for such simplified run, just don't define such a groupId
at least, it seems to work for real world plugins, that's the first intent

of course, if you find a better heuristics, or even an algorithm, I'm all ears open

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave it some thought, but I can't find a better heuristic either. The only thing more or less foolproof would be to look at the first token, assuming it is a plugin prefix. If that lookup yields nothing, it would be a groupId.

Even that is not 100% safe, though. Imagine you're not connected to the network, so lookup fails, so we decide it's a groupId -- this certainly doesn't make sense. But more importantly, it's probably quite costly compared to a String.contains :-).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and do you really think that we'll have any single word groupId in the future, given Maven Central explicitely asks for DNS matching?
heuristics is heuristics: in theory there could be edge cases, but in real world, it simply works

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indeed breaks real-world projects. We're using a single word groupId internally and invoking maven using mvn groupId:artifactId:goal@executionId no longer works starting with Maven 3.8.8.

{
// We have everything that we need except the version
//
// org.apache.maven.plugins:maven-remote-resources-plugin:???:process
//
// groupId
// artifactId
// ???
// goal
//
plugin = new Plugin();
plugin.setGroupId( firstToken );
plugin.setArtifactId( tok.nextToken() );
}
else
{
// pluginPrefix:version:goal, like remote-resources:3.5.0:process
plugin = findPluginForPrefix( firstToken, session );
plugin.setVersion( tok.nextToken() );
}
goal = tok.nextToken();
}
else if ( numTokens <= 2 )
Expand Down