[GRADLE-633] Findbug Ant task doesn't work - "unexpected token: class" Created: 11/Sep/09  Updated: 04/Jan/13  Resolved: 13/Sep/09

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Tomek Kaczanowski Assignee: Hans Dockter
Resolution: Won't Fix Votes: 0

Attachments: Zip Archive findbugs.zip    

 Description   

if you include such snippet in build.gradle:
createTask('findbugs') {
println 'Running findbugs static code analysis'
ant {
taskdef(name:'findbugs', classname:'edu.umd.cs.findbugs.anttask.FindBugsTask', classpath: configurations.findbugsConf.asPath)

findbugs(home: '/home/tomek/bin/findbugs', output:'xml')

{ sourcePath(path: 'src/main/java') class(location: 'build/libs/findbugs-unspecified.jar') }

}
}

it will fail with the following message:
FAILURE: Build failed with an exception.

  • Where:
    Build file '/home/tomek/temp/findbugs/build.gradle' line: 22
  • What went wrong:
    Could not compile build file '/home/tomek/temp/findbugs/build.gradle'.
    Cause: startup failed, build_gradle_bfa6716a6b68b3a8303c7268cf58a48e: 22: unexpected token: class @ line 22, column 3.
    1 error

looks like "class" is treated as reserved keyword and can't be included in the build script like this

This makes impossible to use Findbugs from build.gradle via its Ant task (class parameter is required by Findbugs)

Attached project illustrates this behaviour.


best regards
Tomek Kaczanowski



 Comments   
Comment by Adam Murdoch [ 11/Sep/09 ]

You can quote the class method:

findbugs(...) {
    "class"(location: ...)
}
Comment by Hans Dockter [ 13/Sep/09 ]

We can't really do anything about that. But that's a good issue for the faq/cookbook.

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