I made a small zip example to illustrate the issue.
I have in the project the Animal class from AutoValue example and a maven pom file to do the code generation and compilation. See below.
Running mvn clean install
works great and generates and compiles everything into target/classes
:
The problem is that IntelliJ doesn't recognize AutoValue_Animal
:
So how to make IntelliJ IDEA recognize build-time generated sources?
* Preferably, without needing to change IDEA specific setting, in order to keep the dev env consolidated around Maven.
Class:
package kilaka;
import com.google.auto.value.AutoValue;
@AutoValue
public abstract class Animal {
static Animal create(String name, int numberOfLegs) {
// See "How do I...?" below for nested classes.
return new AutoValue_Animal(name, numberOfLegs);
}
abstract String name();
abstract int numberOfLegs();
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kilaka</groupId>
<artifactId>auto-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>