Skip to content

Commit c4ac2a3

Browse files
committedOct 20, 2019
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
1 parent b37c6d7 commit c4ac2a3

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
11
package au.com.dius.pact.provider.gradle
22

3+
import groovy.transform.CompileStatic
4+
import org.gradle.api.Action
35
import org.gradle.api.NamedDomainObjectContainer
4-
import org.gradle.util.ConfigureUtil
56

67
/**
78
* Extension object for pact plugin
89
*/
10+
@CompileStatic
911
class PactPluginExtension {
1012

1113
final NamedDomainObjectContainer<GradleProviderInfo> serviceProviders
1214

1315
PactPublish publish
16+
1417
VerificationReports reports
1518

16-
PactPluginExtension(serviceProviders) {
17-
this.serviceProviders = serviceProviders
19+
PactPluginExtension(NamedDomainObjectContainer<GradleProviderInfo> serviceProviders) {
20+
this.serviceProviders = serviceProviders
1821
}
1922

2023
@SuppressWarnings('ConfusingMethodName')
21-
def serviceProviders(Closure closure) {
22-
serviceProviders.configure(closure)
24+
void serviceProviders(Action<? extends NamedDomainObjectContainer<GradleProviderInfo>> configureAction) {
25+
configureAction.execute(serviceProviders)
2326
}
2427

2528
@SuppressWarnings('ConfusingMethodName')
26-
def publish(Closure closure) {
29+
void publish(Action<? extends PactPublish> configureAction) {
2730
publish = new PactPublish()
28-
ConfigureUtil.configure(closure, publish)
31+
configureAction.execute(publish)
2932
}
3033

31-
@SuppressWarnings('ConfusingMethodName')
32-
def reports(Closure closure) {
33-
reports = new VerificationReports()
34-
ConfigureUtil.configure(closure, reports)
35-
}
34+
@SuppressWarnings('ConfusingMethodName')
35+
void reports(Action<? extends VerificationReports> configureAction) {
36+
reports = new VerificationReports()
37+
configureAction.execute(reports)
38+
}
3639
}

0 commit comments

Comments
 (0)
Please sign in to comment.