Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven plugin required parameter

I'm writing my own Maven plugin. My Mojo has a required parameter list:

@Parameter(property = "map.packages", required = true)
private List<String> packages;

Now, when I run this plugin in a project with no configuration, I would expect the build to fail as the packages parameter is required. Instead I get packages as an empty list.

Is this a bug or am I doing something wrong?

Ps. I probably should have added this to some issue tracker but where is Maven's issue tracker?

like image 391
vertti Avatar asked Apr 25 '26 20:04

vertti


1 Answers

The problem is located based on the property which can be observed via a debug output (with the help of an integration test) which looks like this:

[DEBUG] -----------------------------------------------------------------------
[DEBUG] Goal:          com.nitorcreations:drm-maven-plugin:1.1-SNAPSHOT:map (test-parameter)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <outputDirectory default-value="${project.build.directory}">${outputDir}</outputDirectory>
  <packages>${map.packages}</packages>
  <project default-value="${project}"/>
</configuration>

Here you can see that the property (map.packages) will be injected into the package configuration parameter which means the configuration parameter has a value which fulfills the required parameter. If you need having a property defined in combination with required you need to check in the execute() method.

like image 113
khmarbaise Avatar answered Apr 29 '26 22:04

khmarbaise



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!