diff --git a/subprojects/model-core/src/integTest/groovy/org/gradle/internal/extensibility/CallablePropertyIntegrationTest.groovy b/subprojects/model-core/src/integTest/groovy/org/gradle/internal/extensibility/CallablePropertyIntegrationTest.groovy index e5a53c463632..552e4ad5ef4b 100644 --- a/subprojects/model-core/src/integTest/groovy/org/gradle/internal/extensibility/CallablePropertyIntegrationTest.groovy +++ b/subprojects/model-core/src/integTest/groovy/org/gradle/internal/extensibility/CallablePropertyIntegrationTest.groovy @@ -18,6 +18,7 @@ package org.gradle.internal.extensibility import org.gradle.integtests.fixtures.AbstractIntegrationSpec +import spock.lang.Issue class CallablePropertyIntegrationTest extends AbstractIntegrationSpec { @@ -95,4 +96,19 @@ class CallablePropertyIntegrationTest extends AbstractIntegrationSpec { "Inside Project.configure" | "configure(container.foo) { prop() }" "Inside NDOC.configure" | "container.configure { foo { prop() } }" } + + @Issue('https://github.com/gradle/gradle/issues/23111') + def "can configure dynamic property without call method"() { + buildFile << """ + task test { + doLast { + ant { echo(message: 'hello world!') } + } + } + """ + + expect: + args('--stacktrace') + succeeds("test") + } } diff --git a/subprojects/model-core/src/main/java/org/gradle/internal/extensibility/MixInClosurePropertiesAsMethodsDynamicObject.java b/subprojects/model-core/src/main/java/org/gradle/internal/extensibility/MixInClosurePropertiesAsMethodsDynamicObject.java index a58375206b7c..4ba1f999c477 100644 --- a/subprojects/model-core/src/main/java/org/gradle/internal/extensibility/MixInClosurePropertiesAsMethodsDynamicObject.java +++ b/subprojects/model-core/src/main/java/org/gradle/internal/extensibility/MixInClosurePropertiesAsMethodsDynamicObject.java @@ -56,7 +56,9 @@ public DynamicInvokeResult tryInvokeMethod(String name, Object... arguments) { return DynamicInvokeResult.found(); } DynamicObject dynamicObject = DynamicObjectUtil.asDynamicObject(property); - return dynamicObject.tryInvokeMethod("call", arguments); + if (dynamicObject.hasMethod("call", arguments)) { + return dynamicObject.tryInvokeMethod("call", arguments); + } } return DynamicInvokeResult.notFound(); }