-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Separate AutoValue artifacts into an annotation and a processor #250
Comments
This is dictated by the |
A lot of android projects have an associated apt binary:
This makes it quick and easy for developers to integrate it into their project. Any plans on adding this support? It does seem like AutoParcel does this, but might be good to have all developments in once location. Thanks! |
I don't get it. Auto works exactly the same as Dagger as far as declaring your dependencies goes: just add the dependency to the |
As @tbroyer pointed out, using the same strategy as dagger projects, using the plugins from http://code.neenbedankt.com/gradle-android-apt-plugin/ (also found here: https://bitbucket.org/hvisser/android-apt) will let you specify: dependencies { and this should successfully configure gradle and intellij to use auto-values and put the generated files in a place where intellij can find them. |
The annotation is only on the processor path if you do that which means you On Fri, Jun 5, 2015, 9:02 PM Christian Edward Gruber <
|
I'm not sure I follow what you mean, jake? There is no runtime "library" - On Fri, 5 Jun 2015 at 18:08 Jake Wharton [email protected] wrote:
|
The annotation needs to be on the classpath for use. On Fri, Jun 5, 2015, 9:33 PM Christian Edward Gruber <
|
As @JakeWharton pointed out there should be one apt binary and one compile binary. I think the AutoParcel project might be the easiest to illustrate (since it is pretty closely related to this project):
The auto-parcel-processor and the actual annotation auto-parcel |
I don't think the separation of the two libraries is necessary. The compile scoped dependency of auto-parcel only contains annotations that are Also, I can confirm I use Autovalue under provided / apt scope successfully. |
From the android-apt README:
I suppose using In https://github.com/tbroyer/gradle-apt-plugin (for non-android projects), I created a |
The big problem we face with |
@JakeWharton Yup. This is why you want those dependencies of annotation processors to be shaded and "hidden". But indeed having separate artifacts for annotations and processor makes it easier. |
@JakeWharton, ah, that's good point, I hadn't thought of that perspective. Makes the API much more clear and no extra non-runtime dependencies to reference in the IDE. I always figured the apt plugin was only meant for referencing generated code in Android Studio. |
Hmm. We went deliberately with a one artifact approach because of a bias I'd like feedback from folks on what preferred deployment would look like, On Sat, Jun 6, 2015, 17:09 John Ericksen [email protected] wrote:
|
I, for one, am fine with a single artifact approach iff dependencies are all shaded (and hidden from auto complete in IDEs), and of course if there are no runtime dependencies (which would mean the processor is deployed in the runtime classpath). |
Dagger 2 is already a 2 artifact situation because there is a runtime, Autofactory shades everything I think, and autovalue is about to as we On Sun, Jun 7, 2015, 18:48 Thomas Broyer [email protected] wrote:
|
Android (and I) prefer the Dagger 2 approach. This allows us to keep the On Sun, Jun 7, 2015, 7:48 PM Thomas Broyer [email protected] wrote:
|
Even when the contents of the "dependency" is a source only annotation? Though given that you have to go through the motions in gradle, it seems no On Sun, Jun 7, 2015, 18:58 Jake Wharton [email protected] wrote:
|
Not arguing strongly here, just trying to hone in on the best policy to On Sun, Jun 7, 2015, 19:04 Christian Gruber [email protected] wrote:
|
Correct me if I'm wrong, Shading only obfuscates the package, it would be easy to accidentally autocomplete a Guava class by just class name.. right? |
Yes, though I believe naming the package starting with $ helps fix that, in On Sun, Jun 7, 2015, 19:06 John Ericksen [email protected] wrote:
|
I'll throw a vote in for the Dagger 2 approach. Pros: API usability in the IDE around the APT scope, Cons: the user might miss the compiler dependency. If a user misconfigures the compiler dependency wouldn't it result in a failed build? With the added push of at least one Android extension (#202) puts some emphasis on the Android side of things. |
Fair point about compilation failures. On Sun, Jun 7, 2015, 19:15 John Ericksen [email protected] wrote:
|
Yes, even if it is a single source-only annotation. It needs to be on the On Sun, Jun 7, 2015, 8:17 PM Christian Edward Gruber <
|
Sorry... The question included the premise that we fix the plugin to make But yeah. It's probably just easier to extract the annotation. Sigh. The On Sun, Jun 7, 2015, 19:57 Jake Wharton [email protected] wrote:
|
I'm just bummed as it adds boilerplate to the Maven case. On Sun, Jun 7, 2015, 20:28 Christian Gruber [email protected] wrote:
|
It's not strictly the Maven case. The build system is irrelevant. It's the case where you don't care about your classpath or what's in your final artifact. Not sure how you'd classify it, but for the purposes of discussion it's the JVM service case. |
Separating the annotation from the processing is a very sounded choice in my opinion. It's not impossible that somebody would like to depend just on ˋgoogle.auto.value.annotationˋ and provide his own implementation for the processor (to do something that we can't forsee at the moment). In the early days of my fork having the annotation as a separate dependency would have been great: the users that now are using auto-parcel would have been using the same annotation with a different processor and migrating to this new version would have been seemless without them even noticing. Shipping a repo with just the annotation means that you can mark your classes with AutoValue and maybe package them as a library and let the consumer decide what processor to use (another far fetched example, but still). I just see so many potentials wins with this move with relatively little cost. Plus, since ˋgoogle.auto.value.processorˋ would depend on the annotation, if you're not using Android Studio you just need to add the processor as a provided dependency and you're done, no reason to know the other artefact exists. |
Seems to have ended up as a duplicate of #268. |
Is there a good way to direct generated output to a different directory than [build_folder]/intermediates/classes.... This gets a bit messy from using it in the IDE and linking to a build output folder as a src directory.
The text was updated successfully, but these errors were encountered: