Repository navigation
Closed
Labels
bugSomething isn't working
Description
Hi,
we are trying to upgrade from 2.1.0 to 2.2.0 in our project.
Currently, we use
mvn license:aggregate-add-third-party@generate-and-check-licenses -Dlicense.skipAggregateAddThirdParty=false -Dlicense.thirdPartyFilename=DEPENDENCY-LICENSES -Dlicense.outputDirectory=targetin a CI env with a config as follows
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<missingFile>${project.basedir}/THIRD-PARTY.properties</missingFile>
<aggregateMissingLicensesFile>${project.basedir}/THIRD-PARTY.properties</aggregateMissingLicensesFile>
</configuration>
<executions>
<execution>
<id>generate-and-check-licenses</id>
<goals>
<goal>aggregate-add-third-party</goal>
</goals>
</execution>
<execution>
<id>download-licenses</id>
<goals>
<goal>aggregate-download-licenses</goal>
</goals>
</execution>
</executions>
</plugin>and
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${maven.mojo.license.plugin}</version>
<configuration>
<useMissingFile>true</useMissingFile>
<failOnMissing>true</failOnMissing>
<includeTransitiveDependencies>true</includeTransitiveDependencies>
<fileTemplate>/org/codehaus/mojo/license/third-party-file-groupByMultiLicense.ftl
</fileTemplate>
<excludedScopes>system,test</excludedScopes>
<excludedGroups>${project.groupId}</excludedGroups>
<licenseMerges>
<licenseMerge>
Apache License, Version 2.0 |
Apache License, version 2.0 |
Apache License Version 2 |
Apache License Version 2.0 |
Apache License version 2.0 |
Apache 2 |
Apache 2.0 |
Apache License, 2.0 |
Apache License 2 |
Apache License 2.0 |
Apache Public License 2.0 |
Apache Software License - Version 2.0 |
Apache v2 |
ASL, version 2 |
The Apache License, Version 2.0 |
The Apache Software License, Version 2.0
</licenseMerge>
<licenseMerge>
Apache License |
Apache Software Licenses
</licenseMerge>
<licenseMerge>
BSD License |
BSD license |
BSD |
The BSD License
</licenseMerge>
<licenseMerge>
BSD 3-Clause License |
BSD 3-Clause |
BSD 3-clause |
The BSD 3-Clause License |
New BSD License |
New BSD license
</licenseMerge>
<licenseMerge>
Common Development and Distribution License (CDDL) v1.0 |
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 |
CDDL 1.0
</licenseMerge>
<licenseMerge>
Common Development and Distribution License (CDDL) v1.1 |
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1 |
CDDL 1.1 |
Common Development and Distribution License (CDDL), Version 1.1
</licenseMerge>
<licenseMerge>
Common Development and Distribution License |
<!-- Multilicense, choosing CDDL -->
CDDL+GPL |
CDDL+GPL License |
CDDL + GPLv2 with classpath exception
</licenseMerge>
<licenseMerge>
Eclipse Public License, Version 1.0 |
Eclipse Public License 1.0 |
Eclipse Public License - v 1.0
</licenseMerge>
<licenseMerge>
Eclipse Public License, Version 2.0 |
EPL-2.0 |
EPL 2.0
</licenseMerge>
<licenseMerge>
Eclipse Distribution License, Version 1.0 |
Eclipse Distribution License - v 1.0 |
EDL 1.0
</licenseMerge>
<licenseMerge>
MIT License |
The MIT License |
MIT license |
MIT X11 License |
MIT
</licenseMerge>
<licenseMerge>
The GNU General Public License (GPL), Version 2, With Classpath Exception |
GPL2 w/ CPE
</licenseMerge>
<licenseMerge>
GNU Lesser General Public License (LGPL), Version 2.1 |
LGPL, version 2.1 |
GNU Lesser General Public License Version 2.1 |
GNU Lesser General Public License, version 2.1
</licenseMerge>
<licenseMerge>
Common Public License Version 1.0 |
Common Public License - v 1.0
</licenseMerge>
</licenseMerges>
</configuration>
</plugin>This works fine with 2.1.0 but now fails with a NullPointerException in 2.2.0:
[ERROR] Failed to execute goal org.codehaus.mojo:license-maven-plugin:2.2.0:aggregate-add-third-party (generate-and-check-licenses) on project XXX could not execute goal AggregatorAddThirdPartyMojo for reason : null: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:license-maven-plugin:2.2.0:aggregate-add-third-party (generate-and-check-licenses) on project XXX: could not execute goal AggregatorAddThirdPartyMojo for reason : null
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: could not execute goal AggregatorAddThirdPartyMojo for reason : null
at org.codehaus.mojo.license.AbstractLicenseMojo.execute (AbstractLicenseMojo.java:187)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
at org.codehaus.mojo.license.api.DefaultThirdPartyTool.getProjectsWithNoLicense (DefaultThirdPartyTool.java:168)
at org.codehaus.mojo.license.api.DefaultThirdPartyHelper.getProjectsWithNoLicense (DefaultThirdPartyHelper.java:214)
at org.codehaus.mojo.license.AbstractAddThirdPartyMojo.consolidate (AbstractAddThirdPartyMojo.java:775)
at org.codehaus.mojo.license.AddThirdPartyMojo.initFromMojo (AddThirdPartyMojo.java:440)
at org.codehaus.mojo.license.AggregatorAddThirdPartyMojo.doAction (AggregatorAddThirdPartyMojo.java:221)
at org.codehaus.mojo.license.AbstractLicenseMojo.execute (AbstractLicenseMojo.java:180)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:298)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Obviously, after looking into the code it seems that licenseMap is NULL.
Any idea what I am missing here or anything we are doing wrong in the related config?
Thanks in advance!
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
slawekjaranowski commentedon Jul 4, 2023
Can you provide a simple project which reproduce issue.
We can add such project to IT in order to be sure with next changes.
Something like in https://github.com/mojohaus/license-maven-plugin/tree/master/src/it
rzo1 commentedon Jul 4, 2023
Tried fiddling around to produce a minimal reproducer but failed to build one. It seems, that it is bit tricky to reproduce.
From
mvnDebugit seems, that there are two executions involved. The first one correctly populates thelicenseMap, in the second phase, we are running into an early return inhttps://github.com/mojohaus/license-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java#L736
which leaves the
licenseMapuninitalized (=null). This is confirmed by doing agit bisect, which leads to 1c8fab2For completeness, I added the full plugin config in the entry post.
I will try building an IT for it, if I find some more time this week.
slawekjaranowski commentedon Jul 4, 2023
It can be my fault ... 😄
I was assume that we not need more computation if plugin should skip executions ...
But looks like aggregate goal do something more in some cases ....
rzo1 commentedon Jul 4, 2023
Did some more debugging :-)
A workaround would be to use
-Dlicense.force=true.The skip condition is meet due to the following change from
to
In the 2nd execution,
projectFile.lastModified() > thirdPartyFile.lastModified()isfalse, thethirdPartyFileexists anddoGeneratewill befalse, so we are hitting theskipcondition later running into the NPE.I guess, that this was an optimization to avoid regeneration if the actual project file wasn't modified?
slawekjaranowski commentedon Jul 5, 2023
There is some magic in code ... in aggregate goal method
initFromMojois called for each child ... such code can be refactored but it is another issue.There is
isAggregatorBuildfield - it should be moved to AbstractAddThirdPartyMojo or used as parameter forAbstractAddThirdPartyMojo#initand used in condition for check if mojo should be executed.By the way I still can not reproduce even execute many times ....
I will prepare a fix.
mojohaus#508 - Add basic IT setup
mojohaus#508 - Add basic IT setup
mojohaus#508 - No clean in invoker goals
mojohaus#508 - Adjust setup
rzo1 commentedon Jul 5, 2023
I am able to reproduce it in GitHub actions via https://github.com/rzo1/license-maven-plugin-508 in https://github.com/rzo1/license-maven-plugin-508/actions/runs/5461908479/jobs/9940529031 (not in an IT, was trying it in https://github.com/rzo1/license-maven-plugin/commits/master)
#508 - Add basic IT setup
slawekjaranowski commentedon Jul 18, 2023
I have created branch with your examples: https://github.com/mojohaus/license-maven-plugin/commits/issue-508
And all test was pass 😄
https://github.com/mojohaus/license-maven-plugin/actions?query=branch%3Aissue-508
any idea?
rzo1 commentedon Jul 18, 2023
@slawekjaranowski Yeah, I didn't get the IT failing either :/
The setup is basically similar to https://github.com/rzo1/license-maven-plugin-508 - the only real difference is the pre-existing
DEPENDENCY-LICENSESin the root directory. This is also similar to the setup they have in https://github.com/camunda/connector-sdk/pull/510 were they also encountered the issue.Therefore, I guess, that the pre-existing file plays a role. For testing, I added it to the IT with similar results: IT passes :/
slawekjaranowski commentedon Jul 18, 2023
@rzo1 - I have a reproduce 😄
Fix #508 - Avoid NPE in AggregatorAddThirdPartyMojo (#512)
rzo1 commentedon Jul 23, 2023
Thanks @slawekjaranowski !