I have a project composed of several BUCK modules. Each module uses the same annotation processor to generate a single file for each annotated class. For the sake of simplicity, for each annotated class:
package com.myproject.module1;
@Marker
public class SomeFoo {
// ... code ...
}
a single class will be generated in the same package:
package com.myproject.module1;
@Generated
public class SomeFoo$$Marker {
// ... generated code ...
}
Let's say I have two such modules: module1
and module2
Lastly, I have a module3
which is dependent on both above-mentioned modules.
This module contains another annotation:
package com.myproject.module3;
@MarkerCollector
public class Bar {
}
I'm trying to use the same annotation processor (could be a separate one as well), to generate a class that references all previously generated files (due to classes marked with @Marker
.
The problem is that the annotation processor runs for each module separately , when run in module3, the annotation processor doesn't 'see' the files generated in other modules .
I've tried using the annotation processor's Filer
to create a resource file and write the class names of all generated files, but this resource file is too, created per module .
What's the best way to aggregate/access generated code from different modules?
If you are working with gradle you can create a JavaCompile
task and configure it as I did here . My project was targeting android so you will see variant
just make sure you put your classPath there instead 🤓
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.