jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Maven 2.x Resources Plugin
  • MRESOURCES-158

outputDirectory is marked as mandatory whereas it is not really mandatory

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Not A Bug
  • Affects Version/s: 2.5
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

in the documentation and plugin descriptor the outputDirectory config element is marked as mandatory. But since there is a default value of ${project.build.outputDirectory} this element is not really mandatory. Other configuration elements with the same default value semantics are not marked as mandatory so i think for outputDirectory the same semantics should be applied.

this is especially troublesome for ideas that try to assist in maven configuration and rely on the plugin descriptor to figure out if elements are mandatory or not. See http://youtrack.jetbrains.net/issue/IDEA-80626

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Robert Scholte added a comment - 01/Feb/12 12:54 PM

Mandatory has nothing to do with default values. If you empty a mandatory parameter, the build should fail.

Show
Robert Scholte added a comment - 01/Feb/12 12:54 PM Mandatory has nothing to do with default values. If you empty a mandatory parameter, the build should fail.
Hide
Permalink
Jorg Heymans added a comment - 01/Feb/12 1:26 PM

There are different semantics IMO.

1) 'emptying' the parameter value as you say is this:

<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <outputDirectory/>
        </configuration>
      </plugin>

The value was in this case specified as null so a build error will be triggered because it is mandatory. Does mandatory then mean a not-null not-empty string or is this up to the plugin to interpret ?

2) Not specifying the parameter at all:

<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
      </plugin>

In this case the default value kicks in.

3) Specifying the parameter, the common case no problem there

<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <outputDirectory>mydir</outputDirectory>
        </configuration>
      </plugin>

Is this consistent for all maven plugins ? In that case an IDE should do an extra check in case of a mandatory parameter, i.e. not-null check on the value if the element is specified, and let it pass if the element is not specified and has a default value. But this would break if there are plugins out there that specify mandatory parameters without a default value. Do these exist ? And where is the default value kept, it's not in the plugin descriptor AFAICT.

Show
Jorg Heymans added a comment - 01/Feb/12 1:26 PM There are different semantics IMO. 1) 'emptying' the parameter value as you say is this:
<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <outputDirectory/>
        </configuration>
      </plugin>
The value was in this case specified as null so a build error will be triggered because it is mandatory. Does mandatory then mean a not-null not-empty string or is this up to the plugin to interpret ? 2) Not specifying the parameter at all:
<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
      </plugin>
In this case the default value kicks in. 3) Specifying the parameter, the common case no problem there
<plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <outputDirectory>mydir</outputDirectory>
        </configuration>
      </plugin>
Is this consistent for all maven plugins ? In that case an IDE should do an extra check in case of a mandatory parameter, i.e. not-null check on the value if the element is specified, and let it pass if the element is not specified and has a default value. But this would break if there are plugins out there that specify mandatory parameters without a default value. Do these exist ? And where is the default value kept, it's not in the plugin descriptor AFAICT.
Hide
Permalink
Robert Scholte added a comment - 01/Feb/12 4:32 PM

Here's an example of a help goal as specified in the META-INF/maven/plugin.xml:

