-
Notifications
You must be signed in to change notification settings - Fork 69
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
Generated java types general housekeeping #143
Generated java types general housekeeping #143
Conversation
The Java installer would simply overwrite files instead of removing and recreating the shared_types directory. This resulted in old unused shared types that were removed from the rust app library sticking around in the java shared_types files. This can lead to confusion as kotlin will not see references to these unused types as no longer valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for this! Much appreciated :-) Will merge (unless you fancy adding a similar thing to the Swift and TypeScript gen :-)
crux_core/src/typegen.rs
Outdated
let package_path = package_name.replace('.', "/"); | ||
|
||
// remove any existing generated shared types, this ensures that we remove no longer used types | ||
fs::remove_dir_all(path.as_ref().to_path_buf().join(&package_path)).unwrap_or(()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the to_path_buf()
call, as join()
is on &path
. This will avoid an unneccesary coercion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the unnecessary coercion. Thank you for the bringing that to my attention.
The call to to_path_buf was unnecessary as we were working on a path reference, which already implements the join method.
As far as I can tell, Swift and Typescript do not need similar treatment. The java installer puts each type in it's own file within the Java shared_types directory. The swift and typescript installers instead collate all the shared types into a single shared types file which is overwritten with each build. |
Ahh perfect. Thanks! |
@Trapfether nice improvement. I've definitely run into this issue, thanks! |
When building the core app with an android target, java files are generated that we reference from kotlin to help facilitate our interaction with the core app. During this process, any types that were no longer being used were left in place. This PR updates the Java type generation helper clean up the shared types directory before generating the updated set of types.