11plugins {
2- id ' org.springframework.boot' version ' 2.7.8 '
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'
5- id " au.com.dius.pact" version " 4.1.39 "
5+ id " au.com.dius.pact" version " 4.5.13 "
66}
77
88group = ' com.example'
99version = ' 0.0.1-SNAPSHOT'
10- sourceCompatibility = ' 15'
10+ java {
11+ sourceCompatibility = ' 17'
12+ }
1113
1214repositories {
1315 mavenCentral()
@@ -23,9 +25,9 @@ dependencies {
2325 implementation ' org.springframework.boot:spring-boot-starter-web'
2426 implementation ' org.springframework.boot:spring-boot-starter-graphql'
2527 implementation ' org.springframework.boot:spring-boot-starter-data-jpa'
26- testImplementation ' au.com.dius.pact.provider:junit:4.1.39 '
27- testImplementation ' au.com.dius.pact.provider:junit5:4.1.39 '
28- testImplementation ' au.com.dius.pact.provider:spring:4.1.39 '
28+ testImplementation ' au.com.dius.pact.provider:junit:4.5.13 '
29+ testImplementation ' au.com.dius.pact.provider:junit5:4.5.13 '
30+ testImplementation ' au.com.dius.pact.provider:spring:4.5.13 '
2931
3032 runtimeOnly ' com.h2database:h2'
3133 compileOnly ' org.projectlombok:lombok'
@@ -39,9 +41,31 @@ test {
3941 useJUnitPlatform()
4042
4143 // These properties need to be set on the test JVM process
44+
45+ // required variables for fetching dynamic pacts, & publishing verification results
46+ // used for fetching dynamic pacts
47+ systemProperty(" pactbroker.providerBranch" , System . getenv(" GIT_BRANCH" ) == null ? " " : System . getenv(" GIT_BRANCH" ))
48+ // used for publishing verification results
49+ systemProperty(" pact.provider.branch" , System . getenv(" GIT_BRANCH" ) == null ? " " : System . getenv(" GIT_BRANCH" ))
4250 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 " ))
44- systemProperty( " pact.provider.branch " , System . getenv( " GIT_BRANCH " ) == null ? " main " : System . getenv( " GIT_BRANCH " ))
45- systemProperty( " pactbroker.consumerversionselectors.rawjson " , " [{ \" mainBranch \" :true}] " )
51+
52+ // only publish verification results from CI allowing developers to run tests locally and debug, without affecting broker results
53+ // only verification results from a known source (such at a commit in a VCS and a reproducible environment such as CI) should be published
4654 systemProperty(" pact.verifier.publishResults" , System . getenv(" PACT_BROKER_PUBLISH_VERIFICATION_RESULTS" ) == null ? " false" : " true" )
55+
56+ // Consumer version selectors for dynamically fetching pacts
57+ // https://docs.pact.io/implementation_guides/jvm/provider/junit#selecting-the-pacts-to-verify-with-consumer-version-selectors-4314
58+ // Runs when the provider code changes
59+ systemProperty(" pactbroker.consumerversionselectors.rawjson" , " [{\" mainBranch\" :true},{\" deployedOrReleased\" :true},{\" matchingBranch\" :true}]" )
60+ // Allow just the changed pact triggered by webhook, to be verified, ignoring the consumer version selectors above
61+ // https://docs.pact.io/implementation_guides/jvm/provider/junit#allowing-just-the-changed-pact-specified-in-a-webhook-to-be-verified-406
62+ // Runs when the consumer contract changes
63+ systemProperty(" pact.filter.pacturl" , System . getenv(" PACT_URL" ) == null ? null : System . getenv(" PACT_URL" ))
64+ systemProperty(" pact.filter.consumers" , System . getenv(" PACT_URL" ) == null ? null : System . getenv(" PACT_URL" ). split(" /consumer/" )[1 ])
65+
66+ // pending pacts
67+ systemProperty(" pactbroker.enablePending" , true )
68+
69+ // work in progress pacts
70+ systemProperty(" pactbroker.includeWipPactsSince" , java.time.LocalDate . now(). minusMonths(6 ). format(java.time.format.DateTimeFormatter . ofPattern(" yyyy-MM-dd" )))
4771}
0 commit comments