[Commented] (MNG-7044) Allow use of attributes in Maven pom.xml

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Commented] (MNG-7044) Allow use of attributes in Maven pom.xml

Marco Patavini (Jira)

    [ https://issues.apache.org/jira/browse/MNG-7044?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17243432#comment-17243432 ]

Will Iverson commented on MNG-7044:

KK, so the validation of the model happens in Java. The actual parsing of the model appears to be from Java code generated by Modello.

It appears that the Modello Maven plugin is used to generate Java parsing code from a Modello file. This page has links with the Modello plugin and the Maven Modello file available here:


Interestingly, the existing page for Modello lists other formats besides XML (e.g. YAML).


This is the Maven core project that actually generates the Model parsing from Modello:


That maven-model project is interesting, as there is essentially no code in it at all, just the Modello generation. Checking that code out and running it to generate the Modello XML parsing is quite interesting and (happily) pretty straight-forward.

It appears that the theoretical path is to add an option to the Modello Java generator to add attribute processing via a flag. So, then the process is (again, to flog theoretical) submit a patch to add the option to Modello to allow for attribute alias generation (looks like just a few lines), and then submit a patch to turn that option on in the maven-model project (a single line to enable it in the Modello configuration).

Unfortunately, the links on the Modello page to documentation appear to be broken due to the codehaus dissolution.

Let me know any thoughts/observations. I would guess adding an option to Modello to generate attribute aliasing is, in itself, pretty innocuous/likely to be accepted. Which, in turn, would mean that flipping the option on would be a single line PR for maven-model.



> Allow use of attributes in Maven pom.xml
> ----------------------------------------
>                 Key: MNG-7044
>                 URL: https://issues.apache.org/jira/browse/MNG-7044
>             Project: Maven
>          Issue Type: New Feature
>          Components: core, POM
>            Reporter: Will Iverson
>            Priority: Minor
>              Labels: features
> 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.

This message was sent by Atlassian Jira