Details

      Description

      I would like to enforce consistency of all pom.xml accross projects of my company. I've asked all developers to follow Maven POM Code convention to order elements (http://maven.apache.org/developers/conventions/code.html#POM_Code_Convention).

      It would be great to have a Sonar check that enforce compliance of this rule.

        Issue Links

          Activity

          henryju OLD - Julien HENRY created issue -
          Hide
          simon.brandhof Simon Brandhof added a comment -

          Great, I did not know these conventions.
          Do you know how can we check them ? Are there any lib at Apache ?

          Show
          simon.brandhof Simon Brandhof added a comment - Great, I did not know these conventions. Do you know how can we check them ? Are there any lib at Apache ?
          Hide
          godin OLD - Evgeny Mandrikov added a comment - - edited

          Hi all, I think it would be better to automatically reorder and reformat pom.xml - see http://jira.codehaus.org/browse/MOJO-928

          Show
          godin OLD - Evgeny Mandrikov added a comment - - edited Hi all, I think it would be better to automatically reorder and reformat pom.xml - see http://jira.codehaus.org/browse/MOJO-928
          Hide
          henryju OLD - Julien HENRY added a comment -

          From Sonar point of view, I think it is better to raise a warning/error when convention is not followed. I don't want that Sonar change the pom.xml of the project.

          Having a Maven plugin to perform the change is a good thing but is the responsibility of each project to actually run it. Sonar is the solution in corporate environment to check all projects are following the rule.

          Show
          henryju OLD - Julien HENRY added a comment - From Sonar point of view, I think it is better to raise a warning/error when convention is not followed. I don't want that Sonar change the pom.xml of the project. Having a Maven plugin to perform the change is a good thing but is the responsibility of each project to actually run it. Sonar is the solution in corporate environment to check all projects are following the rule.
          Hide
          godin OLD - Evgeny Mandrikov added a comment -

          So, I think that such functionality should be realized as a plugin.
          Moreover it can be a good start point for plugin, which can validate not only pom.xml (eg. jboss-app.xml, web.xml and so on).
          What do you think, guys?

          Show
          godin OLD - Evgeny Mandrikov added a comment - So, I think that such functionality should be realized as a plugin. Moreover it can be a good start point for plugin, which can validate not only pom.xml (eg. jboss-app.xml, web.xml and so on). What do you think, guys?
          Hide
          cdeneux Christophe DENEUX added a comment -

          Do you thing that it is possible to use the xml-maven-plugin (http://mojo.codehaus.org/xml-maven-plugin) to validate xml files (POM, ...) against coding rules defined through an XSD.

          Show
          cdeneux Christophe DENEUX added a comment - Do you thing that it is possible to use the xml-maven-plugin ( http://mojo.codehaus.org/xml-maven-plugin ) to validate xml files (POM, ...) against coding rules defined through an XSD.
          Hide
          godin OLD - Evgeny Mandrikov added a comment -

          Hi Christophe,

          I never used this plugin, but looks like it can check validity of xml file against an XSD.
          But returning to original issue - validity of xml isn't the same as compliance with POM Code Convention.

          Show
          godin OLD - Evgeny Mandrikov added a comment - Hi Christophe, I never used this plugin, but looks like it can check validity of xml file against an XSD. But returning to original issue - validity of xml isn't the same as compliance with POM Code Convention.
          Hide
          cdeneux Christophe DENEUX added a comment -

          Evgeny,

          POM Code convention is a POM elements ordering, so you can defined it using an XSD. In the default POM XSD (http://maven.apache.org/xsd/maven-4.0.0.xsd), all elements are defined inside a 'xsd:all'. If you replace it by a 'xsd:sequence' and order elements according to POM Code conventions, you check the compliance with POM Code Convention.

          Show
          cdeneux Christophe DENEUX added a comment - Evgeny, POM Code convention is a POM elements ordering, so you can defined it using an XSD. In the default POM XSD ( http://maven.apache.org/xsd/maven-4.0.0.xsd ), all elements are defined inside a 'xsd:all'. If you replace it by a 'xsd:sequence' and order elements according to POM Code conventions, you check the compliance with POM Code Convention.
          Hide
          godin OLD - Evgeny Mandrikov added a comment -

          Good point, Christophe.

          Show
          godin OLD - Evgeny Mandrikov added a comment - Good point, Christophe.
          godin OLD - Evgeny Mandrikov made changes -
          Field Original Value New Value
          Project Sonar [ 11694 ] Sonar Plugins [ 11911 ]
          Key SONAR-1399 SONARPLUGINS-611
          Issue Type Wish [ 5 ] New Feature [ 2 ]
          Affects Version/s 1.12 [ 15685 ]
          Hide
          godin OLD - Evgeny Mandrikov added a comment -

          I've moved this issue to Sonar Plugins project, because we want to decouple Sonar core from Maven in future.

          Show
          godin OLD - Evgeny Mandrikov added a comment - I've moved this issue to Sonar Plugins project, because we want to decouple Sonar core from Maven in future.
          godin OLD - Evgeny Mandrikov made changes -
          Link This issue depends upon SONAR-926 [ SONAR-926 ]
          Hide
          ttres Taciano Tres added a comment -

          In reply to comment #5:
          > Do you thing that it is possible to use the xml-maven-plugin
          > (http://mojo.codehaus.org/xml-maven-plugin) to validate xml files (POM, ...)
          > against coding rules defined through an XSD.
          Just for historical reference, I get it to work with this configuration:

          			<plugin>
          				<groupId>org.codehaus.mojo</groupId>
          				<artifactId>xml-maven-plugin</artifactId>
          				<version>1.0</version>
          				<executions>
          					<execution>
          						<phase>validate</phase>
          						<goals>
          							<goal>validate</goal>
          						</goals>
          					</execution>
          				</executions>
          				<configuration>
          					<validationSets>
          						<validationSet>
          							<dir>${project.basedir}</dir>
          							<systemId>http://my.company.server/maven-4.0.0.xsd</systemId>
          							<includes>
          								<include>pom.xml</include>
          							</includes>
          						</validationSet>
          					</validationSets>
          				</configuration>
          			</plugin>
          

          The maven-4.0.0.xsd was edited to follow the POM Code Convention Rules.

          Show
          ttres Taciano Tres added a comment - In reply to comment #5: > Do you thing that it is possible to use the xml-maven-plugin > ( http://mojo.codehaus.org/xml-maven-plugin ) to validate xml files (POM, ...) > against coding rules defined through an XSD. Just for historical reference, I get it to work with this configuration: <plugin> <groupId> org.codehaus.mojo </groupId> <artifactId> xml-maven-plugin </artifactId> <version> 1.0 </version> <executions> <execution> <phase> validate </phase> <goals> <goal> validate </goal> </goals> </execution> </executions> <configuration> <validationSets> <validationSet> <dir> ${project.basedir} </dir> <systemId> http://my.company.server/maven-4.0.0.xsd </systemId> <includes> <include> pom.xml </include> </includes> </validationSet> </validationSets> </configuration> </plugin> The maven-4.0.0.xsd was edited to follow the POM Code Convention Rules .
          matthijs.galesloot Matthijs Galesloot made changes -
          Assignee Matthijs Galesloot [ matthijs.galesloot ]
          Fix Version/s XML-0.1 [ 17345 ]
          matthijs.galesloot Matthijs Galesloot made changes -
          Component/s XML [ 14607 ]
          Hide
          matthijs.galesloot Matthijs Galesloot added a comment -

          schema validation is provided by a custom maven-4.0.0.xsd with order of the elements as in the maven code conventions.

          whitespace validation will be done in http://jira.codehaus.org/browse/SONARPLUGINS-1145

          Show
          matthijs.galesloot Matthijs Galesloot added a comment - schema validation is provided by a custom maven-4.0.0.xsd with order of the elements as in the maven code conventions. whitespace validation will be done in http://jira.codehaus.org/browse/SONARPLUGINS-1145
          matthijs.galesloot Matthijs Galesloot made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          matthijs.galesloot Matthijs Galesloot made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          hgomez Henri Gomez made changes -
          Project Import Wed May 27 15:34:50 CEST 2015 [ 1432733690440 ]
          henri.gomez Henri Gomez made changes -
          Project Import Wed Jun 03 10:43:16 UTC 2015 [ 1433328196345 ]
          freddy.mallet Freddy Mallet made changes -
          Workflow jira [ 38562 ] Default SonarSource Workflow [ 60393 ]
          freddy.mallet Freddy Mallet made changes -
          Workflow Default SonarSource Workflow [ 60393 ] Default Agile SonarSource Workflow [ 80257 ]

            People

            • Assignee:
              matthijs.galesloot Matthijs Galesloot
              Reporter:
              henryju OLD - Julien HENRY
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: