stubs mappings directory should be the same for convert and run mojo (#95)
This commit is contained in:
committed by
Marcin Grzejszczak
parent
61ca5a489c
commit
09cf63a600
@@ -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");
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user