If a setter is defined for a property defined using decoration on an abstract getter Gradle will fail with the following error:
Cannot have abstract method MyClass.getXYZ()
Caused by: java.lang.IllegalArgumentException: Cannot have abstract method MyClass.getMyFile().
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.assertNotAbstract(AbstractClassGenerator.java:396)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:322)
at org.gradle.internal.instantiation.generator.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:224)
... 224 more
Expected Behavior
If this pattern is valid then having both the auto generated decorated setter overloaded by a custom setter should work.
If this pattern is not valid then a better error message should be thrown indicating that a setter of an auto generated property cannot be overloaded.
Context (optional)
No response
Steps to Reproduce
Create a decorated object:
public abstract class MyClass {
private transient ObjectFactory objectFactory;
@Inject
public MyClass(ObjectFactory objectFactory) {
this.objectFactory = objectFactory;
}
@InputFile
public abstract RegularFileProperty getMyFile();
// Overloaded to allow passing in String objects
public void setMyFile(Object obj) {
getMyFile().set(objectFactory.fileCollection().from(obj).getSingleFile());
}
}
Current Behavior
If a setter is defined for a property defined using decoration on an abstract getter Gradle will fail with the following error:
Expected Behavior
If this pattern is valid then having both the auto generated decorated setter overloaded by a custom setter should work.
If this pattern is not valid then a better error message should be thrown indicating that a setter of an auto generated property cannot be overloaded.
Context (optional)
No response
Steps to Reproduce
Instantiate it using objectFactory
Use the plugin and object and attempt to set myFile
Gradle version
8.3
Build scan URL (optional)
No response
Your Environment (optional)
No response