stubs mappings directory should be the same for convert and run mojo (#95)

This commit is contained in:
Mariusz Smykuła
2016-09-30 07:55:35 +02:00
committed by Marcin Grzejszczak
parent 61ca5a489c
commit 09cf63a600
3 changed files with 9 additions and 6 deletions

View File

@@ -44,6 +44,9 @@ import org.springframework.cloud.contract.verifier.wiremock.RecursiveFilesConver
defaultPhase = LifecyclePhase.PROCESS_TEST_RESOURCES)
public class ConvertMojo extends AbstractMojo {
public static final String DEFAULT_STUBS_DIR = "${project.build.directory}/stubs/";
public static final String MAPPINGS_PATH = "mappings";
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
private RepositorySystemSession repoSession;
@@ -57,8 +60,8 @@ public class ConvertMojo extends AbstractMojo {
* Directory where the generated WireMock stubs from Groovy DSL should be placed.
* You can then mention them in your packaging task to create jar with stubs
*/
@Parameter(defaultValue = "${project.build.directory}/stubs")
private File outputDirectory;
@Parameter(defaultValue = DEFAULT_STUBS_DIR)
private File stubsDirectory;
/**
* Directory containing contracts written using the GroovyDSL
@@ -132,11 +135,11 @@ public class ConvertMojo extends AbstractMojo {
getLog().info("Directory with contract is present at [" + contractsDirectory + "]");
new CopyContracts(this.project, this.mavenSession, this.mavenResourcesFiltering)
.copy(contractsDirectory, this.outputDirectory);
.copy(contractsDirectory, this.stubsDirectory);
config.setContractsDslDir(isInsideProject() ? contractsDirectory : this.source);
config.setStubsOutputDir(
isInsideProject() ? new File(this.outputDirectory, "mappings") : this.destination);
isInsideProject() ? new File(this.stubsDirectory, MAPPINGS_PATH) : this.destination);
getLog().info(
"Converting from Spring Cloud Contract Verifier contracts to WireMock stubs mappings");

View File

@@ -44,7 +44,7 @@ public class RunMojo extends AbstractMojo {
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
private RepositorySystemSession repoSession;
@Parameter(defaultValue = "${project.build.directory}/stubs/mappings")
@Parameter(defaultValue = ConvertMojo.DEFAULT_STUBS_DIR)
private File stubsDirectory;
@Parameter(property = "stubsDirectory", defaultValue = "${basedir}")

View File

@@ -64,7 +64,7 @@ public class PluginUnitTest {
@Test
public void shouldGenerateWireMockStubsInSelectedLocation() throws Exception {
File basedir = this.resources.getBasedir("basic");
this.maven.executeMojo(basedir, "convert", newParameter("outputDirectory", "target/foo"));
this.maven.executeMojo(basedir, "convert", newParameter("stubsDirectory", "target/foo"));
assertFilesPresent(basedir, "target/foo/mappings/Sample.json");
}