mathieucarbou / license-maven-plugin

Manage license headers in your source files

Home Page:https://oss.carbou.me/license-maven-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors when importing a project into Eclipse 2023-03 that uses this plugin

ctubbsii opened this issue · comments

Version affected

Tried using 4.1, 4.2.rc2, 4.2.rc3

Describe the bug

When I import the project into Eclipse 2023-03, I get the following errors (click to expand):
Description	Resource	Path	Location	Type
Failed to execute mojo com.mycila:license-maven-plugin:4.1:format {execution: license-headers} (com.mycila:license-maven-plugin:4.1:format:license-headers:process-test-resources)

org.eclipse.core.runtime.CoreException: Failed to execute mojo com.mycila:license-maven-plugin:4.1:format {execution: license-headers}
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:340)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.lambda$0(MavenExecutionContext.java:291)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:290)
	at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:57)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.lambda$1(MavenBuilderImpl.java:139)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:721)
	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:122)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:164)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$1(MavenBuilder.java:109)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:228)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.lambda$0(MavenBuilder.java:100)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:83)
	at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:192)
	at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:1020)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:247)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
	at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:392)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:395)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:506)
	at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:454)
	at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:536)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:196)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:289)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution license-headers of goal com.mycila:license-maven-plugin:4.1:format failed: Cannot read header document /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt. Cause: Resource /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt not found in file system, classpath or URL: no protocol: /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:338)
	... 32 more
Caused by: java.lang.IllegalArgumentException: Cannot read header document /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt. Cause: Resource /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt not found in file system, classpath or URL: no protocol: /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt
	at com.mycila.maven.plugin.license.header.HeaderSource.of(HeaderSource.java:237)
	at com.mycila.maven.plugin.license.AbstractLicenseMojo.executeForLicenseSet(AbstractLicenseMojo.java:459)
	at com.mycila.maven.plugin.license.AbstractLicenseMojo.executeForLicenseSets(AbstractLicenseMojo.java:429)
	at com.mycila.maven.plugin.license.AbstractLicenseMojo.execute(AbstractLicenseMojo.java:391)
	at com.mycila.maven.plugin.license.LicenseFormatMojo.execute(LicenseFormatMojo.java:69)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	... 33 more
Caused by: org.apache.maven.plugin.MojoFailureException: Resource /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt not found in file system, classpath or URL: no protocol: /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt
	at com.mycila.maven.plugin.license.util.resource.ResourceFinder.findResource(ResourceFinder.java:112)
	at com.mycila.maven.plugin.license.header.HeaderSource.of(HeaderSource.java:233)
	... 38 more
Caused by: java.net.MalformedURLException: no protocol: /home/christopher/git/apache/accumulo/accumulo/core/contrib/license-header.txt
	at java.base/java.net.URL.<init>(URL.java:674)
	at java.base/java.net.URL.<init>(URL.java:569)
	at java.base/java.net.URL.<init>(URL.java:516)
	at com.mycila.maven.plugin.license.util.resource.ResourceFinder.findResource(ResourceFinder.java:107)
	... 39 more
	pom.xml	/accumulo-core	line 24	Maven Build Problem

How to Reproduce

  1. Download Eclipse for Java Developers package
  2. Import the Apache Accumulo project (https://github.com/apache/accumulo) at commit e79532a2d69429e8fdce3f75c1c3121f5673b856 using Import projects -> Maven -> Existing Maven Projects -> Select root directory of checkout -> Click Finish
  3. See the errors

Notably, I didn't get an error in the top-level module of the multi-module project. Only in the child modules. The error seems to show that it can't read the license-header.txt file, but it exists and works fine when running the plugin from Maven command-line.

Additional details

This worked without issue in previous versions of Eclipse. It worked fine in 2022-09, and after upgrading to 2022-12. It also seemed to work after upgrading to 2023-03, but it did not work on a fresh install.

When I tried to import another (smaller, single module) project (https://github.com/revelc/formatter-maven-plugin), it seemed to have trouble resolving the Eclipse plugin from the M2E marketplace.

I'm reporting it here as a starting place. I don't know if the issue is with this plugin, the M2E marketplace, or Eclipse itself.

Gut tells me m2e.

I think you might be right. I couldn't even get the build-helper plugin to work right until I installed the complete M2E Development kit, which comes with all M2E plugins.

Confirmed it works fine with Eclipse 2022-09, but the 2022-12 has the same issues being unable to resolve the Eclipse plugin that affects 2023-03. It also works fine after resolving the plugin in 2022-09, and then upgrading that installation up to 2023-03. One thing I noticed was that the resolved basepom.org m2e extension for the Mycila license plugin. 1.1.0 org.basepom.m2e.mycila-license plugin was not signed. Maybe that has something to do with it.

@ctubbsii will close. The plugin code uses standard Maven Plugin annotations for teh dev. It has and cannot have any effect on IDE support...

I had assumed (incorrectly, it appears) that this plugin shipped with a lifecycle-mapping-metadata file that triggered the corresponding M2E connector, like the one we ship with formatter-maven-plugin (but doesn't have a working connector published).

I had also assumed (likely incorrectly) that the M2E connector for this plugin was affiliated with its maintainers, or at the very least, they would have some insight into how it is triggered.

Since that's not the case, I have absolutely no idea how M2E is triggering and resolving the corresponding M2E connector (or why it is failing to do so in recent M2E versions).

I suppose the next step is to report this at https://github.com/eclipse-m2e/m2e-core

Oh, since the MalformedURLException in the stack trace appeared to be coming from this plugin, I thought perhaps the bug was coming from this plugin somehow.