mojohaus / license-maven-plugin

Maven plugin to download and collect license files from project dependencies.
https://www.mojohaus.org/license-maven-plugin/
GNU Lesser General Public License v3.0
106 stars 125 forks source link

Is multimodule working when using aggregate-add-third-party? #107

Open v1v opened 6 years ago

v1v commented 6 years ago

For some reason when I use 1.14 version plus the '--projects' flag to just run the aggregate goal. it skips the multimodule as you can see below:

 mvn license:aggregate-add-third-party -Pgenerate-third-party -pl multimodule-with-war-util
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building multimodule-with-war-util 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- license-maven-plugin:1.14:aggregate-add-third-party (default-cli) @ multimodule-with-war-util ---
[WARNING] The goal is skip due to packaging 'jar'
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

while if I use 1.13 it works as expected

 mvn license:aggregate-add-third-party -Pgenerate-third-party -pl multimodule-with-war-util
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building multimodule-with-war-util 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> license-maven-plugin:1.13:aggregate-add-third-party (default-cli) > :add-third-party @ multimodule-with-war-util >>>
[INFO] 
[INFO] --- license-maven-plugin:1.13:add-third-party (add-third-party) @ multimodule-with-war-util ---
[WARNING] No license name defined for org.apache.xbean--xbean-asm5-shaded--3.17
[WARNING] No license name defined for org.apache.xbean--xbean-asm5-shaded--3.17
[WARNING] There is 1 dependencies with no license :
[WARNING]  - stax--stax--1.2.0
[INFO] Writing third-party file to /Users/victor/work/temp/multimodule-with-war/multimodule-with-war-util/target/generated-sources/license/THIRD-PARTY.txt
[INFO] 
[INFO] <<< license-maven-plugin:1.13:aggregate-add-third-party (default-cli) < :add-third-party @ multimodule-with-war-util <<<
[INFO] 
[INFO] 
[INFO] --- license-maven-plugin:1.13:aggregate-add-third-party (default-cli) @ multimodule-with-war-util ---
[WARNING] The goal is skip due to packaging 'jar'

Someone else already posted this issue: https://github.com/mojohaus/license-maven-plugin/issues/93 and I was able to reproduce in my multimodule project.

Any hints?

Thanks

TorstenKruse commented 6 years ago

Hi. Goal aggregate-add-third-party does not work for me, too. I always get "You should use missingFile parameter instead of deprecated aggregateMissingLicensesFile." although I use missingFile instead of aggregateMissingLicensesFile. Looking into code, probably aggregateMissingLicensesFile still has its default value and won't be null at any time?

Workaround: Set aggregateMissingLicensesFile to the same value as missingFile

But even with the workaround, the missingFileUrl won't be used at all and the missingFile won't be generated.

ppalaga commented 5 years ago

I recently merged a couple of fixes in this area. Could you please reproduce using a SNAPSHOT built from the current master?

TorstenKruse commented 5 years ago

Using the current master snapshot I get an error on execution on my windows 10.

[11:49:32] [ERROR] Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.17-SNAPSHOT:add-third-party (default-cli) on project pad: could not execute goal AddThirdPartyMojo for reason : \dev\null (Das System kann den angegebenen Pfad nicht finden) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.17-SNAPSHOT:add-third-party (default-cli) on project pad: could not execute goal AddThirdPartyMojo for reason : \dev\null (Das System kann den angegebenen Pfad nicht finden)

Root cause is:

Caused by: java.io.FileNotFoundException: \dev\null (Das System kann den angegebenen Pfad nicht finden) at java.base/java.io.FileInputStream.open0(Native Method) at java.base/java.io.FileInputStream.open(FileInputStream.java:220) at java.base/java.io.FileInputStream.(FileInputStream.java:158) at java.base/java.io.FileInputStream.(FileInputStream.java:113) at java.base/sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:86) at java.base/sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:184) at java.base/java.net.URL.openStream(URL.java:1117) at org.codehaus.mojo.license.api.DefaultThirdPartyTool.overrideLicenses(DefaultThirdPartyTool.java:618) at org.codehaus.mojo.license.AbstractAddThirdPartyMojo.overrideLicenses(AbstractAddThirdPartyMojo.java:1002) at org.codehaus.mojo.license.AbstractAddThirdPartyMojo.consolidate(AbstractAddThirdPartyMojo.java:751) at org.codehaus.mojo.license.AddThirdPartyMojo.doAction(AddThirdPartyMojo.java:173) at org.codehaus.mojo.license.AbstractLicenseMojo.execute(AbstractLicenseMojo.java:202)

