annotation-processing

Annotation Processor in IntelliJ and Gradle

爷,独闯天下 提交于 2019-11-28 02:36:19
问题 tl;dr : I cannot configure IntelliJ to generate the java files in the same directory as gradle I have a small project which uses the immutables annotation processor. It works as expected in the gradle command line build, but I cannot get IntelliJ to output the generated files to the same directory. The full project is available on GitLab Gradle config : I use the folowing gradle plugins: gradle-idea plugin which handles the idea configuration gradle-apt-plugin which provides the apt

Specifying order of annotation processors

一个人想着一个人 提交于 2019-11-27 20:06:24
I'm trying to run Dagger 2 as well as Lombok on my Java project. Lombok has to run first, of course, but whether it actually does seems to be up to chance. At first I suspected I could specify the order by the respective position of the library jars in the class path, but that order evidently gets ignored. Is there a way to specify the order for them to run somehow, or do I simply have to live with not being able to combine two APs ? I have produced an SSCCE test case . A simple git clone & mvn compile is enough to demonstrate the issue - if you comment line 18 and uncomment lines 20-21 in App

Gradle + Annotations + Flavors = won't run annotations processor

最后都变了- 提交于 2019-11-27 17:42:25
问题 I have a Gradle build script that is using an annotations processor (Android Annotations) to generate code. Building was fine until I added a new Pro Flavor. I can build the Free flavor but when I build the Pro flavor the annotations processor isn't run. This causes missing code and the build fails. Here is my script: buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } } dependencies { classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android'

Code replacement with an annotation processor

半世苍凉 提交于 2019-11-27 11:42:52
I'm trying to write an annotation processor to insert methods and fields on a class... and the documentation is so sparse. I'm not getting far and I don't know if I'm approaching it correctly. The processing environment provides a Filer object which has handy methods for creating new source and class files. Those work fine but then I tried to figure out how read the existing source files, and all it provides is "getResource". So in my Processor implementation I've done this: @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { try { for

What is the default annotation processors discovery process?

我的未来我决定 提交于 2019-11-27 07:53:10
The documentation of Maven Compiler plugin mentions the following : annotationProcessors: Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies. What is the default annotation processors discovery process here? Is there any other way to set up annotation processors than this configuration tag? I've found that the Getting Started with the Annotation Processing Tool (apt) documentation mentions a default discovery procedure , but it works with factory classes not processors and unfortunately it uses the tools.jar

Accessing source code from Java Annotation Processor

对着背影说爱祢 提交于 2019-11-27 05:35:53
问题 I am trying to access the actual original source code of a type from within a Java Annotation Processor. Is this possible somehow? Thanks! 回答1: I had a problem where I had to access some source code (the initializer code for a non-String/non-primitive constant) and got it solved by accessing the source code via the Compiler Tree API. Here's the general recipe: 1. Create a custom TreePathScanner: private static class CodeAnalyzerTreeScanner extends TreePathScanner<Object, Trees> { private

Java Generics: Accessing Generic Type at runtime

自作多情 提交于 2019-11-27 01:38:52
问题 I'm looking to access the generic type of a declared field during runtime. I was previously under the impression that this was not possible due to the Java type erasure. However, this must not be the case because some well known frameworks leverage the generic type through reflection during runtime. As an example, Guice will implement a Provider based upon the generic type you provide: public class Injectable{ @Inject private Provider<SomeType> someTypeProvider; } How does one access the

Specifying order of annotation processors

霸气de小男生 提交于 2019-11-26 20:09:32
问题 I'm trying to run Dagger 2 as well as Lombok on my Java project. Lombok has to run first, of course, but whether it actually does seems to be up to chance. At first I suspected I could specify the order by the respective position of the library jars in the class path, but that order evidently gets ignored. Is there a way to specify the order for them to run somehow, or do I simply have to live with not being able to combine two APs ? I have produced an SSCCE test case. A simple git clone &

What is the default annotation processors discovery process?

江枫思渺然 提交于 2019-11-26 13:52:14
问题 The documentation of Maven Compiler plugin mentions the following: annotationProcessors: Names of annotation processors to run. Only applies to JDK 1.6+ If not set, the default annotation processors discovery process applies. What is the default annotation processors discovery process here? Is there any other way to set up annotation processors than this configuration tag? I've found that the Getting Started with the Annotation Processing Tool (apt) documentation mentions a default discovery

How to generate JPA 2.0 metamodel?

一个人想着一个人 提交于 2019-11-26 12:04:21
In the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know). EDIT: Just stumbled across Hibernate JPA 2 Metamodel Generator . But the issue remains since I can't find any download links for the jar. EDIT 2: