Maven 2 & 3

Required parameters of self written Mojo configured in execution part of POM are ignored and causing error

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: Plugins and Lifecycle
  • Labels:
    None
  • Environment:
    Windows XP
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

Required parameters configured in execution part of POM are ignored if:

the parameter ist set as required AND
(no default value is set OR
default-Value is set to "") AND
configuration of parameter values are done in the execution element.

Example:

Parameter definition in Mojo:

/** 
	 * @parameter  default-value="ATTENTION DEFAULT"
	 * @required
	 */	
	private File dummy1;

and snip from POM:

<plugins>
      <plugin>
        <groupId>myownartifact.plugin</groupId>
        <artifactId>maven-myownartifact-plugin</artifactId>
        <extensions>true</extensions>
        <executions>
          <execution>
             <id>extract</id>
             <configuration>
              <dummy1>c:/my files/test/dummy1</dummy1>
             </configuration>
             <goals>
               <goal>extract</goal>
             </goals>
          </execution>
        </executions>
      </plugin>     
    </plugins>

runs fine.

If I change the definition of the parameter to

/** 
	 * @parameter 
	 * @required
	 */	
	private File dummy1;

or

* @parameter default-value=""

then I got an error:

[0] inside the definition for plugin: 'maven-myownartifact-plugin'specify the following:

<configuration>
...
<dummy2>VALUE</dummy2>
</configuration>.

In my opinion this is a bug because with @required I have already tagged this parameter as mandatory. So I'm already forced to configure it.

BTW, if I configure the parameters outside the execution element evrything works fine as expected!

More info:

  • the plugin is bind to the package phase

If a runable example is needed it's possible to provide one.

Issue Links

Activity

Hide
Markku Saarela added a comment -

This is very bad bug because I must make my own versions of plugins witch I need to run more than once in same execution with different configuration. One good example is exec-maven-plugin.

Show
Markku Saarela added a comment - This is very bad bug because I must make my own versions of plugins witch I need to run more than once in same execution with different configuration. One good example is exec-maven-plugin.
Hide
Dan Washusen added a comment -

Agreed. I've had to wrap our mvn execution in a shell script to work around this issue...

Show
Dan Washusen added a comment - Agreed. I've had to wrap our mvn execution in a shell script to work around this issue...
Hide
Brian Fox added a comment -

This is a duplicate.

Show
Brian Fox added a comment - This is a duplicate.
Hide
Brian Fox added a comment -

This issue is a duplicate of something that likely cannot be fixed in 2.0.x

Show
Brian Fox added a comment - This issue is a duplicate of something that likely cannot be fixed in 2.0.x

People

Vote (4)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: