From d4135bb802184208684915b3ba165d3f7d9c21f4 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 29 Apr 2016 15:46:35 +0200 Subject: [PATCH] Fixed missing offline mode for aether --- docs/src/docs/asciidoc/stubrunner.adoc | 2 +- .../accurest/stubrunner/AetherStubDownloader.groovy | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/src/docs/asciidoc/stubrunner.adoc b/docs/src/docs/asciidoc/stubrunner.adoc index 78d0b68fd6..e42aeb54c4 100644 --- a/docs/src/docs/asciidoc/stubrunner.adoc +++ b/docs/src/docs/asciidoc/stubrunner.adoc @@ -56,7 +56,7 @@ Some of the properties that are repetitive can be set using system properties or | Property name | Default value | Description |stubrunner.port.range.min|10000| Minimal value of a port for a started WireMock with stubs |stubrunner.port.range.max|15000| Minimal value of a port for a started WireMock with stubs -|stubrunner.stubs.repository.root|| Maven repo url. If blank then will call the local maven repo +|stubrunner.stubs.repository.root|| Comma separated list of Maven repo urls. If blank then will call the local maven repo |stubrunner.stubs.classifier|stubs| Default classifier for the stub artifacts |stubrunner.work-offline|false| If true then will not contact any remote repositories to download stubs |stubrunner.stubs.ids|| Comma separated list of Ivy notation of stubs to download diff --git a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/AetherStubDownloader.groovy b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/AetherStubDownloader.groovy index 03c2880ca2..15e36801be 100644 --- a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/AetherStubDownloader.groovy +++ b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/AetherStubDownloader.groovy @@ -54,7 +54,12 @@ class AetherStubDownloader implements StubDownloader { } private List remoteRepositories(StubRunnerOptions stubRunnerOptions) { - return [new RemoteRepository.Builder("remote", "default", stubRunnerOptions.stubRepositoryRoot).build()] + if (stubRunnerOptions.workOffline || !stubRunnerOptions.stubRepositoryRoot) { + return [] + } + return stubRunnerOptions.stubRepositoryRoot.split(',').collect { String repo -> + new RemoteRepository.Builder("remote", "default", repo).build() + } } private RepositorySystem newRepositorySystem() { @@ -82,7 +87,7 @@ class AetherStubDownloader implements StubDownloader { } Artifact artifact = new DefaultArtifact(stubsGroup, stubsModule, classifier, ARTIFACT_EXTENSION, highestVersion.toString()) ArtifactRequest request = new ArtifactRequest(artifact: artifact, repositories: remoteRepos) - log.info("Resolving artifact $artifact from $remoteRepos") + log.info("Resolving artifact $artifact from ${remoteRepos?:'local maven repo'}") ArtifactResult result = repositorySystem.resolveArtifact(session, request) log.info("Resolved artifact $artifact to ${result.artifact.file} from ${result.repository}") return unpackStubJarToATemporaryFolder(result.artifact.file.toURI())