Changing the default layout of stubs
without this change the stubs are just placed under the contracts|mappings folders. If you have many of these JARs on the classpath then you might have a problem to say which stubs belong to which server.
with this change we're changing the default location to META-INF/groupid/artifactid/version/contract|mappings . That way you can easily discern stubs
fixes #54
This commit is contained in:
@@ -23,10 +23,11 @@ class ContractsCopyTask extends ConventionTask {
|
||||
ContractVerifierConfigProperties props = ExtensionToProperties.fromExtension(getExtension())
|
||||
File file = getDownloader().downloadAndUnpackContractsIfRequired(getExtension(), props)
|
||||
String antPattern = "${props.includedRootFolderAntPattern}*.*"
|
||||
String root = OutputFolderBuilder.buildRootPath(project)
|
||||
ext.contractVerifierConfigProperties = props
|
||||
File outputContractsFolder = getExtension().stubsOutputDir != null ?
|
||||
project.file("${getExtension().stubsOutputDir}/contracts") :
|
||||
project.file("${project.buildDir}/stubs/contracts")
|
||||
project.file("${getExtension().stubsOutputDir}/${root}/contracts") :
|
||||
project.file("${project.buildDir}/stubs/${root}/contracts")
|
||||
ext.contractsDslDir = outputContractsFolder
|
||||
project.logger.info("Downloading and unpacking files from [$file] to [$outputContractsFolder]. The inclusion ant pattern is [$antPattern]")
|
||||
project.copy {
|
||||
|
||||
@@ -48,8 +48,10 @@ class GenerateWireMockClientStubsFromDslTask extends ConventionTask {
|
||||
logger.info("Spring Cloud Contract Verifier Plugin: Invoking DSL to client stubs conversion")
|
||||
props.contractsDslDir = contractsDslDir
|
||||
props.includedContracts = ".*"
|
||||
File outMappingsDir = getStubsOutputDir() != null ? new File(getStubsOutputDir(), DEFAULT_MAPPINGS_FOLDER)
|
||||
: new File(project.buildDir, "stubs/$DEFAULT_MAPPINGS_FOLDER")
|
||||
String root = OutputFolderBuilder.buildRootPath(project)
|
||||
File outMappingsDir = getStubsOutputDir() != null ?
|
||||
new File(getStubsOutputDir(), "${root}/${DEFAULT_MAPPINGS_FOLDER}")
|
||||
: new File(project.buildDir, "stubs/${root}/${DEFAULT_MAPPINGS_FOLDER}")
|
||||
logger.info("Contracts dir is [${contractsDslDir}] output stubs dir is [${outMappingsDir}]")
|
||||
RecursiveFilesConverter converter = new RecursiveFilesConverter(
|
||||
props, outMappingsDir)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
import groovy.transform.CompileStatic
|
||||
import groovy.transform.PackageScope
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
@CompileStatic
|
||||
@PackageScope
|
||||
class OutputFolderBuilder {
|
||||
|
||||
static String buildRootPath(Project project) {
|
||||
String groupId = project.group as String
|
||||
String artifactId = project.name
|
||||
String version = project.version
|
||||
return "META-INF/${groupId}/${artifactId}/${version}"
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ dependencies {
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "ch.qos.logback:logback-classic:1.1.2"
|
||||
testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}"
|
||||
}
|
||||
|
||||
contracts {
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
#
|
||||
wiremockVersion=2.5.1
|
||||
jsonAssertVersion=0.4.8
|
||||
|
||||
verifierVersion=1.1.0.BUILD-SNAPSHOT
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ subprojects {
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,5 +15,4 @@
|
||||
#
|
||||
wiremockVersion=2.5.1
|
||||
jsonAssertVersion=0.4.8
|
||||
|
||||
|
||||
verifierVersion=1.1.0.BUILD-SNAPSHOT
|
||||
|
||||
@@ -47,6 +47,7 @@ subprojects {
|
||||
testCompile("junit:junit:4.12")
|
||||
testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,5 +15,4 @@
|
||||
#
|
||||
wiremockVersion=2.5.1
|
||||
jsonAssertVersion=0.4.8
|
||||
|
||||
|
||||
verifierVersion=1.1.0.BUILD-SNAPSHOT
|
||||
@@ -49,6 +49,7 @@ subprojects {
|
||||
testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
testCompile "org.assertj:assertj-core:2.4.1"
|
||||
testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ configure(project(':loanApplicationService')) {
|
||||
task copyCollaboratorStubs(type: Copy) {
|
||||
File fraudBuildDir = project(':fraudDetectionService').buildDir
|
||||
from(new File(fraudBuildDir, "/production/${project(':fraudDetectionService').name}-stubs/"))
|
||||
into "src/test/resources/"
|
||||
into "src/test/resources/mappings"
|
||||
}
|
||||
|
||||
generateContractTests.dependsOn('copyCollaboratorStubs')
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
#
|
||||
wiremockVersion=2.5.1
|
||||
jsonAssertVersion=0.4.8
|
||||
|
||||
verifierVersion=1.1.0.BUILD-SNAPSHOT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user