11plugins {
2- id ' org.springframework.boot' version ' 2.2.2.RELEASE '
3- id ' io.spring.dependency-management' version ' 1.0.8.RELEASE '
2+ id ' org.springframework.boot' version ' 3.3.4 '
3+ id ' io.spring.dependency-management' version ' 1.1.6 '
44 id ' java'
55}
66
77group = ' io.pactflow.example.xml.provider'
88version = ' 0.0.1-SNAPSHOT'
9- sourceCompatibility = ' 11'
9+ java {
10+ sourceCompatibility = ' 17'
11+ }
1012
1113repositories {
1214 mavenLocal()
@@ -22,13 +24,13 @@ configurations {
2224dependencies {
2325 implementation ' org.springframework.boot:spring-boot-starter-web'
2426 implementation ' org.springframework.boot:spring-boot-starter-data-jpa'
25- implementation ' com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.2 '
27+ implementation ' com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.18.0 '
2628 runtimeOnly ' com.h2database:h2'
2729 compileOnly ' org.projectlombok:lombok'
2830 annotationProcessor ' org.projectlombok:lombok'
2931
30- testImplementation ' au.com.dius.pact.provider:junit5:4.1.7 '
31- testImplementation ' au.com.dius.pact.provider:spring :4.1.7 '
32+ testImplementation ' au.com.dius.pact.provider:junit5:4.5.13 '
33+ testImplementation ' au.com.dius.pact.provider:spring6 :4.5.13 '
3234 testImplementation ' org.apache.commons:commons-lang3:3.11'
3335 testImplementation(' org.springframework.boot:spring-boot-starter-test' ) {
3436 exclude group : ' org.junit.vintage' , module : ' junit-vintage-engine'
@@ -39,7 +41,34 @@ test {
3941 useJUnitPlatform()
4042
4143 // These properties need to be set on the test JVM process
44+ // https://docs.pact.io/implementation_guides/jvm/provider/junit#using-java-system-properties
45+
46+
47+ // required variables for fetching dynamic pacts, & publishing verification results
48+ // used for fetching dynamic pacts
49+ systemProperty(" pactbroker.providerBranch" , System . getenv(" GIT_BRANCH" ) == null ? " " : System . getenv(" GIT_BRANCH" ))
50+ // used for publishing verification results
51+ systemProperty(" pact.provider.branch" , System . getenv(" GIT_BRANCH" ) == null ? " " : System . getenv(" GIT_BRANCH" ))
4252 systemProperty(" pact.provider.version" , System . getenv(" GIT_COMMIT" ) == null ? " " : System . getenv(" GIT_COMMIT" ))
43- systemProperty(" pact.provider.tag" , System . getenv(" GIT_BRANCH" ) == null ? " " : System . getenv(" GIT_BRANCH" ))
53+
54+ // only publish verification results from CI allowing developers to run tests locally and debug, without affecting broker results
55+ // only verification results from a known source (such at a commit in a VCS and a reproducible environment such as CI) should be published
4456 systemProperty(" pact.verifier.publishResults" , System . getenv(" PACT_BROKER_PUBLISH_VERIFICATION_RESULTS" ) == null ? " false" : " true" )
45- }
57+
58+ // Consumer version selectors for dynamically fetching pacts
59+ // https://docs.pact.io/implementation_guides/jvm/provider/junit#selecting-the-pacts-to-verify-with-consumer-version-selectors-4314
60+ // Runs when the provider code changes
61+ systemProperty(" pactbroker.consumerversionselectors.rawjson" , " [{\" mainBranch\" :true},{\" deployedOrReleased\" :true},{\" matchingBranch\" :true}]" )
62+ // Allow just the changed pact triggered by webhook, to be verified, ignoring the consumer version selectors above
63+ // https://docs.pact.io/implementation_guides/jvm/provider/junit#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406
64+ // Runs when the consumer contract changes
65+ systemProperty(" pact.filter.pacturl" , System . getenv(" PACT_URL" ) == null ? null : System . getenv(" PACT_URL" ))
66+ systemProperty(" pact.filter.consumers" , System . getenv(" PACT_URL" ) == null ? null : System . getenv(" PACT_URL" ). split(" /consumer/" )[1 ])
67+
68+ // pending pacts
69+ systemProperty(" pactbroker.enablePending" , true )
70+
71+ // work in progress pacts
72+ systemProperty(" pactbroker.includeWipPactsSince" , java.time.LocalDate . now(). minusMonths(6 ). format(java.time.format.DateTimeFormatter . ofPattern(" yyyy-MM-dd" )))
73+
74+ }
0 commit comments