Maven
  1. Maven
  2. MNG-3397

[RFC] change the POM to use attributes

    Details

    • Patch Submitted:
      Yes
    • Number of attachments :
      0

      Issue Links

        Activity

        Hide
        Jifeng Zhang added a comment - - edited

        It would be great to have this feature. At least 50% of the lines of my poms is the dependencies section. With the support of using attributes, the dependency section will be reduced at least 70% in lines and more easy to read.

        For example, from 4 lines:

         
        <dependency>
        	<groupId>org.apache.maven.plugins</groupId>
        	<artifactId>maven-surefire-plugin</artifactId>
        	<version>2.16</version>
        </dependency>
        

        to just one line:

         
        <dependency groupId="org.apache.maven.plugins" artifactId="maven-surefire-plugin" version="2.16"/>
        
        Show
        Jifeng Zhang added a comment - - edited It would be great to have this feature. At least 50% of the lines of my poms is the dependencies section. With the support of using attributes, the dependency section will be reduced at least 70% in lines and more easy to read. For example, from 4 lines: <dependency> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-surefire-plugin </artifactId> <version> 2.16 </version> </dependency> to just one line: <dependency groupId= "org.apache.maven.plugins" artifactId= "maven-surefire-plugin" version= "2.16" />
        Hide
        Darren Bell added a comment -

        Or maybe even this:

        <dependency id="org.apache.maven.plugins:org.apache.maven.plugins:2.16" />
        

        or

        <dependency id=":org.apache.maven.plugins:" />
        

        in a management section.

        Show
        Darren Bell added a comment - Or maybe even this: <dependency id="org.apache.maven.plugins:org.apache.maven.plugins:2.16" /> or <dependency id=":org.apache.maven.plugins:" /> in a management section.
        Hide
        Darren Bell added a comment -

        A pity this has been pushed back to 4.x. When is that due for release I wonder.

        Show
        Darren Bell added a comment - A pity this has been pushed back to 4.x. When is that due for release I wonder.
        Hide
        Karl-Heinz Marbaise added a comment -

        So an exclusions could look like this:

        <dependency groupId="junit" artifactId="junit" scope="test" version="4.11">
          <exclusions>
            <exclusion groupId="org.hamcrest" artifactId="hamcrest-core"/>
          </exclusions>
        </dependency>
        

        Or going with the idea of Id's it would look like this:

        <dependency id="org.junit:junit:test:4.11">
          <exclusions>
            <exclusion id="org.hamcrest:hamcest-core"/>
          </exclusions>
        </dependency>
        

        Furthermore some more convenience:

        <dependency id="org.junit:junit:test" exclusions="*"/>
        

        Which brings me to a more formal definition:

        <dependency id="{groupId}:{artifactId}:{version}:{classifier}:{type}:{scope}"/>
        
        Show
        Karl-Heinz Marbaise added a comment - So an exclusions could look like this: <dependency groupId= "junit" artifactId= "junit" scope= "test" version= "4.11" > <exclusions> <exclusion groupId= "org.hamcrest" artifactId= "hamcrest-core" /> </exclusions> </dependency> Or going with the idea of Id's it would look like this: <dependency id= "org.junit:junit:test:4.11" > <exclusions> <exclusion id= "org.hamcrest:hamcest-core" /> </exclusions> </dependency> Furthermore some more convenience: <dependency id= "org.junit:junit:test" exclusions= "*" /> Which brings me to a more formal definition: <dependency id= "{groupId}:{artifactId}:{version}:{classifier}:{type}:{scope}" />
        Hide
        Sergei Ivanov added a comment -

        I support the idea of a compact colon-separated dependency id, however:

        • scope does not really belong to artifact coordinates, it is an additional property of an artifact dependency. As such, IMHO it deserves a separate XML attribute.
        • some plugins are already using colon-separated coordinate notation, but the ordering of the coordinate parts is not consistent. See for example, off the top of my head:
          http://maven.apache.org/plugins/maven-remote-resources-plugin/process-mojo.html#resourceBundles
          versus includes/excludes in
          http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_dependencySet
          I am pretty sure I saw it being used elsewhere, but cannot remember just now. This really needs to be standardised.
        • it could be just me, but I think colon does not really stand out visually as a separator in a stream of characters, maybe we should allow for optional spaces around colons for better readability
        • if possible, we should also try to do away with container elements (e.g. exclusions) or make them optional in all non-ambiguous contexts.

        Example:

        <dependency id="org.junit : junit : 4.11" scope="test">
            <exclusion id="org.hamcrest : hamcest-core"/>
        </dependency>
        

        or

        <dependency id="org.apache.maven : maven-core : 3.2.2" scope="compile">
            <exclusion id="org.codehaus.plexus : plexus-utils"/>
            <exclusion id="org.codehaus.plexus : plexus-interpolation"/>
        </dependency>
        
        Show
        Sergei Ivanov added a comment - I support the idea of a compact colon-separated dependency id, however: scope does not really belong to artifact coordinates, it is an additional property of an artifact dependency. As such, IMHO it deserves a separate XML attribute. some plugins are already using colon-separated coordinate notation, but the ordering of the coordinate parts is not consistent. See for example, off the top of my head: http://maven.apache.org/plugins/maven-remote-resources-plugin/process-mojo.html#resourceBundles versus includes/excludes in http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_dependencySet I am pretty sure I saw it being used elsewhere, but cannot remember just now. This really needs to be standardised. it could be just me, but I think colon does not really stand out visually as a separator in a stream of characters, maybe we should allow for optional spaces around colons for better readability if possible, we should also try to do away with container elements (e.g. exclusions ) or make them optional in all non-ambiguous contexts. Example: <dependency id= "org.junit : junit : 4.11" scope= "test" > <exclusion id= "org.hamcrest : hamcest-core" /> </dependency> or <dependency id= "org.apache.maven : maven-core : 3.2.2" scope= "compile" > <exclusion id= "org.codehaus.plexus : plexus-utils" /> <exclusion id= "org.codehaus.plexus : plexus-interpolation" /> </dependency>

          People

          • Assignee:
            Unassigned
            Reporter:
            Brett Porter
          • Votes:
            59 Vote for this issue
            Watchers:
            53 Start watching this issue

            Dates

            • Created:
              Updated: