contracts {
targetFramework = ‘JUNIT‘
testMode = ‘MockMvc‘
generatedTestSourcesDir = project.file("${project.buildDir}/generated-test-sources/contracts")
contractsDslDir = "${project.rootDir}/src/test/resources/contracts"
basePackageForTests = ‘org.springframework.cloud.verifier.tests‘
stubsOutputDir = project.file("${project.buildDir}/stubs")
// the following properties are used when you want to provide where the JAR with contract lays
contractDependency {
stringNotation = ‘‘
}
contractsPath = ‘‘
contractsWorkOffline = false
}
tasks.create(type: Jar, name: ‘verifierStubsJar‘, dependsOn: ‘generateClientStubs‘) {
baseName = project.name
classifier = contracts.stubsSuffix
from contractVerifier.stubsOutputDir
}
project.artifacts {
archives task
}
tasks.create(type: Copy, name: ‘copyContracts‘) {
from contracts.contractsDslDir
into contracts.stubsOutputDir
}
verifierStubsJar.dependsOn ‘copyContracts‘
publishing {
publications {
stubs(MavenPublication) {
artifactId project.name
artifact verifierStubsJar
}
}
}
资料和源码来源