uk.co.automatictester.wiremock.maven.plugin.mojo.ConfigurationMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wiremock-maven-plugin Show documentation
Show all versions of wiremock-maven-plugin Show documentation
Run WireMock as part of Maven lifecycle
package uk.co.automatictester.wiremock.maven.plugin.mojo;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Parameter;
import uk.co.automatictester.wiremock.maven.plugin.util.ParameterUtil;
import java.io.File;
import java.util.List;
abstract class ConfigurationMojo extends AbstractMojo {
@Parameter(defaultValue = "${plugin}", required = true, readonly = true)
PluginDescriptor descriptor;
@Parameter(property = "project.testClasspathElements", required = true, readonly = true)
List classpathElements;
/**
* Set the root directory (--root-dir), under which mappings and __files reside.
* This defaults to: target/classes
*/
@Parameter(property = "dir", defaultValue = "target/classes")
private File dir;
/**
* Set all other parameters in command-line format, e.g.:
* --port=8081 --verbose
* Do NOT specify --root-dir here.
*/
@Parameter(property = "params")
private String params;
/**
* Set to true if (and only if) you want to keep the plugin running indefinitely.
*/
@Parameter(property = "keepRunning", defaultValue = "false")
private String keepRunning;
boolean shouldKeepRunning() {
return keepRunning.equals("true");
}
String[] getAllParams() {
String directory = dir.toString();
if (params == null) {
return ParameterUtil.getDirParam(directory);
} else {
return ParameterUtil.getAllParams(directory, params);
}
}
}