package org.daisy.maven.xproc.plugin;

import java.io.File;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;

import org.daisy.maven.xproc.xprocspec.XProcSpecRunner;
import org.daisy.maven.xproc.xprocspec.XProcSpecRunner.Reporter;

/**
 * Run an XProcSpec test.
 *
 * @goal xprocspec
 */
public class XProcSpecMojo extends AbstractMojo {
	
	/**
	 * Directory containing the XProcSpec tests.
	 *
	 * @parameter expression="${project.basedir}/src/test/xprocspec"
	 * @required
	 */
	private File xprocspecDirectory;
	
	/**
	 * Directory that will contain the generated reports.
	 *
	 * @parameter expression="${project.build.directory}/xprocspec-reports"
	 * @required
	 */
	private File reportsDirectory;
	
	/**
	 * Directory that will contain the generated Surefire reports.
	 *
	 * @parameter expression="${project.build.directory}/surefire-reports"
	 * @required
	 */
	private File surefireReportsDirectory;
	
	/**
	 * Temporary directory for storing XProcSpec related files.
	 *
	 * @parameter default-value="${project.build.directory}/xprocspec"
	 * @required
	 * @readonly
	 */
	private File tempDir;
	
	public void execute() throws MojoFailureException {
		
		XProcSpecRunner runner = new XProcSpecRunner();
		Reporter.DefaultReporter reporter = new Reporter.DefaultReporter(System.out);
		
		if (!runner.run(xprocspecDirectory,
		                reportsDirectory,
		                surefireReportsDirectory,
		                tempDir,
		                reporter))
			throw new MojoFailureException("There are test failures.");
		
	}
}

@@ -956,24 +956,675 @@
 ory;%0A%09%0A%09/**%0A
+%09 * Set this to %22true%22 to skip running tests, but still compile them. Its use%0A%09 * is NOT RECOMMENDED, but quite convenient on occasion.%0A%09 *%0A%09 * @parameter property=%22skipTests%22 default-value=%22false%22%0A%09 */%0A%09private boolean skipTests;%0A%0A%09/**%0A%09 * Set this to %22true%22 to bypass unit tests entirely. Its use is NOT%0A%09 * RECOMMENDED, especially if you enable it using the %22maven.test.skip%22%0A%09 * property, because maven.test.skip disables both running the tests and%0A%09 * compiling the tests. Consider using the %3Ccode%3EskipTests%3C/code%3E parameter%0A%09 * instead.%0A%09 *%0A%09 * @parameter expression=%22$%7Bmaven.test.skip%7D%22 default-value=%22false%22%0A%09 */%0A%09private boolean skip;%0A%09%0A%09/**%0A
 %09 * Temporar
@@ -1858,16 +1858,99 @@
 on %7B%0A%09%09%0A
+%09%09if (skip %7C%7C skipTests) %7B%0A%09%09%09getLog().info(%22Tests are skipped.%22);%0A%09%09%09return; %7D%0A%09%09%0A
 %09%09XProcS

Support for skipTests and maven.test.skip