Skip to content

Commit

Permalink
Allow to run wiremocks stubs from current directory (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszs committed Apr 15, 2016
1 parent c142850 commit 19b5b12
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/main/groovy/io/codearte/accurest/maven/RunMojo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 19b5b12

Please sign in to comment.