package au.com.dius.pact.provider.gradle

import org.gradle.api.NamedDomainObjectContainer
import org.gradle.util.ConfigureUtil

/**
 * Extension object for pact plugin
 */
class PactPluginExtension {

    final NamedDomainObjectContainer<GradleProviderInfo> serviceProviders

    PactPublish publish
    VerificationReports reports

    PactPluginExtension(serviceProviders) {
      this.serviceProviders = serviceProviders
    }

    @SuppressWarnings('ConfusingMethodName')
    def serviceProviders(Closure closure) {
        serviceProviders.configure(closure)
    }

    @SuppressWarnings('ConfusingMethodName')
    def publish(Closure closure) {
        publish = new PactPublish()
        ConfigureUtil.configure(closure, publish)
    }

  @SuppressWarnings('ConfusingMethodName')
  def reports(Closure closure) {
    reports = new VerificationReports()
    ConfigureUtil.configure(closure, reports)
  }
}

package au.com.dius.pact.provider.gradle

import groovy.transform.CompileStatic
import org.gradle.api.Action
import org.gradle.api.NamedDomainObjectContainer

/**
 * Extension object for pact plugin
 */
@CompileStatic
class PactPluginExtension {

    final NamedDomainObjectContainer<GradleProviderInfo> serviceProviders

    PactPublish publish

    VerificationReports reports

    PactPluginExtension(NamedDomainObjectContainer<GradleProviderInfo> serviceProviders) {
        this.serviceProviders = serviceProviders
    }

    @SuppressWarnings('ConfusingMethodName')
    void serviceProviders(Action<? extends NamedDomainObjectContainer<GradleProviderInfo>> configureAction) {
        configureAction.execute(serviceProviders)
    }

    @SuppressWarnings('ConfusingMethodName')
    void publish(Action<? extends PactPublish> configureAction) {
        publish = new PactPublish()
        configureAction.execute(publish)
    }

    @SuppressWarnings('ConfusingMethodName')
    void reports(Action<? extends VerificationReports> configureAction) {
        reports = new VerificationReports()
        configureAction.execute(reports)
    }
}

Allow using pact-jvm-provider-gradle with Kotlin
Allow using pact-jvm-provider-gradle with Kotlin

Methods taking Groovy Closure were causing 'Type mismatch' error
in Kotlin.

Additionally make the extension statically compiled.

Fixes #852
