spring-cloud-contract
spring-cloud-contract copied to clipboard
Multi external contract jar files implemented by one producer ?
Is it possible to have separate contract jar files for different consumers but one producer to implement both ?
I was testing a producer with external contracts and contractsMode="CLASSPATH"
build.gradle (CLASSPATH mode)
buildscript {
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
classpath "com.example:donna-cloud-contract:0.4.0-SNAPSHOT:stubs"
}
}
apply plugin: "groovy"
apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"
apply plugin: "spring-cloud-contract"
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.cloud:spring-cloud-starter-contract-verifier")
testCompile("com.example:donna-cloud-contract:0.4.0-SNAPSHOT:stubs") {
transitive = false
}
}
group = "com.example"
contracts {
contractsMode = "CLASSPATH"
contractsPath = "META-INF/com.example/donna-cloud-contract"
// Base package for generated tests
basePackageForTests = "com.example"
baseClassMappings {
baseClassMapping(".*rest.*", "com.example.BeerRestBase")
}
}
but when building the producer no contract files are copied and no test classes are generated. However the same producer in contractsMode='REMOTE' is building fine.
build.gradle (REMOTE mode)
buildscript {
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE"
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
}
}
apply plugin: 'groovy'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'spring-cloud-contract'
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
}
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.cloud:spring-cloud-starter-contract-verifier")
}
group = 'com.example'
contracts {
contractDependency {
stringNotation = 'com.example:donna-cloud-contract:0.4.0-SNAPSHOT:stubs'
}
// The JAR with contracts should be taken from Maven
contractsMode = "REMOTE"
contractsRepositoryUrl = "http://nshoppsrv32:8081/nexus/service/local/repositories/nl.donna.build.snapshots/content"
// Base package for generated tests
basePackageForTests = "com.example"
baseClassMappings {
baseClassMapping(".*rest.*", "com.example.BeerRestBase")
}
}
Please learn how to properly format the code