August 06, 2009

Maven XML Plugin - Validation

« Servlet Example | Main | Start Maven in Debug Mode »

Sometimes you need XML validation in your build process. Often configuration files will be read on load time. Not till then validation failures occurs. The Maven XML Plugin validates XML files in your project at build time.

You have only add the following build plugin in pom.xml file:

<build>
    <plugins>
      ...
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>validate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <validationSets>
            <validationSet>
              <dir>xml</dir>
            </validationSet>
            <validationSet>
              <dir>xsd</dir>
              <systemId>xmlschema.xml</systemId>
            </validationSet>
          </validationSets>
        </configuration>
      </plugin>
      ...
    </plugins>
  </build>
Regards
Rafael Sobek

Technorati Tags:

Posted by rafael.sobek at 12:14 AM in Maven

 

[Trackback URL for this entry]

Your comment:

(not displayed)
 
 
 

Live Comment Preview: