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

Will Iverson commented on MNG-7044:
-----------------------------------

Looks like the change would be to this file:
https://github.com/codehaus-plexus/modello/blob/08152b14bb44867c038e52fc957c46ec1906668e/modello-plugins/modello-plugin-xpp3/src/main/java/org/codehaus/modello/plugin/xpp3/Xpp3ReaderGenerator.java

It's a ~1600 line code generator. Looks like it doesn't actually have any tests 
for validating that a given pom.xml can be parsed/validated, just that the 
files generated by a *.mdo file can successfully compile. The maven-model 
project at https://github.com/apache/maven/blob/master/maven-model/pom.xml has 
a dependency on modello-maven-plugin, which in turn uses the above.

Trying to time box to ~1hr at time. :) Next step is to try to generate a 
working test environment linking the above with SNAPSHOTs.

My sense that this will all boil down to just a few lines to tweak the 
Xpp3ReaderGenerator.java is still there. The error message for an invalid 
pom.xml such as:

 Malformed POM /Users/wiverson/src/tiny-pom/pom.xml: Unknown attribute 'scope' 
for tag 'dependency' (position: START_TAG seen ...y groupId="junit" 
artifactId="junit" version="4.11" scope="test"/>... @22:81)  @ 
/Users/wiverson/src/tiny-pom/pom.xml, line 22, column 81

...is clearly coming from the Modello generated code, not the XSD. A simple 
version of the tweak to the code generator would just check to see if the 
attribute is a known field and allow it to be set if known, while throwing an 
error (like today) if not. A fancier version would emit an warning for a 
duplicate attribute/element declaration (just like a duplicate element 
declaration today.

> 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
(v8.3.4#803005)

Reply via email to