Include resource files in pkl_java_library output#110
Merged
KushalP merged 5 commits intoapple:mainfrom Oct 24, 2025
Merged
Conversation
Fix pkl_java_library to include .properties files generated by pkl codegen in the final JAR. Previously, these mapper metadata files were only present in the intermediate srcjar but not in the compiled output JAR. This change: - Adds _pkl_java_resource_jar rule to extract resources from srcjar - Uses java_single_jar to merge compiled classes and resources - Wraps result with java_import to provide JavaInfo for deps - Maintains backward compatibility with module_path feature Addresses issue raised in bazelbuild/rules_java#275 by using the recommended java_single_jar approach for including generated resources. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add test demonstrating that mapper .properties files are required for polymorphic type resolution. The test creates a Shelter with mixed Dog and Cat instances (both extending abstract Animal class) and verifies each deserializes to the correct concrete type. This validates that the .properties files generated by pkl codegen are correctly included in the JAR and used by ClassRegistry for runtime type mapping. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
KushalP
reviewed
Oct 21, 2025
Move inline Pkl configuration to external shelter.pkl file following the pattern established in TestPklCodegen. This improves test maintainability and uses try-with-resources for proper resource management. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
sitaktif
reviewed
Oct 22, 2025
Remove the `|| true` from the zip command that creates the resource JAR, allowing real errors (e.g., disk full, permissions) to properly fail the build. Add explicit check for empty resources directory to handle this case gracefully by creating an empty JAR, rather than silently ignoring zip command failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
KushalP
reviewed
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
pkl_java_libraryto include.propertiesfiles generated by pkl codegen in the final JAR. Previously, these mapper metadata files were only present in the intermediate srcjar but not in the compiled output JAR.This change:
_pkl_java_resource_jarrule to extract resources fromsrcjarjava_single_jarto merge compiled classes and resourcesjava_importto provideJavaInfofordepsmodule_pathfeatureSee issue: #109