Maven
  1. Maven
  2. MNG-3397

[RFC] change the POM to use attributes

    Details

    • Flags:
      Patch

      Issue Links

        Activity

        Show
        Brett Porter added a comment - see build: http://people.apache.org/~brett/apache-maven-2.0.9-SNAPSHOT-terse-bin.tar.gz and branch: http://svn.apache.org/repos/asf/maven/components/branches/maven-2.0.x-terse
        Show
        Brett Porter added a comment - files for comparison: http://svn.apache.org/viewvc/maven/archiva/trunk/pom.xml?content-type=text%2Fplain&view=co http://svn.apache.org/viewvc/maven/archiva/trunk/pom-4.1.0.xml?content-type=text%2Fplain&view=co
        Hide
        nicolas de loof added a comment -

        I tried to enable the "flat" modello format for collections, to change :

        <plugin>
        <executions>
        <execution>
        <id>xx</id>
        <phase>xx</phase>
        <goals>
        <goal>xx</goal>
        </goals>
        </execution>
        </executions>
        </plugin>

        .. to the more convice :

        <plugin>
        <execution id="xx" phase="xx">
        <goal>xx</goal>
        </executions>
        </plugin>

        but this didn't worked : the modello generated parser still search the "executions" in XML stream. Not investigated more yet on this.

        Show
        nicolas de loof added a comment - I tried to enable the "flat" modello format for collections, to change : <plugin> <executions> <execution> <id>xx</id> <phase>xx</phase> <goals> <goal>xx</goal> </goals> </execution> </executions> </plugin> .. to the more convice : <plugin> <execution id="xx" phase="xx"> <goal>xx</goal> </executions> </plugin> but this didn't worked : the modello generated parser still search the "executions" in XML stream. Not investigated more yet on this.
        Hide
        Brett Porter added a comment -

        what change did you make to the model to enable this?

        Show
        Brett Porter added a comment - what change did you make to the model to enable this?
        Hide
        Darren Bell added a comment -

        When will this be rolled into a release?

        Show
        Darren Bell added a comment - When will this be rolled into a release?
        Hide
        Darren Bell added a comment -

        Yay, thanks Brett. So, when's 2.1 out?

        Show
        Darren Bell added a comment - Yay, thanks Brett. So, when's 2.1 out?
        Hide
        Young Gu added a comment -

        This feature will make pom.xml more concise.

        Show
        Young Gu added a comment - This feature will make pom.xml more concise.
        Hide
        Tim Chen added a comment -

        Any chance this will be ported to the 2.0.x or 2.1.x lines?

        Show
        Tim Chen added a comment - Any chance this will be ported to the 2.0.x or 2.1.x lines?
        Hide
        Darren Bell added a comment -

        Is this still being worked on? Maybe now for the 3.0 release?

        Show
        Darren Bell added a comment - Is this still being worked on? Maybe now for the 3.0 release?
        Hide
        Alex Collins added a comment -

        Any update on this?

        Show
        Alex Collins added a comment - Any update on this?
        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 S. 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 S. 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>
        Hide
        Will Iverson added a comment -

        Question: would this be a breaking, hard change for POMs, or a soft change, (e.g. any of the following specified as an attribute will serve as the declaration unless overridden by a child element, groupId, artifactId, version, classifier, type, scope).

        If going down the hard-change route, it would be really, really easy for IDEs (and/or Maven itself ) to support a 1-click update for existing POMs, and would avoid confusing situations with conflicting declarations in attributes and child elements. The bad news is that you'd have to wait for the IDEs and what not to support Maven 4... but hey, it's another reason to upgrade!

        The colon delimited version is popular (you can see it in use with other build tools at, for example: http://mvnrepository.com/artifact/org.mockito/mockito-all/1.10.8 ) but not standard.

        Show
        Will Iverson added a comment - Question: would this be a breaking, hard change for POMs, or a soft change, (e.g. any of the following specified as an attribute will serve as the declaration unless overridden by a child element, groupId, artifactId, version, classifier, type, scope). If going down the hard-change route, it would be really, really easy for IDEs (and/or Maven itself ) to support a 1-click update for existing POMs, and would avoid confusing situations with conflicting declarations in attributes and child elements. The bad news is that you'd have to wait for the IDEs and what not to support Maven 4... but hey, it's another reason to upgrade! The colon delimited version is popular (you can see it in use with other build tools at, for example: http://mvnrepository.com/artifact/org.mockito/mockito-all/1.10.8 ) but not standard.

          People

          • Assignee:
            Unassigned
            Reporter:
            Brett Porter
          • Votes:
            47 Vote for this issue
            Watchers:
            41 Start watching this issue

            Dates

            • Created:
              Updated:

              Development