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

feat: add support for Java templates #129

Merged
merged 3 commits into from
Mar 6, 2021

Conversation

friederbluemle
Copy link
Contributor

@friederbluemle friederbluemle commented Jan 27, 2021

Summary

This PR adds support for Java templates (both native module and native view types).

With this, Bob now supports all four possible combinations:

  • Java + Objective-C
  • Java + Swift
  • Kotlin + Objective-C
  • Kotlin + Swift

image

Commit Details

The PR head branch contains 3 commits with incremental changes (one way dependency), best reviewed in succession.

Move Kotlin templates to separate directory

As the subject line states, this merely renames the existing Kotlin templates directory to kotlin-library, similar to the existing objc-library/swift-library categories. No functional changes, but prepares for the next commit with independent precursor work in src/create.ts.

Add Java templates

All new templates in templates/java-library and templates/java-view-library. Additional changes in src/create.ts to add the selection to the bob create command.

Combine native and native-view into native-common

This final commit again does not add any new functionality, but removes a large number of duplications by combining native-library and native-view-library into native-common (both on the Android and iOS side). I can move this one to a separate PR if preferred.

Test plan

Use bob create <name> and select one of the new templates, verify that everything works.

Closes #82

Once approved, please use a normal GitHub merge (i.e. NO rebase/squash merge) to integrate the commit(s) from the PR head branch. The changes are broken up into meaningful, atomic commits, and my branch should already be up-to-date with the latest base branch. If it isn't, or if you want me to change anything, please let me know, and I will update the branch as soon as possible. Thank you!

@kelsonpw
Copy link

Would love to see this get merged

@krizzu
Copy link
Collaborator

krizzu commented Jan 28, 2021

@friederbluemle Great work on this one, much appreciated 🙏 !

This final commit again does not add any new functionality, but removes a large number of duplications by combining native-library and native-view-library into native-common (both on the Android and iOS side). I can move this one to a separate PR if preferred.

I'm fine with having this one here.

As a next improvement step, I'd think about having module type selection divided into categories (select either pure js or native, if native then either functional, view or both etc.), so that we're not lost in there. But that's another topic.

WDYT @satya164 ?

@friederbluemle
Copy link
Contributor Author

As a next improvement step, I'd think about having module type selection divided into categories (select either pure js or native, if native then either functional, view or both etc.), so that we're not lost in there. But that's another topic.

Yes, great point! I also had some ideas regarding this while working on the changes here. Like you said, it's another topic, and I wanted to keep the PR focused. Happy to discuss, help and contribute more in the future! 👍

@friederbluemle
Copy link
Contributor Author

@satya164 - If you have a few minutes can you please check this PR? Thanks! 🙏

@shamilovtim
Copy link
Contributor

This PR really helped me out. Thanks!

Copy link
Contributor

@shamilovtim shamilovtim left a comment

Choose a reason for hiding this comment

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

Currently using this in prod

@friederbluemle
Copy link
Contributor Author

I just rebased this, which turned out to be a bit tricky and quite a bit of work after all the structural changes that got merged (especially dc56fc9). I would very much appreciate it if this could get merged/reviewed soon (before more changes are pushed to the main branch). 🙏

@satya164
Copy link
Member

satya164 commented Mar 3, 2021

Hey, sorry for delay, I have been a bit busy with other stuff and also the pending monorepo reorg so haven't been able to check it. I'll try to check it soon.

@mlazari
Copy link

mlazari commented Mar 4, 2021

Currently using this in prod

How do we use this before being merged and officially released?

@shamilovtim
Copy link
Contributor

Currently using this in prod

How do we use this before being merged and officially released?

Pull the git repo, compile it, and run the same CLI commands you would as if you ran it from npm

@friederbluemle
Copy link
Contributor Author

Currently using this in prod

How do we use this before being merged and officially released?

git clone -b java-template https://github.com/friederbluemle/react-native-builder-bob.git
cd react-native-builder-bob 
yarn
yarn --cwd packages/create-react-native-library

You should now have the executable script available in packages/create-react-native-library/bin/.

Run it directly from there to create a new test library (use type native or native-view):

packages/create-react-native-library/bin/create-react-native-library test --slug react-native-test --description test --author-name test --author-email test@test.com --author-url http://test --repo-url http://test --type native

@satya164 satya164 changed the title Add support for Java templates feat: add support for Java templates Mar 6, 2021
@satya164 satya164 merged commit e3a4c2d into callstack:main Mar 6, 2021
@friederbluemle friederbluemle deleted the java-template branch March 6, 2021 21:51
@true-hamid
Copy link

Currently using this in prod

How do we use this before being merged and officially released?

git clone -b java-template https://github.com/friederbluemle/react-native-builder-bob.git
cd react-native-builder-bob 
yarn
yarn --cwd packages/create-react-native-library

You should now have the executable script available in packages/create-react-native-library/bin/.

Run it directly from there to create a new test library (use type native or native-view):

packages/create-react-native-library/bin/create-react-native-library test --slug react-native-test --description test --author-name test --author-email test@test.com --author-url http://test --repo-url http://test --type native

I see you removed/renamed you branch java-template, should we use the 'main' branch for this until it is released?
And thanks for this awesome contribution

@friederbluemle
Copy link
Contributor Author

@true-hamid - The PR has already been merged. So until a new release has been published, you would need to use the default branch (main) in this repo.

Note that because a squash commit was used to merge the PR, the individual commits are no longer distinguishable in this repo. If you want to take a look at these, you can use the java-template-commits branch that I pushed to my fork. Basically repeat the same steps as described above, but replace java-template with java-template-commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Native view in Swift and Kotlin Creates a Project with Objective C and not swift Java instead of Kotlin
7 participants