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

Generated java types general housekeeping #143

Merged

Conversation

Trapfether
Copy link
Contributor

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.

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.
Copy link
Member

@StuartHarris StuartHarris left a 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 :-)

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(());
Copy link
Member

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.

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 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.
@Trapfether
Copy link
Contributor Author

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.

@StuartHarris
Copy link
Member

Ahh perfect. Thanks!

@StuartHarris StuartHarris merged commit 83e0f1f into redbadger:master Sep 18, 2023
9 checks passed
@wasnotrice
Copy link
Contributor

@Trapfether nice improvement. I've definitely run into this issue, thanks!

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.

3 participants