Skip to content

Commit

Permalink
[MNG-5561] Plugin relocation loses configuration
Browse files Browse the repository at this point in the history
Previously, to locate plugin configuration in the project the plugin descriptor
was read and the GA were extracted. This always worked because the GA from the
model and the GA from plugin descriptor (plugin.xml) were identical. When a
plugin is relocated the target artifact is read, thus its plugin descriptor as
well. Naturally, the GA of new (relocated) does not correspond to the old
(static) one in the model. Therefore, the configuration is not found.
New approach is to use the original plugin GA to locate the configuration in
the model regardless of relocation.
  • Loading branch information
michael-o committed Dec 30, 2021
1 parent ef74a62 commit 05b748f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public class DefaultMojoExecutionConfigurator
@Override
public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig )
{
String g = mojoExecution.getGroupId();
String g = mojoExecution.getPlugin().getGroupId();

String a = mojoExecution.getArtifactId();
String a = mojoExecution.getPlugin().getArtifactId();

Plugin plugin = findPlugin( g, a, project.getBuildPlugins() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public PluginDescriptor loadPlugin( Plugin plugin, List<RemoteRepository> reposi
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
RepositorySystemSession session )
{
return MojoExecutorStub.createMojoDescriptor( plugin.getKey() );
return MojoExecutorStub.createMojoDescriptor( plugin );
}

public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.maven.lifecycle.internal.MojoExecutor;
import org.apache.maven.lifecycle.internal.PhaseRecorder;
import org.apache.maven.lifecycle.internal.ProjectIndex;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
Expand Down Expand Up @@ -54,12 +55,14 @@ public void execute( MavenSession session, List<MojoExecution> mojoExecutions, P
}


public static MojoDescriptor createMojoDescriptor( String mojoDescription )
public static MojoDescriptor createMojoDescriptor( Plugin plugin )
{
final PluginDescriptor descriptor = new PluginDescriptor();
descriptor.setArtifactId( mojoDescription );
descriptor.setGroupId( plugin.getGroupId() );
descriptor.setArtifactId( plugin.getArtifactId() );
descriptor.setPlugin( plugin );
descriptor.setVersion( plugin.getVersion() );
final MojoDescriptor mojoDescriptor = new MojoDescriptor();
mojoDescriptor.setDescription( mojoDescription );
mojoDescriptor.setPluginDescriptor( descriptor );
return mojoDescriptor;
}
Expand Down

0 comments on commit 05b748f

Please sign in to comment.