[GRADLE-1352] Improve error message when class cannot be found Created: 25/Jan/11  Updated: 04/Jan/13  Resolved: 26/Jan/11

Status: Resolved
Project: Gradle
Affects Version/s: 0.9.2
Fix Version/s: 1.0-milestone-1

Type: Bug
Reporter: Ben McCann Assignee: Unassigned
Resolution: Won't Fix Votes: 0

Attachments: File build.gradle    

 Description   

In the attached build file, I accidentally wrote:
com.smokejumperit.gradle.OneJar

Instead of:
com.smokejumperit.gradle.OneJarPlugin

The message I got was:
groovy.lang.MissingPropertyException: Could not find property 'com' on project

This was very misleading to me, so it took me take a very long time to figure out what the problem was. A much better error message would be something like:
groovy.lang.MissingClassException: Could not find class 'com.smokejumperit.gradle.OneJar'



 Comments   
Comment by Hans Dockter [ 26/Jan/11 ]

I know this problem very well. Mostly from working with Groovy. It is very confusing. Responsible for this is the Groovy compiler. Not sure if we can do anything about this.

Peter Niederwieser might have a good idea.

Comment by Peter Niederwieser [ 26/Jan/11 ]

There isn't much we can do about the error message, it's just the way Groovy works. The best way to solve this problem is for the plugin author to add a plugin descriptor. Then the plugin can be referenced by ID (apply plugin: "sjit.onejar") rather than class name, and Gradle will issue a meaningful error message if it can't find a plugin with this ID. https://github.com/pniederw/gradle-plugins shows how it is done. I've sent a pull request to https://github.com/RobertFischer/gradle-plugins.

Generated at Wed Jun 30 11:53:22 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.