Skip to content

Commit

Permalink
Merge pull request #23211 Fix issue with ant builder throwing excepti…
Browse files Browse the repository at this point in the history
…on on call()

Fixes the issue where `call()` is invoked on a dynamic object that does not throw a MethodMissingException on an unknown method (such as `BasicAntBuilder`, that assumes the method call is an incorrect xml element).

Fixes #23111

Co-authored-by: Gary Hale <gary@gradle.com>
  • Loading branch information
bot-gradle and ghale committed Dec 19, 2022
2 parents 1bd7c90 + ec424d6 commit d1a0b6e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Expand Up @@ -18,6 +18,7 @@ package org.gradle.internal.extensibility


import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import spock.lang.Issue

class CallablePropertyIntegrationTest extends AbstractIntegrationSpec {

Expand Down Expand Up @@ -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")
}
}
Expand Up @@ -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();
}
Expand Down

0 comments on commit d1a0b6e

Please sign in to comment.