Skip to content
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

Handle autogenerated classes correctly. #527

Merged
merged 1 commit into from
Oct 23, 2015
Merged

Conversation

advayDev1
Copy link
Contributor

Handle autogenerated classes correctly.

  • Make autogenerated files work even without --build-closure
  • Handle changes to autogenerated files that are not solely caused by changes to hand-written files (ex. configuration changes).
  • Default to build/classes/main for annotation-processor generated source.
  • Both CycleFinder and Translate now treat autogen code identically.
  • Remove duplicate functionality between 'additional' and 'generated' files.

Fixes #517

@@ -149,8 +149,9 @@ class J2objcPlugin implements Plugin<Project> {
dependsOn: 'j2objcPreBuild') {
group 'build'
description "Translates all the java source files in to Objective-C using 'j2objc'"
// Default location for generated source files using annotation processor compilation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a reference to where this is defined?

@brunobowden
Copy link
Contributor

LGTM

@advayDev1
Copy link
Contributor Author

Waiting for @andrewfunston's ack on #517 .

This is a guess, we'll see if it works. If it does indeed work, I'll try to look through Gradle's source to see if we can provide an authoritative reference.

@advayDev1 advayDev1 force-pushed the apt branch 2 times, most recently from 783c85c to 08ae497 Compare October 22, 2015 19:59
@advayDev1 advayDev1 changed the title Use correct directory for autogenerated classes. - WIP Handle autogenerated classes correctly. Oct 22, 2015
@advayDev1
Copy link
Contributor Author

@brunobowden ptal; completely redone btw.

@advayDev1
Copy link
Contributor Author

Per @andrewfunston at #517 (comment) - this is functionally good to go

*/
List<String> generatedSourceDirs = new ArrayList<>()
// Default location for generated source files using annotation processor compilation.
List<String> generatedSourceDirs = ['build/classes/main']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any convention around writing generated source to build/classes/test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found anything like that. I don't think we could support distinct annotation processors in the test source set (that aren't in the main source set) at this moment without significant changes (remember we have a limitation that build-closure is not possible to apply for the test source).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally used injection in my test set on my real project; I'm not sure if it's standard practice or not. I add component that inject test implementations (in memory dbs, etc); that was failure on my part to include that in the sample project, I was attempting to boil everything down pretty thin. Is there any actionable items for this, or is this an accepted shortcoming of the current j2objc plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we do the same as we did here?
i.e. you put out some GitHub/Gist repos of an issue (if there actually is any, it might just work?), and we'll try to fix. But let's please do it as a separate bug and PR (please file the bug Andy).

Adding build/classes/test here is not a good idea regardless, as it would add those test files to your production library.

It is the annotation processors themselves that we can't have be distinct for the test set. I think I can get it to work as long as you use for example Dagger in both main and test, but you happen to inject different classes (along with their autogen counterparts) in your test code. If you were to use SomeOtherInjectionFramework in test (only), I don't think we can make that work in the near future.

@brunobowden
Copy link
Contributor

LGTM after addressing comments

- Make autogenerated files work even without --build-closure
- Handle changes to autogenerated files that are not solely caused by changes to hand-written files (ex. configuration changes).
- Default to build/classes/main for annotation-processor generated source.
- Both CycleFinder and Translate now treat autogen code identically.
- Remove duplicate functionality between 'additional' and 'generated' files.

Fixes j2objc-contrib#517
@advayDev1
Copy link
Contributor Author

Unit-tests for all platforms have passed; non-aesthetic changes should have only affected them. Will get the 30min result on main branch anyway.

merging.

advayDev1 added a commit that referenced this pull request Oct 23, 2015
Handle autogenerated classes correctly.
@advayDev1 advayDev1 merged commit a21272c into j2objc-contrib:master Oct 23, 2015
@advayDev1 advayDev1 deleted the apt branch October 25, 2015 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants