Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-7044

Allow use of attributes in Maven pom.xml

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core, POM
    • Labels:

      Description

      Proposal: The current pom.xml file is very verbose due to the exclusive use of XML elements. This makes even simple declarations such as dependencies unnecessarily verbose.

      I would propose that a future version of Maven allow for the use of attributes as an alternative declaration for pom.xml configuration. This would only affect how Maven ingests project files - for consistency and backward compatibility all generated pom.xml files would continue to be element based.

      Projects that declared a conflicting/duplicate attribute/element pairing would be considered to be malformed, and would result in a built break.

      By way of example of the benefit of this proposal, this declaration would be reduced from:

      <dependency>
           <groupId>commons-cli</groupId>
           <artifactId>commons-cli</artifactId>
           <version>1.4</version>
      </dependency>

      ...to...

      <dependency groupId="commons-cli" artifactId="commons-cli" version="1.4" />

      This would allow many Maven projects to dramatically decrease the total line count, which is one of the frequent criticisms of Maven compared with other build tools.

      If there is interest, I would be happy to help support this. My hope/expectation is that the changes required to support this in Maven itself would be quite minor - simply adding a bit of additional logic to look for attributes in the XML parse and error reporting in the event of a duplication (as well as supporting test cases). That said, I don't want to send in patches for a change like this that would be dead on arrival.

      This would, of course, represent a potentially large impact on the user and tooling space (in particular, IDEs that integrate Maven support). As the emitted files for resolved pom.xml files (those that are published in repos) would remain the same, hopefully the overall impacts would be manageable.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                rfscholte Robert Scholte
                Reporter:
                wiverson Will Iverson
              • Votes:
                4 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: