add shutdown for wiremock server (#21)
This commit is contained in:
@@ -3,6 +3,8 @@ package io.codearte.accurest.maven
|
||||
import groovy.transform.CompileStatic
|
||||
import io.codearte.accurest.maven.stubrunner.LocalStubRunner
|
||||
import io.codearte.accurest.maven.stubrunner.RemoteStubRunner
|
||||
import io.codearte.accurest.stubrunner.BatchStubRunner
|
||||
import io.codearte.accurest.stubrunner.StubRunner
|
||||
import io.codearte.accurest.stubrunner.StubRunnerOptions
|
||||
import org.apache.maven.execution.MavenSession
|
||||
import org.apache.maven.plugin.AbstractMojo
|
||||
@@ -63,17 +65,21 @@ class RunMojo extends AbstractMojo {
|
||||
log.info("Skipping accurest execution: accurest.skip=${skip}")
|
||||
return
|
||||
}
|
||||
|
||||
BatchStubRunner batchStubRunner
|
||||
if (!stubs) {
|
||||
StubRunnerOptions options = new StubRunnerOptions(httpPort, httpPort + 1, "", false, stubsClassifier)
|
||||
localStubRunner.run(resolveStubsDirectory().absolutePath, options)
|
||||
StubRunner stubRunner = localStubRunner.run(resolveStubsDirectory().absolutePath, options)
|
||||
batchStubRunner = new BatchStubRunner(Arrays.asList(stubRunner))
|
||||
} else {
|
||||
StubRunnerOptions options = new StubRunnerOptions(minPort, maxPort, "", false, stubsClassifier)
|
||||
remoteStubRunner.run(stubs, options, repoSession)
|
||||
batchStubRunner = remoteStubRunner.run(stubs, options, repoSession)
|
||||
}
|
||||
|
||||
if (!insideProject) {
|
||||
pressAnyKeyToContinue()
|
||||
if (batchStubRunner) {
|
||||
batchStubRunner.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@ import javax.inject.Named
|
||||
@Slf4j
|
||||
class LocalStubRunner {
|
||||
|
||||
void run(String contractsDir, StubRunnerOptions options) {
|
||||
StubRunner run(String contractsDir, StubRunnerOptions options) {
|
||||
log.info("Launching StubRunner with contracts from ${contractsDir}")
|
||||
new StubRunner(options, contractsDir, new StubConfiguration(contractsDir)).runStubs()
|
||||
StubRunner stubRunner = new StubRunner(options, contractsDir, new StubConfiguration(contractsDir))
|
||||
stubRunner.runStubs()
|
||||
return stubRunner
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class RemoteStubRunner {
|
||||
this.aetherStubDownloaderFactory = aetherStubDownloaderFactory
|
||||
}
|
||||
|
||||
void run(String stubs, StubRunnerOptions options, RepositorySystemSession repositorySystemSession) {
|
||||
BatchStubRunner run(String stubs, StubRunnerOptions options, RepositorySystemSession repositorySystemSession) {
|
||||
AetherStubDownloader stubDownloader = aetherStubDownloaderFactory.build(repositorySystemSession)
|
||||
try {
|
||||
log.debug("Launching StubRunner with args: $options")
|
||||
@@ -30,6 +30,7 @@ class RemoteStubRunner {
|
||||
.buildBatchStubRunner()
|
||||
RunningStubs runningCollaborators = stubRunner.runStubs()
|
||||
log.info(runningCollaborators.toString())
|
||||
return stubRunner
|
||||
} catch (Exception e) {
|
||||
log.error("An exception occurred while trying to execute the stubs: ${e.message}")
|
||||
throw e
|
||||
|
||||
Reference in New Issue
Block a user