I tried to find the correct settings for processing IntelliJ annotations so that it coexisted with the Gradle build process.
Whenever I build from IntelliJ, I cannot get it to recognize the generated sources from the gradle-apt-plugin plugin .
My requirements for my project:
- The construction between IntelliJ and Gradle should be seamless and not interfere with each other's process.
- I need to use IntelliJ. Create a separate module for each source set option.
- I need to use IntelliJ folder structure
- IntelliJ should be able to recognize and automatically populate AutoValue classes
Here are the steps for MCVE to reproduce the issue with IntelliJ 2017.2.4 and Gradle 3.5:
- Create a new Gradle project from IntelliJ
- Check the box next to "Create a separate module for each source."
- Open the build.gradle file:
- Add the following block
plugins
:
plugins {
id 'java'
id 'net.ltgt.apt' version '0.12'
}
- Add the following block
dependencies
dependencies {
compileOnly 'com.google.auto.value:auto-value:1.5'
apt 'com.google.auto.value:auto-value:1.5'
}
- Go to Settings → Build, Run, Deploy → Annotation Processors.
- Check enable annotation processing
- Create class:
@AutoValue
public abstract class GeneratedSourcesTest {
static GeneratedSourcesTest create(String field) {
return new AutoValue_GeneratedSourcesTest(field);
}
public abstract String field();
}
- On IntelliJ, run Build -> Build Project
- Open the class
GeneratedSourcesTest
, everything is fine in the static factory method, but I get an error:
cannot resolve symbol 'AutoValue_GeneratedSourcesTest
How to make a class AutoValue_GeneratedSourcesTest
accessible from IntelliJ?
Jaiye source
share