vertx-codegen icon indicating copy to clipboard operation
vertx-codegen copied to clipboard

Add support for Gradle Apt Plugin

Open JakePi3 opened this issue 8 years ago • 4 comments

I already have another package that uses annotation processing (immutables), and it doesn't play nicely with the documented Gradle solution for adding annotation processing.

immutables plugs in directly to the Gradle Apt Plugin (https://github.com/tbroyer/gradle-apt-plugin)

It would be nice if the CodeGen worked similarly for vertx.. I have it working with Warnings only via:

dependencies {
  compileOnly "org.immutables:value:2.4.4:annotations"
  apt group: 'org.immutables', name: 'value', version: '2.4.4'

  compileOnly group: 'io.vertx', name: 'vertx-codegen', version: vertxVersion
  apt group: 'io.vertx', name: 'vertx-codegen', version: vertxVersion
  apt group: 'io.vertx', name: 'vertx-docgen', version: vertxVersion
  apt group: 'io.vertx', name:'vertx-service-proxy', version:vertxVersion, classifier: 'processor'
}

This generates both sets of classes but my gradle output is littered with warnings:

warning: No SupportedSourceVersion annotation found on io.vertx.serviceproxy.ServiceProxyProcessor, returning RELEASE_6. warning: Supported source version 'RELEASE_6' from annotation processor 'io.vertx.serviceproxy.ServiceProxyProcessor' less than -source '1.8'

I have java code and source compatibility set to 1.8 but can't figure out how to feed this in to avoid the warning. Hopefully this is just a documentation issue, would be helpful to add this as an option to the documentation for anyone else using the apt plugin.

JakePi3 avatar Jul 17 '17 15:07 JakePi3

There is also a processor classifier for vertx-codegen, just like vertx-service-proxy.

What if you add:

dependencies {
  apt "io.vertx:vertx-codegen:$vertxVersion:processor"
  // (...)
}

(or even just as a compileOnly configuration, the immutables library generation also works if you add it without the apt plugin).

jponge avatar Jul 17 '17 20:07 jponge

That didn't make any difference, but I do have a suggested fix that I cribbed from antlr:

@Override public SourceVersion getSupportedSourceVersion() {
    return SourceVersion.latestSupported();
  }

Add above to ServiceProxyProcessor (or better yet the parent, CodeGenProcessor)..

The issue stems from this annotation being present on the parent class CodeGenProcessor:

@javax.annotation.processing.SupportedSourceVersion(javax.lang.model.SourceVersion.RELEASE_8)

But annotations are not inherited, so default RELEASE_6 is assigned.

JakePi3 avatar Jul 18 '17 09:07 JakePi3

Gradle 4.6 has a new annotationProcessor configuration that also emits this warning.

thiagogcm avatar Mar 01 '18 01:03 thiagogcm

Gradle 4.6 has a new annotationProcessor configuration that also emits this warning.

@JakePi3 @jponge @thiagogcm @vietj @pmlopes see #181 re. annotationProcessor. When that (#181) is sorted, I guess this issue can be closed, as the Gradle Apt Plugin is superceded by annotationProcessor.

vorburger avatar May 18 '18 10:05 vorburger