Changed contractVerifier into contracts

This commit is contained in:
Marcin Grzejszczak
2016-07-20 12:49:58 +02:00
parent 5b900561c9
commit 4d5badafda
9 changed files with 19 additions and 22 deletions

View File

@@ -93,7 +93,7 @@ Default Gradle Plugin setup creates the following Gradle part of the build (it's
[source,groovy,indent=0]
----
contractVerifier {
contracts {
targetFramework = 'JUNIT'
testMode = 'MockMvc'
generatedTestSourcesDir = project.file("${project.buildDir}/generated-test-sources/contracts")
@@ -104,7 +104,7 @@ contractVerifier {
tasks.create(type: Jar, name: 'verifierStubsJar', dependsOn: 'generateWireMockClientStubs') {
baseName = project.name
classifier = contractVerifier.stubsSuffix
classifier = contracts.stubsSuffix
from contractVerifier.stubsOutputDir
}
@@ -113,8 +113,8 @@ project.artifacts {
}
tasks.create(type: Copy, name: 'copyContracts') {
from contractVerifier.contractsDslDir
into contractVerifier.stubsOutputDir
from contracts.contractsDslDir
into contracts.stubsOutputDir
}
verifierStubsJar.dependsOn 'copyContracts'
@@ -131,11 +131,11 @@ publishing {
===== Configure plugin
To change default configuration just add `contractVerifier` snippet to your Gradle config
To change default configuration just add `contracts` snippet to your Gradle config
[source,groovy,indent=0]
----
contractVerifier {
contracts {
testMode = 'MockMvc'
baseClassForTests = 'org.mycompany.tests'
generatedTestSourcesDir = project.file('src/generatedContract')

View File

@@ -39,7 +39,7 @@ dependencyManagement {
}
}
contractVerifier {
contracts {
baseClassForTests = 'com.example.fraud.MvcTest'
}

View File

@@ -41,7 +41,7 @@ ext {
stubsOutputDirRoot = file("${project.buildDir}/stubs/")
}
contractVerifier {
contracts {
baseClassForTests = 'com.example.source.SensorSourceTestBase'
stubsOutputDir = stubsOutputDirRoot
}

View File

@@ -52,7 +52,7 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
private static final Class IDEA_PLUGIN_CLASS = org.gradle.plugins.ide.idea.IdeaPlugin
private static final String GROUP_NAME = "Verification"
private static final String EXTENSION_NAME = 'contractVerifier'
private static final String EXTENSION_NAME = 'contracts'
private Project project

View File

@@ -31,6 +31,11 @@ import static java.nio.charset.StandardCharsets.UTF_8
abstract class ContractVerifierIntegrationSpec extends Specification {
public static final String SPOCK = "targetFramework = 'Spock'"
public static final String JUNIT = "targetFramework = 'JUnit'"
public static final String MVC_SPEC = "baseClassForTests = 'org.springframework.cloud.MvcSpec'"
public static final String MVC_TEST = "baseClassForTests = 'org.springframework.cloud.MvcTest'"
File testProjectDir
def setup() {
@@ -40,21 +45,12 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
testProjectDir = testFolder
}
public static final String SPOCK = "targetFramework = 'Spock'"
public static final String JUNIT = "targetFramework = 'JUnit'"
public static final String MVC_SPEC = "baseClassForTests = 'org.springframework.cloud.MvcSpec'"
public static final String MVC_TEST = "baseClassForTests = 'org.springframework.cloud.MvcTest'"
protected void setupForProject(String projectRoot) {
copyResourcesToRoot(projectRoot)
String gradlePluginSysProp = System.getProperty("contract-gradle-plugin-libs-dir")
String gradlePluginLibsDir = (gradlePluginSysProp ?: new File("build/").absolutePath.toString()).replace('\\', '\\\\')
String messagingLibDirProp = System.getProperty("messaging-libs-dir")
String messagingLibDir = (messagingLibDirProp ?: new File("build/").absolutePath.toString()).replace('\\', '\\\\')
buildFile.write """
ext.messagingLibsDir = '$messagingLibDir'
buildscript {
dependencies {
classpath fileTree(dir: '$gradlePluginLibsDir', include: '*.jar')
@@ -97,6 +93,7 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
return GradleRunner.create()
.withProjectDir(testProjectDir)
.withArguments(tasks)
.withDebug(true)
.forwardOutput()
.build()
}

View File

@@ -47,7 +47,7 @@ dependencies {
testCompile "ch.qos.logback:logback-classic:1.1.2"
}
contractVerifier {
contracts {
baseClassForTests = 'org.springframework.cloud.contract.verifier.twitter.places.BaseMockMvcSpec'
basePackageForTests = 'contracts'
contractsDslDir = contractsDir

View File

@@ -60,7 +60,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/")
}
contractVerifier {
contracts {
targetFramework = 'Spock'
testMode = 'JaxRsClient'
baseClassForTests = 'org.springframework.cloud.MvcSpec'

View File

@@ -60,7 +60,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/")
}
contractVerifier {
contracts {
targetFramework = 'Spock'
testMode = 'MockMvc'
baseClassForTests = 'org.springframework.cloud.MvcSpec'

View File

@@ -76,7 +76,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
}
// end::jar_setup[]
contractVerifier {
contracts {
// tag::target_framework[]
targetFramework = 'Spock'
// end::target_framework[]