Skip to content

Commit

Permalink
Fix mojohaus#139 - "Can't find license-maven-plugin"
Browse files Browse the repository at this point in the history
Use the PluginDescriptor.
Most painful checkstyle.
  • Loading branch information
AndyGee committed Aug 5, 2019
1 parent 60418bb commit 9f060cb
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
Expand Down Expand Up @@ -203,11 +204,30 @@ protected void doAction()
}
if ( groupId == null )
{
throw new IllegalStateException( "Can't find license-maven-plugin" );
try
{
final PluginDescriptor pd = ( PluginDescriptor ) getPluginContext().get( "pluginDescriptor" );
groupId = pd.getGroupId();
artifactId = pd.getArtifactId();
version = pd.getVersion();
}
catch ( ClassCastException e )
{
LOG.warn( "Failed to access PluginDescriptor", e );
}

if ( groupId == null )
{
throw new IllegalStateException( "Failed to determine the license-maven-plugin artifact."
+
"Please add it to your parent POM." );
}
}

String addThirdPartyRoleHint = groupId + ":" + artifactId + ":" + version + ":" + "add-third-party";

LOG.info( "The default plugin hint is: " + addThirdPartyRoleHint );

for ( MavenProject reactorProject : reactorProjects )
{
if ( getProject().equals( reactorProject ) && !acceptPomPackaging )
Expand Down

0 comments on commit 9f060cb

Please sign in to comment.