JSF & Java Blog

Discussion on Java and JSF, including Spring, Maven, Eclipse and Jenkins

Using Maven to check facelets are valid

0

Although Eclipse validates our xml documents, sometimes invalid xml documents can get committed into our source repository by accident.

Using the maven xml-maven-plugin we can force the build to break when xml documents aren’t welformed.

Currently we are only doing the check on facelets (files with a .xhtml extension): The xml snippet below shows the configuration of the plugin for xhtml files.

Add this to the plugins element in the build section.

<plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>xml-maven-plugin</artifactId>
	<executions>
		<execution>
			<goals>
				<goal>validate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<validationSets>
			<validationSet>
				<dir>src/main/webapp</dir>
				<includes>
					<include>**/*.xhtml</include>
				</includes>
			</validationSet>
		</validationSets>
	</configuration>
</plugin>

To Do:

Really we should be validating all xml files. Also we should investigate turning on schema validation, especially for facelets files.

So, what do you think ?

  • *