Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There should be a way to pass options to annotation processors #430

Open
gbl opened this issue Apr 24, 2019 · 2 comments
Open

There should be a way to pass options to annotation processors #430

gbl opened this issue Apr 24, 2019 · 2 comments

Comments

@gbl
Copy link

gbl commented Apr 24, 2019

I have a project that uses annotations, with an annotation processor that needs some configuration. The Gradle plugin itself uses several "-AX=Y" options to pass this configuration to the compiler.

NetBeans with the netbeans-gradle-project plugin finds the annotation processor and seems to call it when syntax-checking editor contents, but without those options, which results in the processor emitting warnings/errors, which in turn get marked as errors in the editor.

As far as I can tell, the org/netbeans/gradle/project/java/query/GradleAnnotationProcessingQuery.java file is responsible for configuring the annotation processor, and as that class has a processorOptions() method which always returns an empty map, there's no configuration option, not even a hard-to-find or hidden one, to configure those options.

Unfortunately, I know way too little about the netbeans ecosystem to create a PR myself, but I hope this won't be too hard to implement for someone who does.

@kelemen
Copy link
Owner

kelemen commented Apr 26, 2019

How are you setting it? Through the CompileOptions.compilerArgs? Anyway, if something is readable from the Gradle script, then it can be done with relatively little pain.

@gbl
Copy link
Author

gbl commented Apr 27, 2019

I don't really understand a lot about Gradle, I'm just using somebody's script from here: https://github.com/FabricMC/fabric-loom

That thing has, in AbstractPlugin.java (I amended some logging):

						project.getLogger().lifecycle(":setting java compiler args");
						try {
							javaCompileTask.getOptions().getCompilerArgs().add("-AinMapFileNamedIntermediary=" + extension.getMappingsProvider().MAPPINGS_TINY.getCanonicalPath());
							javaCompileTask.getOptions().getCompilerArgs().add("-AoutMapFileNamedIntermediary=" + extension.getMappingsProvider().MAPPINGS_MIXIN_EXPORT.getCanonicalPath());
							javaCompileTask.getOptions().getCompilerArgs().add("-AoutRefMapFile=" + new File(javaCompileTask.getDestinationDir(), extension.getRefmapName()).getCanonicalPath());
							javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=named:intermediary");
						} catch (IOException e) {
							e.printStackTrace();
						}
                        project.getLogger().lifecycle(String.join("\n",javaCompileTask.getOptions().getCompilerArgs()));

Of course it would be great if the netbeans plugin could catch these options when it runs a build. But a way to input them manually, like the annotation processor input box in standard ant netbeans projects (project/properties/compiling) would be greatly appreciated as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants