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

Extensibility #237

Merged
merged 20 commits into from Aug 7, 2015

Conversation

Projects
None yet
5 participants
@rharter
Contributor

rharter commented May 15, 2015

This is a first pass implementation of issue #202, providing two options for extending AutoValue through the use of compile time plugins.

The first method, is by having your extension create an intermediate class between the abstract template class and the final AutoValue implementation of the class. The provides a good mechanism for adding functionality to an AutoValue class, while still keeping the implementation segregated.

The second method is to alter the final AutoValue class itself. This was required to support Android Parcelable implementations, as Parcels are required to have static factory objects, and this isn't achievable via inheritance. Using this method, extensions have to option of adding imports, interfaces and code to the resulting AutoValue class implementation. You can see a working example of one such plugin here.

You can view a test Android app that makes use of the auto-parcel extension here.

@googlebot

This comment has been minimized.

Show comment
Hide comment
@googlebot

googlebot May 15, 2015

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

googlebot commented May 15, 2015

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot googlebot added the cla: no label May 15, 2015

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter May 15, 2015

Contributor

I signed it!

Contributor

rharter commented May 15, 2015

I signed it!

@googlebot

This comment has been minimized.

Show comment
Hide comment
@googlebot

googlebot May 15, 2015

CLAs look good, thanks!

googlebot commented May 15, 2015

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels May 15, 2015

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus May 15, 2015

Contributor

I think the Travis failure indicates that you need to merge in recent changes.

Contributor

eamonnmcmanus commented May 15, 2015

I think the Travis failure indicates that you need to merge in recent changes.

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Jul 2, 2015

Contributor

@eamonnmcmanus I think this is in a good state to check out. To see an example of a working extension implementation, check out my auto-parcel code.

I'm still having a problem with my Parcelable extension in that the annotated class has to implement the Parcelable interface, but AutoValue takes the int describeContents() method from the interface to be something that it should generate. I understand the need to include inherited abstract methods in the properties list, but I'm not sure how to tell AutoValue that it doesn't need to worry about this particular interface method with no parameters that returns an int. For now, I'm working around this by simply implementing the super simple version in my annotated class. The generated class also generates an implementation.

Contributor

rharter commented Jul 2, 2015

@eamonnmcmanus I think this is in a good state to check out. To see an example of a working extension implementation, check out my auto-parcel code.

I'm still having a problem with my Parcelable extension in that the annotated class has to implement the Parcelable interface, but AutoValue takes the int describeContents() method from the interface to be something that it should generate. I understand the need to include inherited abstract methods in the properties list, but I'm not sure how to tell AutoValue that it doesn't need to worry about this particular interface method with no parameters that returns an int. For now, I'm working around this by simply implementing the super simple version in my annotated class. The generated class also generates an implementation.

