Comments (6)
With the current additions to IntelliJ (https://www.jetbrains.com/idea/whatsnew/#v2016-3-gradle), I'm now using Auto-Value + Gradle in IntelliJ by importing the projects like this:
- Open the project directory.
- Select Import Gradle Project.
- Uncheck "Create separate modules per source set".
- Select Settings → Build, Execution, Deployment → Build Tools → Gradle → Runner → Delegate IDE build/run actions to gradle.
- Perform an initial Gradle build (you can either run it from within IntelliJ or on the CL via gradlew).
- Mark
build/generated/source/apt/main
as a "Generated Sources Root" (right click on the directory → Mark Directory as → Generated Sources Root).
from auto.
we ended up using a plugin to enable this for our IDEs: https://github.com/palantir/gradle-processors
from auto.
Finally able to get everything hooked up, here are the details:
OSX 10.9.2
Intellij 13.1.2 Build #IC 135.690 April 17, 2014
built with gradle 1.12
build.gradle: compile group: 'com.google.auto.value', name: 'auto-value', version: '1.0-rc1'
1:
Properties -> Compiler -> Annotation Processors
check 'Enable annotation processors'
Set 'Store generated sources relative to': Module content root
2: use step b if you are using gradle, otherwise use step a.
a. Module Settings (-> Sources
right click ~/src/my-project/generated and set as source folder
b. It appears that the gradle plugin is overwriting my IDE settings on refresh, removing my addition of the generated folder as a source folder. To get the module source setting to stick, I did the following:
build.gradle: srcDir is additive, so the default srcDir is preserved. The exclude is required because gradle will perform the annotation processing. We are just adding the srcDir tag for the gradle ide integration, gradle will compile successfully without this (but your ide will be busted).
sourceSets.main.java {
srcDir 'generated'
exclude '*/AutoValue.java'
}
3:
Properties -> Compiler -> Excludes
add processor annotation output dir as recursive exclude
ex: ~/src/my-project/generated (recursive)
Explanation:
I'm using gradle with a parent project hierarchy. I was unable to convince the ide to add just the /generated subfolder as a source folder until I had the annotation sources generated outside the project build folder. After taking these two steps (move annotation processor build folder and make it a module source folder), the compiler started failing with a duplicate class error. This is because the annotation processor re-generates the code file, then the compiler tries to process the generated file (because we added it as a source). After excluding the generated folder from the compiler everything is happy (almost).
from auto.
is there a way to turn on annotation processors using the gradle idea plugin?
having a clean gradle script i can just include to make this all happen would be wonderful!
assuming i can get annotations to be kept to the generated classes, i'd be willing to look into good clean intellij/gradle support :)
from auto.
Is there some documentation to add autovalue 1.2 manually to an eclipse project. The link in the blog post above was useful but its pretty outdated and deals with the initial release of autovalue.
from auto.
Here's an approach that automates most of the configuration from the build file. With some help from this post. In this approach, the annotation processor parts of gradle are picked up and passed into intellij's configuation. Also, the generated sources folded is injected into the configuration. For some reason using the idea plugin generatedSourceDirs
doesnt work, so it is just marked as sources.
In this configuration you MUST still uncheck "Create separate modules per source set" when using this. (Haven't figured out how to auto configure this)
idea {
project {
ipr {
withXml { provider ->
// Get XML as groovy.util.Node to work with.
def projectXml = provider.asNode()
// Find compiler configuration component.
def compilerConfiguration = projectXml.component.find { component ->
component.'@name' == 'CompilerConfiguration'
}
// Replace current annotationProcessing
// that is part of the compiler configuration.
def currentAnnotationProcessing = compilerConfiguration.annotationProcessing
currentAnnotationProcessing.replaceNode {
annotationProcessing {
profile(name: 'Default', default: true, enabled: true) {
processorPath(useClasspath: false) {
// find all annotation processors on from gradle config and
// add them as entries to the intellij config
project.configurations.annotationProcessor.each {
entry(name:"$it.path")
}
}
}
}
}
}
}
}
module {
// add the generated sources directory as a sourceDir (should be
// wherever the intellij compiler is spitting out your autovalue files).
sourceDirs += file("out/production/classes/generated")
}
}
from auto.
Related Issues (20)
- Renaming nested builders HOT 2
- Library has Kotlin runtime bundled into it HOT 3
- Cannot resolve symbol 'AutoBuilder' HOT 1
- AutoFactory checkNotNull index in error message is 1-indexed, despite java being 0-indexed HOT 5
- AutoService should verify presence of a no-argument public constructor HOT 8
- ServiceLoader$LazyIterator.nextService NullPointerException HOT 2
- noSuchElementException HOT 3
- AutoService breaks with Immutables HOT 8
- Shaded guava triggers CVE checks HOT 1
- AutoValue functional tests not being run by Maven
- Intermittent `Stream closed` exception after upgrading to 1.10.2 HOT 16
- auto-value 1.10.2 breaks compatibility with Kotlin 1.6 HOT 8
- AutoBuilder will not build Kotlin data class with Duration HOT 3
- Require Java 11+ for compilation HOT 1
- Use Jakarta's @Generated annotation if available HOT 2
- AutoValue `toBuilder()` works poorly if an extension subclasses `Builder`; possible INCOMPATIBLE change HOT 1
- Android does not use AutoService. See the example code HOT 2
- Is cross-process support available? HOT 3
- Release AutoFactory 1.1.0 HOT 1
- Remove `o == this` check from generated `equals`? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auto.