Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: XML-0.1
    • Component/s: XML
    • Labels:
      None
    • Number of attachments :
      0

      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

          Hide
          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
          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
          Evgeny Mandrikov added a comment -

          Good point, Christophe.

          Show
          Evgeny Mandrikov added a comment - Good point, Christophe.
          Hide
          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
          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.
          Hide
          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
          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 .
          Hide
          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 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

            People

            • Assignee:
              Matthijs Galesloot
              Reporter:
              Julien HENRY
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: