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

Build failure when used in "clean" scope in fresh build #143

Open
raphw opened this issue Nov 28, 2019 · 3 comments
Open

Build failure when used in "clean" scope in fresh build #143

raphw opened this issue Nov 28, 2019 · 3 comments

Comments

@raphw
Copy link

raphw commented Nov 28, 2019

In a multi-module build, due to the use of requiresDependencyResolution = ResolutionScope.TEST, it is impossible to reliably use the plugin before the install phase of dependant modules in the same project. This can be a problem when using the plugin in the clean phase where it can be useful to clean up external resources that are created by the plugin in other phases.

The error happens when building a snapshot version for the first time where intra-project dependencies might not yet exist. When triggering the maven-exec-plugin, Maven will attempt to resolve the dependencies for the module where no dependent package was yet created before the package phase. Therefore, dependency resolution will fail. This is independant of the dependencies being required by the plugin.

As a possible work around, one could create a subclass without any code of its own such as:

@Mojo( name = "raw-exec", 
  threadSafe = true, 
  requiresDependencyResolution = ResolutionScope.NONE )
public class RawExecMojo extends ExecMojo { }

This way, one could use the plugin in the clean phase.

Such a solution would remedy the issue of people often using mvn clean package even on a fresh project where any clone with subsequent build results in an error.

@raphw raphw changed the title Build failure when used in "clean" scope Build failure when used in "clean" scope in fresh build Nov 28, 2019
@lppedd
Copy link

lppedd commented Sep 22, 2022

Hi @raphw!
I'm hitting the same problem.

As a possible work around, one could create a subclass

Could you expand a bit on this?
Are you saying this should be done at exec-maven-plugin level, or in our multi-module project?

There might also be requiresDependencyCollection to consider.

@raphw
Copy link
Author

raphw commented Sep 22, 2022

I argue this needs fixing in Maven, yes.

@lppedd
Copy link

lppedd commented Sep 22, 2022

@raphw thanks.
This kind of multi-module issue is making me go crazy.
It's much more noticeable when you run a CI pipeline.

If you start with projects a and b, and then you deliver c, making b dependent on it, you'll have to run mvn install again.
At this point you'll end up with a pipeline which always uses install, wasting time for nothing.

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

2 participants