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

Gradle 3.3 -> 3.4 Annotation Processor not called in JavaCompile Task #1471

Closed
ralfeis opened this issue Feb 27, 2017 · 6 comments
Closed

Gradle 3.3 -> 3.4 Annotation Processor not called in JavaCompile Task #1471

ralfeis opened this issue Feb 27, 2017 · 6 comments
Assignees
Milestone

Comments

@ralfeis
Copy link

ralfeis commented Feb 27, 2017

If I use the JavaCompile Task with compilerArgs Options, then the Annotation Processor "SQLProcessor" is not called anymore. With gradle 3.0,3.1,3.2, 3.3 it is working. With gradle 3.4 it seems to be broken.

The Java source files and the annotation processor are in the same project.

Expected Behavior

Same result as with gradle 3.3.

Current Behavior

Annotation Processor is not called anymore.

Context

Steps to Reproduce (for bugs)

This task does not call the Annotation Processor anymore.

task generateSQLConst (type: JavaCompile) {
   description = "Creates SQL Constants"
   destinationDir = file("$buildDir/classes/sql")
   source = file("$projectDir/src/de/")
   includes = ['**/*.java']
   classpath = sourceSets.main.output + configurations.compile + configurations.provided
   options.compilerArgs = ['-processor', 'de.util.annotation.SQLProcessor']
}

Your Environment

Java 7, Gradle 3.4

@oehme
Copy link
Contributor

oehme commented Feb 28, 2017

Could you please push a reproducible example to GitHub? That would make it easier for us to fix the problem.

@oehme
Copy link
Contributor

oehme commented Feb 28, 2017

I think I know what the issues is though: Your annotation processor is missing the processor configuration file (META-INF/services/javax.annotation.processing.Processor, see javac documentation). Gradle 3.4 scans for these configuration files and passes the proc:none flag if it doesn't find any.

Apparently javac allows you to use a processor with the explicit -processor flag even if it does not have a valid processor configuration file. So I guess Gradle should be lenient in this case as well.

As a workaround, add a processor configuration file for your processor. That way you don't have to pass -processor anymore, making your task setup simpler.

@oehme oehme added this to the 3.5 RC1 milestone Feb 28, 2017
@oehme
Copy link
Contributor

oehme commented Feb 28, 2017

@melix This should be a simple fix we can do between branching and 3.5-RC-1. We need to check for an explicit -processor flag here.

@ralfeis
Copy link
Author

ralfeis commented Feb 28, 2017

Thanks for your fast reply.

Your solution proposal worked for us. We added META-INF/services/javax.annotation.processing.Processor and removed the "-processor" flag.

melix added a commit that referenced this issue Mar 10, 2017
…on is passed

This commit fixes #1471 by making sure that if `-processor` is passed to the compiler options,
then we use the right classpath: compile classpath is no explicit `-processorpath` is used, and
processorpath otherwise.
@melix
Copy link
Contributor

melix commented Mar 10, 2017

@oehme can you take a quick look at the fix above and close this issue if you are happy with it?

melix added a commit that referenced this issue Mar 10, 2017
We can return the compile classpath directly.
@oehme
Copy link
Contributor

oehme commented Mar 10, 2017

LGTM

@oehme oehme closed this as completed Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants