jaredsburrows/gradle-checker-framework-plugin

Issues when put in plugins block

Closed this issue · 6 comments

* What went wrong:
An exception occurred applying plugin request [id: 'com.jaredsburrows.checkerframework', version: '0.2.1']
> Failed to apply plugin [id 'com.jaredsburrows.checkerframework']
   > Checker plugin can only be applied to android or java projects.

This happens with both

apply plugin: 'java'

and

plugins {
id 'java'
}

What version of Java are you using? It only works with Java 7/8 and/or Android projects.

    def jdkVersion
    if (JavaVersion.current().java7) {
      jdkVersion = ANNOTATED_JDK_NAME_JDK7
    } else if (JavaVersion.current().java8) {
      jdkVersion = ANNOTATED_JDK_NAME_JDK8
    } else {
      throw new IllegalStateException("Checker plugin only supports Java 7 and Java 8 projects.")
    }

I was using Java 8 u 171 at the time it occurred, all my projects require Java 8 too.

I'm also experiencing the issue...a new version just needs to be released please (preferably also including #12 😉) .

The last released version of this is very old and predates
a7cc979. Using a locally published copy of newer code with an appropriate pluginManagement configuration shows that this specific error no longer applies.

The update code no longer breaks but also doesn't apply the plugin, working on a fix.

@jaredsburrows is there any strong reason this plugin tries to detect whether other plugins have been applied rather than just applying the java plugin itself? The latter approach seems like it would simplify the associated logic a bit without any obvious impacts (aside from avoiding no-op behavior). An alternative solution to this problem would likely involve introducing a listener which would slide a bit more complexity into this.

Ignore the previous comment, I was glossing over some of the later code around integration differences and including the existing listener. The updated PR moves the rest of the logic to that hook which avoids this issue without introducing notable overhead.