Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with war packaging since m2e 2.2.0.20230228 #23

Open
laurent149 opened this issue Mar 2, 2023 · 11 comments
Open

Error with war packaging since m2e 2.2.0.20230228 #23

laurent149 opened this issue Mar 2, 2023 · 11 comments

Comments

@laurent149
Copy link

laurent149 commented Mar 2, 2023

Since a recent m2e update (2.2.0.20230228), I'm seeing the following error on all my projects using maven-war-plugin:

    Failed to execute mojo org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources {execution: default-cli} (org.apache.maven.plugins:maven-war-plugin:3.3.2:war:default-war:package)
    
    org.eclipse.core.runtime.CoreException: Failed to execute mojo org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources {execution: default-cli}
    	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:374)
    	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.wtp.internal.filtering.ResourceFilteringBuildParticipant.executeCopyResources(ResourceFilteringBuildParticipant.java:271)
    	at org.eclipse.m2e.wtp.internal.filtering.ResourceFilteringBuildParticipant.build(ResourceFilteringBuildParticipant.java:94)
    	at org.eclipse.m2e.wtp.internal.build.WarProjectBuildParticipant.build(WarProjectBuildParticipant.java:52)
    	at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.lambda$1(MavenBuilderImpl.java:139)
    	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:729)
    	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:374)
    	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:374)
    	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.PluginParameterException: The parameters 'resources', 'outputDirectory' for goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources are missing or invalid
    	at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:644)
    	at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:597)
    	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:124)
    	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:338)
    	... 34 more

How can I address this? Preferably without pom modifications (otherwise I have tens of projects to update).

@laeubi
Copy link
Member

laeubi commented Mar 2, 2023

Have you checked what is complained here?

The parameters 'resources', 'outputDirectory' for goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources are missing or invalid

@laurent149
Copy link
Author

Sure, I saw that, but I don't have any explicit usage of maven-resources-plugin, so not sure what is happening here.
And surely, the fact that this only appears following an m2e update is no coincidence.

@laeubi
Copy link
Member

laeubi commented Mar 2, 2023

copy-resources a default goal of the war-life-cycle so you have it enabled always.

The best way would be if you can reproduce the problem with a self contained demo-project so one can beter see whats going on. Another option would be to take a look at the effective pom.

@laurent149
Copy link
Author

I can reproduce the issue with the simplest war project you can think of: https://github.com/laurent149/maven-war-plugin-demo
But maybe it has to do with my Eclipse setup? I started seeing the issue with Eclipse 2022-12. Now I've updated to 2023-03 in the hope that it might help, but it didn't.
The effective pom says:

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

@mickaelistria
Copy link
Contributor

Couldn't it be that the mojo executions were skipped by default so far, and that they become on by default in latest release; and cause some mojo executions to be triggered, including some of them to fail?

@laeubi looking at the definition of the war lifecycle in plexus/components.xml of the maven-war-plugin-3.3.2.jar shows no reference to copy-resources mojo. So it's indeed very curious that such issue arises.

I tried importing it and didn't see any issue, even when referencing non-existing plugin types; so I suspect my m2e setup is also broken.

@laeubi
Copy link
Member

laeubi commented Mar 2, 2023

The original stack trace said it is executed as {execution: default-cli} that means its execution is explicitly requested as a goal...

@laurent149
Copy link
Author

I tried to reproduce the issue on a freshly installed Eclipse and I couldn't.
So I dug further into what could cause the problem with my own Eclipse setup.
It turns out that I had a bunch of m2e-wtp plugins (in version 1.6.0.20230118-0812), no idea when or why they were installed. But the point is that after uninstalling them, I no longer have the aforementioned errors with maven-war-plugin 👍
⇒ problem solved as far as I'm concerned.
Thanks a lot for your help and reactivity!

@blacelle
Copy link

blacelle commented Mar 3, 2023

Couldn't it be that the mojo executions were skipped by default so far, and that they become on by default in latest release;

Eclipse is getting very slow here, as it seems various static-analysis Mojo are running while previously skipped.

@laeubi
Copy link
Member

laeubi commented Mar 3, 2023

Go to the pom, select the mojo execution you don't want (it should get an info icon) and select "disable ..." from the QuickFix.

As an alternative, you can configure the default behavior here:
https://github.com/eclipse-m2e/m2e-core/blob/master/RELEASE_NOTES.md#mojos-without-a-mapping-are-now-executed-by-default-in-incremental-builds

@fbricon
Copy link
Contributor

fbricon commented Mar 3, 2023

Thw Web project configurator executes the maven-resources-plugin:copy-resources goal when web resources filtering is enabled:

 <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>3.3.2</version>
      <configuration>
          <webResources>
              <resource>
                  <directory>${project.basedir}/src/main/webapp</directory>
                  <filtering>true</filtering>
              </resource>
          </webResources>
      </configuration>
  </plugin>

Somehow it broke with m2e 2.2.0

@fbricon fbricon reopened this Mar 3, 2023
@fbricon
Copy link
Contributor

fbricon commented Mar 7, 2023

@laeubi this was broken by eclipse-m2e/m2e-core@5640b34#diff-796a271293c65b5cac9c04a4dccddff344e43fd10f474a5cd2992c2333325704R329

When cloning the MojoExecution, the MojoExecution configuration set by m2e-wtp is not copied over, effectively calling an incomplete mojo execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants