Skip to content

Commit

Permalink
Merge pull request #348 from AndyGee/AndyGee-139
Browse files Browse the repository at this point in the history
Fix #139 - "Can't find license-maven-plugin"
  • Loading branch information
ppalaga committed Aug 5, 2019
2 parents 663b9f6 + 24c6bc5 commit 01fd9a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/it/add-third-party-no-encoding/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
# <http://www.gnu.org/licenses/lgpl-3.0.html>.
# #L%
###
invoker.goals=clean license:add-third-party
invoker.failureBehavior=fail-fast
invoker.goals=clean ${project.groupId}:${project.artifactId}:${project.version}:add-third-party
invoker.failureBehavior=fail-fast
13 changes: 0 additions & 13 deletions src/it/add-third-party-no-encoding/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@
<version>1.1.1</version>
</dependency>
</dependencies>
<build>

<pluginManagement>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>

Expand Down
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 01fd9a1

Please sign in to comment.