Add a IDE helper plugin for annotation processors

Without the net.ltgt.apt plugin, Dagger does not retain generated source code,
and AutoValue mixes generated source code with classes. The new plugin fixes this
problem, making it easier to work with IDEs.

Based on limit experience, Intellij Idea can properly import this project. We
may consider adding IDE-specific plugins in the future.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=220802052
This commit is contained in:
weiminyu 2018-11-09 07:55:53 -08:00 committed by jianglai
parent 9312cb3936
commit 783c010ab4
2 changed files with 17 additions and 2 deletions

View file

@ -1,6 +1,10 @@
plugins {
id 'java'
id 'nebula.lint' version '10.1.2'
// Config helper for annotation processors such as AutoValue and Dagger.
// Ensures that source code is generated at an appropriate location.
id 'net.ltgt.apt' version '0.19'
}
allprojects {
@ -23,6 +27,8 @@ allprojects {
'unused-dependency'
// TODO(weiminyu): enable more dependency checks
]
apply plugin: 'net.ltgt.apt'
}
project(':core') {

View file

@ -5,13 +5,22 @@ plugins {
def javaDir = "${rootDir}/../java"
def javatestsDir = "${rootDir}/../javatests"
def generatedDir = "${project.buildDir}/generated-sources"
// Path to code generated with annotation processors. Note that this path is
// chosen by the 'net.ltgt.apt' plugin, and may change if IDE-specific plugins
// are applied, e.g., 'idea' or 'eclipse'
def aptGeneratedDir = "${project.buildDir}/generated/source/apt/main"
def aptGeneratedTestDir = "${project.buildDir}/generated/source/apt/test"
// Path to code generated by ad hoc tasks in this project. A separate path is
// used for easy inspection.
def generatedDir = "${project.buildDir}/generated/source/custom/main"
sourceSets {
main {
java {
srcDirs = [
"${javaDir}",
"${aptGeneratedDir}",
"${generatedDir}"
]
}
@ -26,7 +35,7 @@ sourceSets {
java {
srcDirs = [
"${javatestsDir}",
"${generatedDir}"
"${aptGeneratedTestDir}"
]
}
resources {