From 19b5b120fbcdfba8f5709b9c63c398a700ce3dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mariusz=20Smyku=C5=82a?= Date: Fri, 15 Apr 2016 20:41:02 +0200 Subject: [PATCH] Allow to run wiremocks stubs from current directory (#4) --- README.md | 2 +- .../io/codearte/accurest/maven/RunMojo.groovy | 3 +-- .../maven/stubrunner/LocalStubRunner.groovy | 13 ++----------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index adeaaed..e2a40fc 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For more information please go to the [Accurest Wiki](https://github.com/Codeart Accurest Stub Runner --- -Run contracts from current directory: +Run stubs mappings from current directory: mvn io.codearte.accurest:accurest-maven-plugin:run diff --git a/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy b/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy index 5f72edb..82c1b49 100644 --- a/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy +++ b/src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy @@ -32,7 +32,6 @@ public class RunMojo extends AbstractMojo { @Parameter(property = 'maxPort', defaultValue = '15000') private int maxPort - private String stubsClassifier = 'stubs' private final LocalStubRunner localStubRunner @@ -48,7 +47,7 @@ public class RunMojo extends AbstractMojo { StubRunnerOptions options = new StubRunnerOptions(minPort, maxPort, "", false, stubsClassifier) log.debug("Launching StubRunner with args: $options") if (!stubs) { - localStubRunner.run(contractsDir, options) + localStubRunner.run(contractsDir.getAbsolutePath(), options) } else { remoteStubRunner.run(stubs, options, repoSession) } diff --git a/src/main/groovy/io/codearte/accurest/maven/stubrunner/LocalStubRunner.groovy b/src/main/groovy/io/codearte/accurest/maven/stubrunner/LocalStubRunner.groovy index 441a150..5239b41 100644 --- a/src/main/groovy/io/codearte/accurest/maven/stubrunner/LocalStubRunner.groovy +++ b/src/main/groovy/io/codearte/accurest/maven/stubrunner/LocalStubRunner.groovy @@ -2,28 +2,19 @@ package io.codearte.accurest.maven.stubrunner import groovy.transform.CompileStatic import groovy.util.logging.Slf4j -import io.codearte.accurest.config.AccurestConfigProperties -import io.codearte.accurest.maven.AccurestConverter import io.codearte.accurest.stubrunner.StubConfiguration import io.codearte.accurest.stubrunner.StubRunner import io.codearte.accurest.stubrunner.StubRunnerOptions import javax.inject.Named -import java.nio.file.Files - -import static io.codearte.accurest.maven.AccurestConverter.convertAccurestToStubs @Named @CompileStatic @Slf4j class LocalStubRunner { - void run(File contractsDir, StubRunnerOptions options) { + void run(String contractsDir, StubRunnerOptions options) { log.info("Launching StubRunner with contracts from ${contractsDir}") - File mappingsOutput = Files.createTempDirectory('accurest').toFile() - mappingsOutput.deleteOnExit() - AccurestConfigProperties config = new AccurestConfigProperties(contractsDslDir: contractsDir, stubsOutputDir: mappingsOutput) - convertAccurestToStubs(config) - new StubRunner(options, contractsDir.getPath(), new StubConfiguration(mappingsOutput.toString())).runStubs() + new StubRunner(options, contractsDir, new StubConfiguration(contractsDir)).runStubs() } }