String packageName();
/**
* The annotated class that this generation cycle is based on.

This comment has been minimized.

@eamonnmcmanus

eamonnmcmanus Jul 8, 2015

Contributor

Maybe add a sentence to make it crystal clear, like this:

 * Given {@code @AutoValue public class Foo {...}}, this will be {@code Foo}.
@eamonnmcmanus

eamonnmcmanus Jul 8, 2015

Contributor

Maybe add a sentence to make it crystal clear, like this:

 * Given {@code @AutoValue public class Foo {...}}, this will be {@code Foo}.
@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Jul 31, 2015

Contributor

Sorry, I guess I didn't comment when those were resolved, but they should all be resolved in the commits from that same day.

Contributor

rharter commented Jul 31, 2015

Sorry, I guess I didn't comment when those were resolved, but they should all be resolved in the commits from that same day.

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Jul 31, 2015

Contributor

OK, I'll take a look later today. Sorry about the misunderstanding.

Contributor

eamonnmcmanus commented Jul 31, 2015

OK, I'll take a look later today. Sorry about the misunderstanding.

/**
* An AutoValueExtension allows for extra functionality to be created during the generation
* of an AutoValue class.

This comment has been minimized.

@eamonnmcmanus

eamonnmcmanus Jul 31, 2015

Contributor

Can you add a sentence:
NOTE: the design of this interface is not final and subject to change.

@eamonnmcmanus

eamonnmcmanus Jul 31, 2015

Contributor

Can you add a sentence:
NOTE: the design of this interface is not final and subject to change.

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Jul 31, 2015

Contributor

I'm expecting @cgruber to make a PR shortly that will export Google's internal changes. Merging with those changes won't be too hard, I hope, and after that I think we should be good to go.

Contributor

eamonnmcmanus commented Jul 31, 2015

I'm expecting @cgruber to make a PR shortly that will export Google's internal changes. Merging with those changes won't be too hard, I hope, and after that I think we should be good to go.

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Aug 1, 2015

Contributor

Changes are in. I think that erroneous empty file is the result of a test and was added through a careless git add .. Seems wrong that tests would create stuff outside the target dir.

Contributor

rharter commented Aug 1, 2015

Changes are in. I think that erroneous empty file is the result of a test and was added through a careless git add .. Seems wrong that tests would create stuff outside the target dir.

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Aug 4, 2015

Contributor

Regarding the erroneous file, it must have been created by AutoAnnotationCompilationTest. That creates the file using File.createTempFile — is it possible that your system creates temporary files in the current directory??

Contributor

eamonnmcmanus commented Aug 4, 2015

Regarding the erroneous file, it must have been created by AutoAnnotationCompilationTest. That creates the file using File.createTempFile — is it possible that your system creates temporary files in the current directory??

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Aug 5, 2015

Contributor

That's certainly possible. My system is a Mac, I haven't tested the default File.createTempFile functionality there.

Contributor

rharter commented Aug 5, 2015

That's certainly possible. My system is a Mac, I haven't tested the default File.createTempFile functionality there.

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Aug 5, 2015

Contributor

Meanwhile we're running into issues merging in the latest Google changes. Those changes are unfortunately more extensive than I thought, so you might be in for a bit of merging work when they go in. I'm reluctant to merge this PR first, though, for fear of making that other merge even worse.

Contributor

eamonnmcmanus commented Aug 5, 2015

Meanwhile we're running into issues merging in the latest Google changes. Those changes are unfortunately more extensive than I thought, so you might be in for a bit of merging work when they go in. I'm reluctant to merge this PR first, though, for fear of making that other merge even worse.

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Aug 5, 2015

Contributor

Could you resolve the merge conflicts? Then I'll have another look. Hopefully Travis issue travis-ci/travis-ci#4621 will be solved soon so we'll be able to get a correct indication of test status.

Contributor

eamonnmcmanus commented Aug 5, 2015

Could you resolve the merge conflicts? Then I'll have another look. Hopefully Travis issue travis-ci/travis-ci#4621 will be solved soon so we'll be able to get a correct indication of test status.

Merge branch 'master' into extensibility
Conflicts:
	value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java
	value/src/main/java/com/google/auto/value/processor/BuilderSpec.java
@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Aug 5, 2015

Contributor

Merged and passing tests locally.

Contributor

rharter commented Aug 5, 2015

Merged and passing tests locally.

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Aug 6, 2015

Contributor

@eamonnmcmanus Does that bug cause Travis to hang? Shows that it's still building after 5 hours.

Contributor

rharter commented Aug 6, 2015

@eamonnmcmanus Does that bug cause Travis to hang? Shows that it's still building after 5 hours.

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Aug 6, 2015

Contributor

Seems Travis has been very slow of late. I waited about as long as that yesterday for a build.

Contributor

eamonnmcmanus commented Aug 6, 2015

Seems Travis has been very slow of late. I waited about as long as that yesterday for a build.

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Aug 7, 2015

Contributor

Looks like Travis is back up and all checks pass.

Contributor

rharter commented Aug 7, 2015

Looks like Travis is back up and all checks pass.

eamonnmcmanus added a commit that referenced this pull request Aug 7, 2015

Merge pull request #237 from rharter/extensibility
Add an initial version of the Extensibility API to AutoValue.

@eamonnmcmanus eamonnmcmanus merged commit 068717f into google:master Aug 7, 2015

2 checks passed

cla/google All necessary CLAs are signed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Aug 7, 2015

Contributor

Thanks for your patience with this!

Contributor

eamonnmcmanus commented Aug 7, 2015

Thanks for your patience with this!

@frankiesardo

This comment has been minimized.

Show comment
Hide comment
@frankiesardo

frankiesardo Aug 9, 2015

Thank you both this CR is well worth the wait!

frankiesardo commented Aug 9, 2015

Thank you both this CR is well worth the wait!

@eamonnmcmanus

This comment has been minimized.

Show comment
Hide comment
@eamonnmcmanus

eamonnmcmanus Aug 10, 2015

Contributor

@frankiesardo are you able to obtain the same results with this as with your @AutoParcelable fork?

Contributor

eamonnmcmanus commented Aug 10, 2015

@frankiesardo are you able to obtain the same results with this as with your @AutoParcelable fork?

@frankiesardo

This comment has been minimized.

Show comment
Hide comment
@frankiesardo

frankiesardo Aug 11, 2015

I pushed a branch that uses the new Extension api. So far so good.

The only problem is related to the Parcelable interface method int describeComponents() as @rharter already pointed out here rharter/auto-value-parcel@bfaba14#commitcomment-12614380).

Forcing the user to implement it, even if it's a simple method, it's an annoyance. Not sure if AutoValue can do something about it.

frankiesardo commented Aug 11, 2015

I pushed a branch that uses the new Extension api. So far so good.

The only problem is related to the Parcelable interface method int describeComponents() as @rharter already pointed out here rharter/auto-value-parcel@bfaba14#commitcomment-12614380).

Forcing the user to implement it, even if it's a simple method, it's an annoyance. Not sure if AutoValue can do something about it.

@frankiesardo

This comment has been minimized.

Show comment
Hide comment
@frankiesardo

frankiesardo Aug 11, 2015

In #202 you mention briefly the possibility for an extension to claim a list of abstract methods. That would be helpful in this case.

frankiesardo commented Aug 11, 2015

In #202 you mention briefly the possibility for an extension to claim a list of abstract methods. That would be helpful in this case.

@rharter

This comment has been minimized.

Show comment
Hide comment
@rharter

rharter Aug 11, 2015

Contributor

I'm working on that.

On Tue, Aug 11, 2015, 3:36 PM Frankie Sardo notifications@github.com
wrote:

In #202 #202 you mention briefly
the possibility for an extension to claim a list of abstract methods. That
would be helpful in this case.


Reply to this email directly or view it on GitHub
#237 (comment).

Contributor

rharter commented Aug 11, 2015

I'm working on that.

On Tue, Aug 11, 2015, 3:36 PM Frankie Sardo notifications@github.com
wrote:

In #202 #202 you mention briefly
the possibility for an extension to claim a list of abstract methods. That
would be helpful in this case.


Reply to this email directly or view it on GitHub
#237 (comment).

cgruber added a commit that referenced this pull request Sep 11, 2015

Merge pull request #237 from rharter/extensibility
Add an initial version of the Extensibility API to AutoValue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=100543793

cgruber added a commit that referenced this pull request Sep 11, 2015

Automated g4 rollback of changelist 100543793.
*** Reason for rollback ***

Google's internal test rig detected substantial numbers of failures, and so this commit was auto-rolled-back.

*** Original change description ***

Merge pull request #237 from rharter/extensibility

Add an initial version of the Extensibility API to AutoValue.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=100545729

cgruber added a commit that referenced this pull request Sep 11, 2015

Automated g4 rollback of changelist 100545729.
*** Reason for rollback ***

Re-attempt original commit, but with internal build fixes to avoid sending the SPI code to android builds, where javac/javax types don't exist.

*** Original change description ***

Automated g4 rollback of changelist 100543793.

*** Reason for rollback ***

Many tests lost their lives securing this commit.

*** Original change description ***

Merge pull request #237 from rharter/extensibility

Add an initial version of the Extensibility API to AutoValue.

***
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=101824430
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment