Bumped Gradle to 3.0 and Boot to 1.4 in Gradle plugin

This commit is contained in:
Marcin Grzejszczak
2016-08-30 11:43:01 +02:00
parent 8dde9f333b
commit ebd3fd3bcb
25 changed files with 83 additions and 126 deletions

View File

@@ -18,7 +18,8 @@ ext {
contractVerifierGradlePluginLibsDir ="$buildDir/contractVerifier-gradle-plugin-libs"
testSystemProperties = [
'contract-gradle-plugin-libs-dir': contractVerifierGradlePluginLibsDir
'contract-gradle-plugin-libs-dir': contractVerifierGradlePluginLibsDir,
"WORK_OFFLINE" : gradle.startParameter.isOffline() ? 'TRUE' : 'FALSE'
]
}
@@ -27,6 +28,7 @@ apply plugin: 'groovy'
apply from: "$rootDir/gradle/release.gradle"
apply plugin: 'eclipse'
apply plugin: "jacoco"
apply plugin: 'checkstyle'
group = 'org.springframework.cloud'
@@ -68,6 +70,7 @@ dependencies {
}
testCompile 'info.solidsoft.spock:spock-global-unroll:0.5.0'
testCompile gradleTestKit()
checkstyle 'org.springframework.cloud:spring-cloud-build:1.0.2.RELEASE'
}
@@ -84,6 +87,7 @@ groovydoc {
def title = "IPDS ${version}"
groovyClasspath = project.configurations.jansi
}
dependencies {
contractVerifierGradlePluginLibs project
jansi 'org.fusesource.jansi:jansi:1.11'
@@ -97,20 +101,6 @@ task archiveContractVerifierGradlePluginLibsDependencies(type: Sync) {
archiveContractVerifierGradlePluginLibsDependencies.dependsOn project.tasks.jar
test.dependsOn archiveContractVerifierGradlePluginLibsDependencies
configurations {
all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
// To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions
// all modularized Groovy jars are replaced with groovy-all.jar by default.
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") {
details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}")
}
}
}
}
}
jacoco {
toolVersion = "0.7.7.201606060606"
}

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
./gradlew clean build

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
./gradlew clean build install && ./scripts/runTests.sh && ./gradlew uploadArchives -x test

View File

@@ -1,6 +1,6 @@
#Thu Jul 21 10:16:50 CEST 2016
#Mon Aug 29 14:43:30 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip

View File

@@ -1,56 +0,0 @@
// orphaned from the main build when this project moved
project(":$verifier-root:$gradle-plugin") {
ext.messagingLibsDir ="$buildDir/messaging-libs"
ext.contractVerifierGradlePluginLibsDir ="$buildDir/contractVerifier-gradle-plugin-libs"
ext.testSystemProperties = [
'contract-gradle-plugin-libs-dir': contractVerifierGradlePluginLibsDir,
'messaging-libs-dir': messagingLibsDir
]
dependencies {
compile project(":$verifier-root:$verifier-core")
compile project(":$verifier-root:$verifier-converters")
compile gradleApi()
testCompile gradleTestKit()
testCompile project(":$verifier-root:$verifier-testing-utils")
}
configurations {
messagingLibs
contractVerifierGradlePluginLibs
}
dependencies {
messagingLibs project(":$verifier-root:$verifier-messaging-root:$verifier-integration")
messagingLibs project(":$verifier-root:$verifier-messaging-root:$verifier-messaging-core")
messagingLibs project(":$verifier-root:$verifier-testing-utils")
messagingLibs 'org.codehaus.groovy:groovy-all:2.4.5'
contractVerifierGradlePluginLibs project(":$verifier-root:$gradle-plugin")
}
test {
systemProperties = testSystemProperties
}
task archiveMessagingLibsDependencies(type: Sync) {
from configurations.messagingLibs.resolvedConfiguration.resolvedArtifacts.collect { it.file }
into messagingLibsDir
}
task archiveContractVerifierGradlePluginLibsDependencies(type: Sync) {
from configurations.contractVerifierGradlePluginLibs.resolvedConfiguration.resolvedArtifacts.collect { it.file }
into contractVerifierGradlePluginLibsDir
}
// archive task needs to have jars ready
archiveMessagingLibsDependencies.dependsOn project(":$verifier-root:$verifier-messaging-root:$verifier-integration").tasks.jar
archiveContractVerifierGradlePluginLibsDependencies.dependsOn project(":$verifier-root:$gradle-plugin").tasks.jar
test.dependsOn archiveMessagingLibsDependencies, archiveContractVerifierGradlePluginLibsDependencies
}

View File

@@ -30,7 +30,7 @@ class BasicFunctionalSpec extends ContractVerifierIntegrationSpec {
private static final String GENERATED_TEST = "build//generated-test-sources//contracts//contracts//spring//cloud//twitter_places_analyzer//PairIdSpec.groovy"
private static final String GENERATED_CLIENT_JSON_STUB = "build//production//bootSimple-stubs//repository//mappings//spring//cloud//twitter-places-analyzer//pairId//collerate_PlacesFrom_Tweet.json"
private static final String GROOVY_DSL_CONTRACT = "repository//mappings//spring//cloud//twitter-places-analyzer//pairId//collerate_PlacesFrom_Tweet.groovy"
private static final String TEST_EXECUTION_XML_REPORT = "build/test-results/TEST-contracts.spring.cloud.twitter_places_analyzer.PairIdSpec.xml"
private static final String TEST_EXECUTION_XML_REPORT = "build/test-results/test/TEST-contracts.spring.cloud.twitter_places_analyzer.PairIdSpec.xml"
def setup() {
setupForProject("functionalTest/bootSimple")
@@ -39,7 +39,7 @@ class BasicFunctionalSpec extends ContractVerifierIntegrationSpec {
def "should pass basic flow"() {
when:
BuildResult result = run("check", "publishToMavenLocal")
BuildResult result = run(checkAndPublishToMavenLocal())
then:
result.task(":generateWireMockClientStubs").outcome == SUCCESS
result.task(":generateContractTests").outcome == SUCCESS

View File

@@ -35,6 +35,7 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
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 static final boolean WORK_OFFLINE = Boolean.parseBoolean(System.getProperty('WORK_OFFLINE', 'false'))
File testProjectDir
@@ -89,6 +90,12 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
return result
}
protected String[] checkAndPublishToMavenLocal() {
String[] args = ["check", "publishToMavenLocal", "--info"] as String[]
if (WORK_OFFLINE) args << "--offline"
return args
}
protected BuildResult run(String... tasks) {
return GradleRunner.create()
.withProjectDir(testProjectDir)
@@ -118,7 +125,9 @@ abstract class ContractVerifierIntegrationSpec extends Specification {
}
protected File file(String path) {
return new File(testProjectDir, path)
File file = new File(testProjectDir, path)
println "Resolved path is [$file]"
return file
}
protected boolean fileExists(String path) {

View File

@@ -1,7 +1,7 @@
package org.springframework.cloud.contract.verifier.plugin
import org.gradle.api.Task
import org.gradle.api.internal.project.AbstractProject
import org.gradle.api.internal.project.DefaultProject
import org.gradle.api.plugins.GroovyPlugin
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
@@ -10,13 +10,13 @@ import org.springframework.cloud.contract.verifier.config.ContractVerifierConfig
import spock.lang.Specification
class ContractVerifierSpec extends Specification {
AbstractProject project
DefaultProject project
def setup() {
def dateString = new Date().format("yyyy-MM-dd_HH-mm-ss")
def testFolder = new File("build/generated-tests/${getClass().simpleName}/${dateString}")
testFolder.mkdirs()
project = (AbstractProject) ProjectBuilder.builder().withProjectDir(testFolder).build()
project = (DefaultProject) ProjectBuilder.builder().withProjectDir(testFolder).build()
}
def "should apply groovy plugin"() {

View File

@@ -30,7 +30,7 @@ class SampleJerseyProjectSpec extends ContractVerifierIntegrationSpec {
given:
assert fileExists('build.gradle')
expect:
runTasksSuccessfully('check', "publishToMavenLocal")
runTasksSuccessfully(checkAndPublishToMavenLocal())
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
}
@@ -39,7 +39,7 @@ class SampleJerseyProjectSpec extends ContractVerifierIntegrationSpec {
switchToJunitTestFramework()
assert fileExists('build.gradle')
expect:
runTasksSuccessfully('check', "publishToMavenLocal")
runTasksSuccessfully(checkAndPublishToMavenLocal())
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
}

View File

@@ -30,7 +30,9 @@ class SampleProjectSpec extends ContractVerifierIntegrationSpec {
given:
assert fileExists('build.gradle')
expect:
runTasksSuccessfully('check', "publishToMavenLocal")
String[] args = ["check", "publishToMavenLocal", "--debug"] as String[]
if (WORK_OFFLINE) args << "--offline"
runTasksSuccessfully(args)
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
}
@@ -39,7 +41,7 @@ class SampleProjectSpec extends ContractVerifierIntegrationSpec {
switchToJunitTestFramework()
assert fileExists('build.gradle')
expect:
runTasksSuccessfully('check', "publishToMavenLocal")
runTasksSuccessfully(checkAndPublishToMavenLocal())
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
}

View File

@@ -30,7 +30,7 @@ class ScenarioProjectSpec extends ContractVerifierIntegrationSpec {
given:
assert fileExists('build.gradle')
expect:
runTasksSuccessfully('check', "publishToMavenLocal")
runTasksSuccessfully(checkAndPublishToMavenLocal())
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
}
@@ -39,7 +39,7 @@ class ScenarioProjectSpec extends ContractVerifierIntegrationSpec {
assert fileExists('build.gradle')
expect:
switchToJunitTestFramework()
runTasksSuccessfully('check', "publishToMavenLocal")
runTasksSuccessfully(checkAndPublishToMavenLocal())
jarContainsContractVerifierContracts('fraudDetectionService/build/libs')
}

View File

@@ -15,20 +15,6 @@ ext {
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/repository/")
}
configurations {
all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
// To prevent an accidental usage of groovy-all.jar and groovy.jar in different versions
// all modularized Groovy jars are replaced with groovy-all.jar by default.
if (details.requested.group == 'org.codehaus.groovy' && details.requested.name != "groovy-all") {
details.useTarget("org.codehaus.groovy:groovy-all:${details.requested.version}")
}
}
}
}
}
repositories {
mavenCentral()
mavenLocal()

View File

@@ -20,7 +20,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE"
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE"
}
}
@@ -59,6 +59,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
contractsDir = file("mappings")
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/")
}
ext['jetty.version'] = '9.2.17.v20160517'
contracts {
targetFramework = 'Spock'
@@ -78,14 +79,23 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
}
dependencies {
compile 'org.glassfish.jersey.containers:jersey-container-jetty-http:2.15'
compile('org.glassfish.jersey.containers:jersey-container-jetty-http:2.23.2') {
exclude group: 'org.eclipse.jetty'
}
compile 'org.springframework.boot:spring-boot-starter-jersey'
compile 'org.springframework.boot:spring-boot-starter-jetty'
testRuntime "org.spockframework:spock-spring:$spockVersion"
compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.15'
testCompile 'org.springframework:spring-test'
compile('org.glassfish.jersey.connectors:jersey-apache-connector:2.23.2') {
exclude group: 'org.eclipse.jetty'
}
testCompile "org.mockito:mockito-core"
testCompile "org.springframework:spring-test"
testCompile "org.springframework.boot:spring-boot-test"
testCompile("com.github.tomakehurst:wiremock:2.1.7") {
exclude group: 'org.eclipse.jetty'
}
}
task cleanup(type: Delete) {

View File

@@ -38,7 +38,10 @@ Contract.make {
"rejectionReason": "Amount too high"
}""")
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}

View File

@@ -39,7 +39,10 @@ Contract.make {
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.frauddetection.Application
import org.springframework.cloud.frauddetection.LoanApplicationService
import org.springframework.cloud.frauddetection.model.Client
@@ -25,12 +26,11 @@ import org.springframework.cloud.frauddetection.model.LoanApplicationStatus
import com.github.tomakehurst.wiremock.junit.WireMockClassRule
import org.junit.ClassRule
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.test.context.ContextConfiguration
import spock.lang.Shared
import spock.lang.Specification
@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application)
@ContextConfiguration(loader = SpringBootContextLoader, classes = Application)
class LoanApplicationServiceSpec extends Specification {
public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort()

View File

@@ -20,7 +20,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
}
}
@@ -81,7 +81,9 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
compile("org.springframework.boot:spring-boot-starter-actuator")
testRuntime "org.spockframework:spock-spring:$spockVersion"
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"
}

View File

@@ -37,7 +37,10 @@ Contract.make {
"rejectionReason": "Amount too high"
}""")
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}

View File

@@ -38,7 +38,10 @@ Contract.make {
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}

View File

@@ -16,21 +16,21 @@
package org.springframework.cloud
import com.github.tomakehurst.wiremock.junit.WireMockClassRule
import org.junit.ClassRule
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.frauddetection.Application
import org.springframework.cloud.frauddetection.LoanApplicationService
import org.springframework.cloud.frauddetection.model.Client
import org.springframework.cloud.frauddetection.model.LoanApplication
import org.springframework.cloud.frauddetection.model.LoanApplicationResult
import org.springframework.cloud.frauddetection.model.LoanApplicationStatus
import com.github.tomakehurst.wiremock.junit.WireMockClassRule
import org.junit.ClassRule
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.test.context.ContextConfiguration
import spock.lang.Shared
import spock.lang.Specification
@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application)
@ContextConfiguration(loader = SpringBootContextLoader, classes = Application)
class LoanApplicationServiceSpec extends Specification {
public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort()

View File

@@ -20,7 +20,7 @@ buildscript {
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
}
}
@@ -99,7 +99,9 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
compile("org.springframework.boot:spring-boot-starter-actuator")
testRuntime "org.spockframework:spock-spring:$spockVersion"
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"
}

View File

@@ -38,7 +38,10 @@ Contract.make {
rejectionReason: $(consumer(null), producer(execute('assertThatRejectionReasonIsNull($it)')))
)
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}

View File

@@ -38,7 +38,10 @@ Contract.make {
"rejectionReason": "Amount too high"
}""")
headers {
header('Content-Type': 'application/vnd.fraud.v1+json')
header('Content-Type': value(
producer(regex('application/vnd.fraud.v1.json.*')),
consumer('application/vnd.fraud.v1+json'))
)
}
}

View File

@@ -16,6 +16,7 @@
package org.springframework.cloud
import org.springframework.boot.test.context.SpringBootContextLoader
import org.springframework.cloud.frauddetection.Application
import org.springframework.cloud.frauddetection.LoanApplicationService
import org.springframework.cloud.frauddetection.model.Client
@@ -25,13 +26,12 @@ import org.springframework.cloud.frauddetection.model.LoanApplicationStatus
import com.github.tomakehurst.wiremock.junit.WireMockClassRule
import org.junit.ClassRule
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.test.context.ContextConfiguration
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Stepwise
@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application)
@ContextConfiguration(loader = SpringBootContextLoader, classes = Application)
@Stepwise
class LoanApplicationServiceSpec extends Specification {