<mojo>
      <goal>help</goal>
      <description>Display help information on maven-jar-plugin.&lt;br/&gt; Call &lt;pre&gt;  mvn jar:help -Ddetail=true -Dgoal=&amp;lt;goal-name&amp;gt;&lt;/pre&gt; to display parameter details.</description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>false</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      <implementation>org.apache.maven.plugin.jar.HelpMojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <threadSafe>true</threadSafe>
      <parameters>
        <parameter>
          <name>detail</name>
          <type>boolean</type>
          <required>false</required>
          <editable>true</editable>
          <description>If &lt;code&gt;true&lt;/code&gt;, display all settable properties for each goal.</description>
        </parameter>
        <parameter>
          <name>goal</name>
          <type>java.lang.String</type>
          <required>false</required>
          <editable>true</editable>
          <description>The name of the goal for which to show help. If unspecified, all goals will be displayed.</description>
        </parameter>
        <parameter>
          <name>indentSize</name>
          <type>int</type>
          <required>false</required>
          <editable>true</editable>
          <description>The number of spaces per indentation level, should be positive.</description>
        </parameter>
        <parameter>
          <name>lineLength</name>
          <type>int</type>
          <required>false</required>
          <editable>true</editable>
          <description>The maximum length of a display line, should be positive.</description>
        </parameter>
      </parameters>
      <configuration>
        <detail implementation="boolean" default-value="false">${detail}</detail>
        <goal implementation="java.lang.String">${goal}</goal>
        <indentSize implementation="int" default-value="2">${indentSize}</indentSize>
        <lineLength implementation="int" default-value="80">${lineLength}</lineLength>
      </configuration>
    </mojo>

The configuration-section contains these values.
Is it consistent? Probably not, but it should. Just like default-value and expression they are often confused, but they are slightly different.

Does mandatory then mean a not-null not-empty string or is this up to the plugin to interpret ?

This is verified by Plexus. As a plugin-developer you only have to say it is @required.

Show
Robert Scholte added a comment - 01/Feb/12 4:32 PM Here's an example of a help goal as specified in the META-INF/maven/plugin.xml:
<mojo>
      <goal>help</goal>
      <description>Display help information on maven-jar-plugin.&lt;br/&gt; Call &lt;pre&gt;  mvn jar:help -Ddetail=true -Dgoal=&amp;lt;goal-name&amp;gt;&lt;/pre&gt; to display parameter details.</description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>false</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      <implementation>org.apache.maven.plugin.jar.HelpMojo</implementation>
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <threadSafe>true</threadSafe>
      <parameters>
        <parameter>
          <name>detail</name>
          <type>boolean</type>
          <required>false</required>
          <editable>true</editable>
          <description>If &lt;code&gt;true&lt;/code&gt;, display all settable properties for each goal.</description>
        </parameter>
        <parameter>
          <name>goal</name>
          <type>java.lang.String</type>
          <required>false</required>
          <editable>true</editable>
          <description>The name of the goal for which to show help. If unspecified, all goals will be displayed.</description>
        </parameter>
        <parameter>
          <name>indentSize</name>
          <type>int</type>
          <required>false</required>
          <editable>true</editable>
          <description>The number of spaces per indentation level, should be positive.</description>
        </parameter>
        <parameter>
          <name>lineLength</name>
          <type>int</type>
          <required>false</required>
          <editable>true</editable>
          <description>The maximum length of a display line, should be positive.</description>
        </parameter>
      </parameters>
      <configuration>
        <detail implementation="boolean" default-value="false">${detail}</detail>
        <goal implementation="java.lang.String">${goal}</goal>
        <indentSize implementation="int" default-value="2">${indentSize}</indentSize>
        <lineLength implementation="int" default-value="80">${lineLength}</lineLength>
      </configuration>
    </mojo>
The configuration-section contains these values. Is it consistent? Probably not, but it should. Just like default-value and expression they are often confused, but they are slightly different.
Does mandatory then mean a not-null not-empty string or is this up to the plugin to interpret ?
This is verified by Plexus. As a plugin-developer you only have to say it is @required.
Hide
Permalink
Jorg Heymans added a comment - 02/Feb/12 2:15 AM

thanks for your insight, this is not-a-bug then i guess.

Show
Jorg Heymans added a comment - 02/Feb/12 2:15 AM thanks for your insight, this is not-a-bug then i guess.

People

  • Assignee:
    Unassigned
    Reporter:
    Jorg Heymans
Vote (0)
Watch (1)

Dates

  • Created:
    01/Feb/12 3:50 AM
    Updated:
    02/Feb/12 2:15 AM
    Resolved:
    02/Feb/12 2:15 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.