[GRADLE-3376] Misleading error when defining a creation rule for an unknown type on a ModelMap using model DSL Created: 30/Dec/15 Updated: 25/Jan/16 Resolved: 25/Jan/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.11-rc-1 |
Type: | Bug | ||
Reporter: | Mark Vieira (Inactive) | Assignee: | Lóránt Pintér |
Resolution: | Fixed | Votes: | 0 |
Description |
When using the model DSL to define a creation rule on a ModelMap, Gradle returns a misleading error when the type specified is unknown. Given the example below: @Managed interface MyManagedType {} class MyPlugin extends RuleSource { @Model void items(ModelMap<MyManagedType> items) {} } apply plugin: MyPlugin model { items { item1(SomeUnknownType) } } The resulting error is: FAILURE: Build failed with an exception. * Where: Build file '/Users/mark/Desktop/gradle/build.gradle' line: 13 * What went wrong: Execution failed for task ':model'. > Exception thrown while executing model rule: items { ... } @ build.gradle line 12, column 5 > Attempt to read a write only view of model of type 'java.lang.Object' given to rule 'items { ... } @ build.gradle line 12, column 5' |
Comments |
Comment by Mark Vieira (Inactive) [ 30/Dec/15 ] |
This issue was first discovered by a forums user: https://discuss.gradle.org/t/rulesource-how-to-use-a-rulesource-plugin-defined-in-a-separate-build-script/13411 |
Comment by Lóránt Pintér [ 25/Jan/16 ] |
This has been addressed in 2.11. Now the same code should print an error message similar to this: Attempt to read property 'SomeUnknownType' from a write only view of model element 'items' given to rule 'items { ... } @ build.gradle line 11, column 17' While this doesn't necessarily point out the exact cause of the error (most probably a typo in a name of a type), including the name of the unknown type in the error message should help figure out what the problem is. |