mojohaus / mojohaus/exec-maven-plugin

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

Open
#143 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
191
Forks
111
Avg merge
1d 21h
Merged PRs (30d)
4

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the maven-exec-plugin's ExecMojo annotation and the proposed RawExecMojo subclass, then reproduce the failure in a fresh multi-module build using the clean phase. Confirm that dependency resolution no longer fails when running mvn clean package before dependent modules have been installed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.