@@ -34,9 +34,7 @@ import org.gradle.jvm.tasks.Jar
|
||||
* Also adds the necessary {@code testCompile} dependencies
|
||||
*
|
||||
* <ul>
|
||||
* <li>WireMock</li>
|
||||
* <li>JSON Assert</li>
|
||||
* <li>AssertJ</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Jakub Kubrynski, codearte.io
|
||||
@@ -72,6 +70,7 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
createGenerateTestsTask(extension, copyContracts)
|
||||
Task clientTask = createAndConfigureGenerateClientStubsFromDslTask(extension, copyContracts)
|
||||
createAndConfigureGenerateWireMockClientStubsFromDslTask(extension, clientTask)
|
||||
addProjectDependencies(project)
|
||||
addIdeaTestSources(project, extension)
|
||||
}
|
||||
|
||||
@@ -89,6 +88,10 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
private void addProjectDependencies(Project project) {
|
||||
project.dependencies.add("testCompile", "com.toomuchcoding.jsonassert:jsonassert:0.4.7")
|
||||
}
|
||||
|
||||
private void setConfigurationDefaults(ContractVerifierExtension extension) {
|
||||
extension.with {
|
||||
generatedTestSourcesDir = generatedTestSourcesDir ?: project.file("${project.buildDir}/generated-test-sources/contracts")
|
||||
|
||||
@@ -160,12 +160,12 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
|
||||
private static class CopyFileVisitor extends SimpleFileVisitor<Path> {
|
||||
private final Path targetPath;
|
||||
private Path sourcePath = null
|
||||
public CopyFileVisitor(Path targetPath) {
|
||||
CopyFileVisitor(Path targetPath) {
|
||||
this.targetPath = targetPath
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(final Path dir,
|
||||
FileVisitResult preVisitDirectory(final Path dir,
|
||||
final BasicFileAttributes attrs) throws IOException {
|
||||
if (sourcePath == null) {
|
||||
sourcePath = dir
|
||||
@@ -177,7 +177,7 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult visitFile(final Path file,
|
||||
FileVisitResult visitFile(final Path file,
|
||||
final BasicFileAttributes attrs) throws IOException {
|
||||
Path target = targetPath.resolve(sourcePath.relativize(file))
|
||||
if (!target.toFile().exists()) {
|
||||
|
||||
@@ -109,6 +109,16 @@ class ContractVerifierSpec extends Specification {
|
||||
publications.findByName("stubs") != null
|
||||
}
|
||||
|
||||
def "should add jsonassert as a testCompile dependency"() {
|
||||
given:
|
||||
project.plugins.apply(SpringCloudContractVerifierGradlePlugin)
|
||||
|
||||
expect:
|
||||
project.configurations.testCompile.dependencies.find {
|
||||
it.group == "com.toomuchcoding.jsonassert" && it.name == "jsonassert"
|
||||
} != null
|
||||
}
|
||||
|
||||
def "should compile"() {
|
||||
given:
|
||||
ContractVerifierExtension extension = new ContractVerifierExtension()
|
||||
|
||||
@@ -2,48 +2,35 @@ buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'spring-cloud-contract'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
group = 'org.springframework.cloud.testprojects'
|
||||
|
||||
ext {
|
||||
contractsDir = file("repository/mappings")
|
||||
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/repository/")
|
||||
BOM_VERSION = "Dalston.BUILD-SNAPSHOT"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "http://repo.spring.io/snapshot" }
|
||||
maven { url "http://repo.spring.io/milestone" }
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.springframework:spring-web"
|
||||
compile "org.springframework:spring-web:$springVersion"
|
||||
compile "org.springframework:spring-context-support:$springVersion"
|
||||
compile "org.codehaus.groovy:groovy-all"
|
||||
compile 'com.jayway.jsonpath:json-path-assert'
|
||||
compile "org.codehaus.groovy:groovy-all:2.4.5"
|
||||
compile 'com.jayway.jsonpath:json-path-assert:2.2.0'
|
||||
|
||||
testCompile "com.github.tomakehurst:wiremock"
|
||||
testCompile "com.github.tomakehurst:wiremock:2.5.1"
|
||||
testCompile "org.spockframework:spock-spring:1.0-groovy-2.4"
|
||||
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-starter-contract-verifier")
|
||||
}
|
||||
|
||||
contracts {
|
||||
|
||||
@@ -29,40 +29,31 @@ allprojects {
|
||||
}
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
BOM_VERSION = "Dalston.BUILD-SNAPSHOT"
|
||||
wiremockVersion = '2.5.1'
|
||||
|
||||
contractVerifierStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "http://repo.spring.io/snapshot" }
|
||||
maven { url "http://repo.spring.io/milestone" }
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile 'org.codehaus.groovy:groovy-all'
|
||||
testCompile 'org.codehaus.groovy:groovy-all:2.4.5'
|
||||
testCompile "org.spockframework:spock-core:$spockVersion"
|
||||
testCompile 'junit:junit'
|
||||
testCompile "com.github.tomakehurst:wiremock"
|
||||
testCompile("org.springframework.cloud:spring-cloud-starter-contract-verifier")
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile "com.github.tomakehurst:wiremock:$wiremockVersion"
|
||||
}
|
||||
}
|
||||
|
||||
configure([project(':fraudDetectionService'), project(':loanApplicationService')]) {
|
||||
apply plugin: 'spring-boot'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
ext['jetty.version'] = '9.2.17.v20160517'
|
||||
@@ -90,7 +81,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
testCompile "org.mockito:mockito-core"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.springframework.boot:spring-boot-test"
|
||||
testCompile("com.github.tomakehurst:wiremock") {
|
||||
testCompile("com.github.tomakehurst:wiremock:2.5.1") {
|
||||
exclude group: 'org.eclipse.jetty'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ buildscript {
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
BOM_VERSION = "Dalston.BUILD-SNAPSHOT"
|
||||
wiremockVersion = '2.5.1'
|
||||
|
||||
contractVerifierStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
}
|
||||
@@ -36,28 +36,17 @@ group = 'org.springframework.cloud.testprojects'
|
||||
|
||||
subprojects {
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "http://repo.spring.io/snapshot" }
|
||||
maven { url "http://repo.spring.io/milestone" }
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile "org.codehaus.groovy:groovy-all:2.4.5"
|
||||
testCompile "org.spockframework:spock-core:$spockVersion"
|
||||
testCompile "junit:junit"
|
||||
testCompile "com.github.tomakehurst:wiremock"
|
||||
testCompile("org.springframework.cloud:spring-cloud-starter-contract-verifier")
|
||||
testCompile("junit:junit:4.12")
|
||||
testCompile "com.github.tomakehurst:wiremock:$wiremockVersion"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,8 +86,6 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
testCompile "org.springframework.boot:spring-boot-test"
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
}
|
||||
|
||||
task cleanup(type: Delete) {
|
||||
|
||||
@@ -27,7 +27,7 @@ buildscript {
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
BOM_VERSION = "Dalston.BUILD-SNAPSHOT"
|
||||
wiremockVersion = '2.5.1'
|
||||
|
||||
contractVerifierStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
}
|
||||
@@ -37,27 +37,17 @@ group = 'org.springframework.cloud.testprojects'
|
||||
subprojects {
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'spring-boot'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "http://repo.spring.io/snapshot" }
|
||||
maven { url "http://repo.spring.io/milestone" }
|
||||
maven { url "http://repo.spring.io/release" }
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile "org.codehaus.groovy:groovy-all"
|
||||
testCompile "org.codehaus.groovy:groovy-all:2.4.5"
|
||||
testCompile "org.spockframework:spock-core:$spockVersion"
|
||||
testCompile("junit:junit:4.12")
|
||||
testCompile("org.springframework.cloud:spring-cloud-starter-contract-verifier")
|
||||
testCompile "com.github.tomakehurst:wiremock:$wiremockVersion"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +107,8 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
testCompile "org.mockito:mockito-core"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.springframework.boot:spring-boot-test"
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
}
|
||||
|
||||
task cleanup(type: Delete) {
|
||||
|
||||
Reference in New Issue
Block a user