I should also point out that AutoValue pulls in AutoService [1] as a
dependency. FTW!

AutoService will generate the appropriate service loader metadata using a
simple annotation:

  @AutoService(ApiMetadata.class)
  public class SwiftApiMetadata extends BaseHttpApiMetadata<SwiftApi> {}

I prototyped this last month just using AutoService, however I ran into
some issues with Maven not copying the generated file from target/classes
into the jar at assembly. Maybe someone could shed some light on how to
get the Maven resources plugin to play nicely at the correct phase?

By using the @AutoService annotation for ApiMetadata and ProviderMetadata
classes, we effectively remove ~120 files from the codebase, and ~360
source directories [2]. This type of metadata file should be autogen¹d as
part of the build anyway.

Food for thought.

/jd

[1] https://github.com/google/auto/tree/master/service
[2] /main/resources/META-INF/services/

On 10/16/14, 11:08 AM, "Jeremy Daggett" <jeremy.dagg...@rackspace.com>
wrote:

>Hi dev@,
>
>There has been some recent discussion around the usage of AutoValue [1]
>in jclouds. Over the past couple of days, I have been prototyping with it
>in the OpenStack Heat API.  I realize that this is far from being
>complete, however I am pretty excited about it and wanted to share what I
>have been able to accomplish so far.
>
>To start, I wasn¹t quite sure how to integrate Gson and AutoValue, but
>luckily I found this Gist [2]. Thanks Jake!
>
>I was able to get the prototype up and running with some fairly trivial
>changes using the above Gist code:
>
>in jclouds/core:
>- Added the `AutoGson` class to `org.jclouds.rest.annotations` package
>- Added the `AutoValueTypeAdapterFactory` class to
>`org.jclouds.json.internal`
>- Register the above `TypeAdapterFactory` in
>`org.jclouds.json.config.GsonModule`
>
>In jclouds-labs-openstack/openstack-heat:
>- Created a simple `AutoStack` class with AutoValue/AutoGson annotations
>and provided necessary methods.
>- Added a test to the `StackApiMockTest` to test parsing of the JSON.
>
>The good news is that the test ran successfully through the jclouds
>codebase.  I ran into some weirdness with the mapping of the snakey case
>method names to non-snakey case field names. We usually annotate the
>fields using @Named, but how do you do that?  HmmŠ More investigation
>necessary.
>
>As it stands, I was only able to get it to map the JSON correctly using
>janky looking snaky-methods due to the way it generates the code. I am
>currently blocked because of this, so if anyone has insight here, please
>share.
>
>Check out this gist [3] if you are interested in this WIP, thanks!
>
>/jd
>
>[1] https://github.com/google/auto/tree/master/value
>[2] https://gist.github.com/JakeWharton/0d67d01badcee0ae7bc9
>[3] https://gist.github.com/jdaggett/11c746ccb257842d5cb5
>

Reply via email to