Unable to compile java 8 project

I’m trying to configure a new java 8 project in gradle, but I get an error:

* What went wrong:
A problem occurred evaluating root project 'NewProject'.
> Could not determine targetjdk from '1.8'.

my configuration looks like this:

apply plugin: "java"
sourceCompatibility = 1.8
targetCompatibility = 1.8

If I change targetCompatibility to 1.7, it works fine.

The output of gradlew -v:

$ ./gradlew -v
Gradle 2.2.1
  Build time:
 2014-11-24 09:45:35 UTC
Build number: none
        Apache Ant(TM) version 1.9.3 compiled on December 23 2013
        1.8.0_25 (Oracle Corporation 25.25-b02)
         Linux 3.13.0-44-generic amd64

Are you also using the PMD plugin by any chance?

yes, I am, I set it up like:

apply plugin: "pmd"
ext.pmdVersion = "5.2.3"
dependencies {
pmd {
    toolVersion = pmdVersion
    ruleSetFiles = files("config/pmd/ruleSet.xml")
    targetJdk = project.targetCompatibility
    sourceSets = [
    ignoreFailures = true

ah, I see now, the error is coming from the PMD plugin (targetJdk = project.targetCompatibility). If the plugin lets us pick the tool version, it should support java 1.8 (and any future version of java as well). PMD has supported java 8 for a while now.

Yes, it seems the PMD plugin should support a target jdk of 1.8, at least for tool versions > 5.1.0.

Looking at the code it seems the value of ‘targetJdk’ is only even used for PMD versions < 5. In this case you can simply avoid setting its value (in which case the PMD plugin would default to 1.4) since it will be ignored anyway.

Thanks, that worked! I’d been using PMD for years and got in the habit of setting it, I didn’t think to see if it was deprecated.

Where is the right place to open a bug report for this, so that the targetJdk property in the plugin is ignored if the toolVersion is >5 ? Or if not ignored, at least a better error message.

You might want to post something on the development mailing list.