Fixed wrong classifier setting

without this change the classifier is picked from the `classifier` field in the extension and not from the parsed string notation

fixes #327
This commit is contained in:
Marcin Grzejszczak
2017-06-14 12:35:16 +02:00
parent 186886029b
commit 88c959beea
3 changed files with 28 additions and 2 deletions

View File

@@ -151,6 +151,7 @@ class ContractVerifierExtension {
closure.call()
}
@ToString
static class Dependency {
String groupId
String artifactId

View File

@@ -35,7 +35,9 @@ class GradleContractsDownloader {
// download contracts, unzip them and pass as output directory
if (shouldDownloadContracts(extension)) {
this.log.info("For project [${this.project.name}] Download dependency is provided - will download contract jars")
this.log.info("Contract dependency [{}]", extension.contractDependency)
StubConfiguration configuration = stubConfiguration(extension.contractDependency)
this.log.info("Got the following contract dependency to download [{}]", configuration)
File cachedFolder = downloadedContract.get(configuration)
if (cachedFolder) {
this.log.info("For project [${this.project.name}] Returning the cached location of the contracts")
@@ -69,7 +71,7 @@ class GradleContractsDownloader {
.build())
}
private StubConfiguration stubConfiguration(ContractVerifierExtension.Dependency contractDependency) {
@PackageScope StubConfiguration stubConfiguration(ContractVerifierExtension.Dependency contractDependency) {
String groupId = contractDependency.groupId
String artifactId = contractDependency.artifactId
String version = StringUtils.hasText(contractDependency.version) ?
@@ -79,7 +81,7 @@ class GradleContractsDownloader {
if (StringUtils.hasText(stringNotation)) {
StubConfiguration stubConfiguration = new StubConfiguration(stringNotation)
return new StubConfiguration(stubConfiguration.groupId, stubConfiguration.artifactId,
stubConfiguration.version, contractDependency.classifier)
stubConfiguration.version, stubConfiguration.classifier)
}
return new StubConfiguration(groupId, artifactId, version, classifier)
}

View File

@@ -0,0 +1,23 @@
package org.springframework.cloud.contract.verifier.plugin
import org.springframework.cloud.contract.stubrunner.StubConfiguration
import spock.lang.Specification
/**
* @author Marcin Grzejszczak
*/
class GradleContractsDownloaderSpec extends Specification {
def "should parse dependency via string notation"() {
given:
String stringNotation = "com.example:foo:1.0.0:stubs"
def dep = new ContractVerifierExtension.Dependency(stringNotation: stringNotation)
when:
StubConfiguration stubConfig = new GradleContractsDownloader(null, null).stubConfiguration(dep)
then:
stubConfig.groupId == "com.example"
stubConfig.artifactId == "foo"
stubConfig.version == "1.0.0"
stubConfig.classifier == "stubs"
}
}