ppalaga commented 5 years ago

@TorstenKruse Sorry for that. It is probably my fault. It is a pity that we still do not have a Windows CI. I am waiting for Mojohaus folks to check why it does not work yet.

ppalaga commented 5 years ago

@TorstenKruse could you please re-try now after I merged https://github.com/mojohaus/license-maven-plugin/pull/194 ?

TorstenKruse commented 5 years ago

@ppalaga After pulling current master the former exception is gone. But another arises. Would be nice to get another fix.

[14:34:18] [ERROR] Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.17-SNAPSHOT:aggregate-download-licenses (default-cli) on project pad: Unable to parse license summary output file: e:\Projects_git\pad\target\generated-resources\licenses.xml: NullPointerException -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.17-SNAPSHOT:aggregate-download-licenses (default-cli) on project pad: Unable to parse license summary output file: e:\Projects_git\pad\target\generated-resources\licenses.xml at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to parse license summary output file: e:\Projects_git\pad\target\generated-resources\licenses.xml at org.codehaus.mojo.license.AbstractDownloadLicensesMojo.loadLicenseInfo(AbstractDownloadLicensesMojo.java:597) at org.codehaus.mojo.license.AbstractDownloadLicensesMojo.execute(AbstractDownloadLicensesMojo.java:334) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) ... 20 more Caused by: java.lang.NullPointerException at java.base/java.io.File.(File.java:359) at org.codehaus.mojo.license.AbstractDownloadLicensesMojo.loadLicenseInfo(AbstractDownloadLicensesMojo.java:590) ... 23 more

ppalaga commented 5 years ago

@TorstenKruse could you please check after https://github.com/mojohaus/license-maven-plugin/pull/198 was merged?

TorstenKruse commented 5 years ago

Build is successful now! But the strange warning is still there.

First the goal add-third-party is executed for each module of the multi-module project. This is fine. At last the aggregate-add-third-party is executed for the complete project and it still starts with the following messagen:

[08:29:58] [INFO] --- license-maven-plugin:1.17-SNAPSHOT:aggregate-add-third-party (default-cli) @ pad --- [08:29:58] [WARNING] [08:29:58] [WARNING] You should use missingFile parameter instead of deprecated aggregateMissingLicensesFile. [08:29:58] [WARNING] [08:29:58] [INFO] All files are up to date, skip goal execution.

ppalaga commented 5 years ago

@TorstenKruse thanks for your effort. From what you say, I am not sure what of the following is true:

  1. The current issue (as originally described) is still reproducible
  2. The warning about missingFile and aggregateMissingLicensesFile is misleading but otherwise the mojo behaves as expected.

Could you please confirm or deny these two statements?

TorstenKruse commented 5 years ago

Well, I'm not 100% sure too because my original fault was slightly different from the inital one of this issue. I think we should ask @v1v . For him the check did not run properly because of packaging jar combined with aggregate goal. For me the check did not run properly because the missingFileUrl was not handeled properly in aggregate.

When I try packaging "jar" for my multi-module project I get

'packaging' with value 'jar' is invalid. Aggregator projects require 'pom' as packaging from maven.

So I cannot reproduce your first point. The second one seems to be ok for me now except of the really misleading message which should be removed.

ppalaga commented 5 years ago

OK, let's keep this open, although I cannot tell this is a bug. An integration test demonstrating the issue would be highly welcome.

As for the the warning about missingFile and aggregateMissingLicensesFile, @TorstenKruse feel free to open a new issue.

TorstenKruse commented 5 years ago

ok, i created #207