<commit_before>Gradle
======

Gradle plugin for verifying pacts against a provider.

The Gradle plugin creates a task `pactVerify` to your build which will verify all configured pacts against your provider.

__*Important Note: Any properties that need to be set when using the Gradle plugin need to be provided with `-P` and
not `-D` as with the other Pact-JVM modules!*__ 

## To Use It

### For Gradle versions 2.1+

```groovy
plugins {
  id "au.com.dius.pact" version "4.1.0"
}
```


### For Gradle versions prior to 2.1

#### 1.1. Add the gradle jar file to your build script class path:

```groovy
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'au.com.dius.pact.provider:gradle:4.1.0'
    }
}
```

#### 1.2. Apply the pact plugin

```groovy
apply plugin: 'au.com.dius.pact'
```

### 2. Define the pacts between your consumers and providers

```groovy

pact {

    serviceProviders {

        // You can define as many as you need, but each must have a unique name
        provider1 {
            // All the provider properties are optional, and have sensible defaults (shown below)
            protocol = 'http'
            host = 'localhost'
            port = 8080
            path = '/'

            // Again, you can define as many consumers for each provider as you need, but each must have a unique name
            hasPactWith('consumer1') {

                // currently supports a file path using file() or a URL using url()
                pactSource = file('path/to/provider1-consumer1-pact.json')

            }

            // Or if you have many pact files in a directory
            hasPactsWith('manyConsumers') {

                // Will define a consumer for each pact file in the directory.
                // Consumer name is read from contents of pact file
                pactFileLocation = file('path/to/pacts')

            }

        }

    }

}
```

### 3. Execute `gradle pactVerify`

# Project Properties

The following project properties can be specified with `-Pproperty=value` on the command line:

|Property|Description|
|--------|-----------|
|`pact.showStacktrace`|This turns on stacktrace printing for each request. It can help with diagnosing network errors|
|`pact.showFullDiff`|This turns on displaying the full diff of the expected versus actual bodies|
|`pact.filter.consumers`|Comma seperated list of consumer names to verify|
|`pact.filter.description`|Only verify interactions whose description match the provided regular expression|
|`pact.filter.providerState`|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state|
|`pact.filter.pacturl`|This filter allows just the just the changed pact specified in a webhook to be run. It should be used in conjunction with `pact.filter.consumers` |
|`pact.verifier.publishResults`|Publishing of verification results will be skipped unless this property is set to 'true'|
|`pact.matching.wildcard`|Enables matching of map values ignoring the keys when this property is set to 'true'|
|`pact.verifier.disableUrlPathDecoding`|Disables decoding of request paths|
|`pact.pactbroker.httpclient.usePreemptiveAuthentication`|Enables preemptive authentication with the pact broker when set to `true`|
|`pact.provider.tag`|Sets the provider tag to push before publishing verification results|
|`pact.content_type.override.<TYPE>.<SUBTYPE>=text|binary`|Overrides the handling of a particular content type [4.1.3+]|

## Specifying the provider hostname at runtime

If you need to calculate the provider hostname at runtime, you can give a Closure as the provider `host`.

```groovy
pact {

    serviceProviders {

        provider1 {
            host = { lookupHostName() }

            hasPactWith('consumer1') {
                pactFile = file('path/to/provider1-consumer1-pact.json')
            }
        }<commit_msg>docs: fix corrupted formatting due to mix of backticks and pipe characters<commit_after>Gradle
======

Gradle plugin for verifying pacts against a provider.

The Gradle plugin creates a task `pactVerify` to your build which will verify all configured pacts against your provider.

__*Important Note: Any properties that need to be set when using the Gradle plugin need to be provided with `-P` and
not `-D` as with the other Pact-JVM modules!*__ 

## To Use It

### For Gradle versions 2.1+

```groovy
plugins {
  id "au.com.dius.pact" version "4.1.0"
}
```


### For Gradle versions prior to 2.1

#### 1.1. Add the gradle jar file to your build script class path:

```groovy
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'au.com.dius.pact.provider:gradle:4.1.0'
    }
}
```

#### 1.2. Apply the pact plugin

```groovy
apply plugin: 'au.com.dius.pact'
```

### 2. Define the pacts between your consumers and providers

```groovy

pact {

    serviceProviders {

        // You can define as many as you need, but each must have a unique name
        provider1 {
            // All the provider properties are optional, and have sensible defaults (shown below)
            protocol = 'http'
            host = 'localhost'
            port = 8080
            path = '/'

            // Again, you can define as many consumers for each provider as you need, but each must have a unique name
            hasPactWith('consumer1') {

                // currently supports a file path using file() or a URL using url()
                pactSource = file('path/to/provider1-consumer1-pact.json')

            }

            // Or if you have many pact files in a directory
            hasPactsWith('manyConsumers') {

                // Will define a consumer for each pact file in the directory.
                // Consumer name is read from contents of pact file
                pactFileLocation = file('path/to/pacts')

            }

        }

    }

}
```

### 3. Execute `gradle pactVerify`

# Project Properties

The following project properties can be specified with `-Pproperty=value` on the command line:

|Property|Description|
|--------|-----------|
|`pact.showStacktrace`|This turns on stacktrace printing for each request. It can help with diagnosing network errors|
|`pact.showFullDiff`|This turns on displaying the full diff of the expected versus actual bodies|
|`pact.filter.consumers`|Comma seperated list of consumer names to verify|
|`pact.filter.description`|Only verify interactions whose description match the provided regular expression|
|`pact.filter.providerState`|Only verify interactions whose provider state match the provided regular expression. An empty string matches interactions that have no state|
|`pact.filter.pacturl`|This filter allows just the just the changed pact specified in a webhook to be run. It should be used in conjunction with `pact.filter.consumers` |
|`pact.verifier.publishResults`|Publishing of verification results will be skipped unless this property is set to 'true'|
|`pact.matching.wildcard`|Enables matching of map values ignoring the keys when this property is set to 'true'|
|`pact.verifier.disableUrlPathDecoding`|Disables decoding of request paths|
|`pact.pactbroker.httpclient.usePreemptiveAuthentication`|Enables preemptive authentication with the pact broker when set to `true`|
|`pact.provider.tag`|Sets the provider tag to push before publishing verification results|
|`pact.content_type.override.<TYPE>.<SUBTYPE>=<VAL>` where `<VAL>` may be `text` or `binary`|Overrides the handling of a particular content type [4.1.3+]|

## Specifying the provider hostname at runtime

If you need to calculate the provider hostname at runtime, you can give a Closure as the provider `host`.

```groovy
pact {

    serviceProviders {

        provider1 {
            host = { lookupHostName() }

            hasPactWith('consumer1') {
                pactFile = file('path/to/provider1-consumer1-pact.json')
            }
        }
{'fraction_non_alphanumeric': 0.09208380378873417, 'fraction_numerical': 0.007778195960356292, 'mean_word_length': 3.0323722812341933, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7288059', 'n_tokens_mistral': 2302, 'n_tokens_neox': 2154, 'n_words': 872}