-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Scala case classes support #598
Comments
Hi @anthony-cros, thanks for raising this. This and #593 (Kotlin support) have been raised recently. I'm not sure it makes sense to target new languages from this tool. Fundamentally, all the code here is about reading a JSON schema rule and creating a some Java for it (Java annotations, Java naming and structural conventions, identifiers that meet Java's restrictions, etc). If you target a new language, you're effectively rewriting everything. Scala and Kotlin could both be considered alternative dialects with which to produce the same Java type, but the burden on this project would be huge, particularly as all new features would have to be supported in Java, Scala and Kotlin. I don't think any individual contributor would have a chance achieving this well. So, given that it's really easy to navigate through a JSON object (in this case the schema) I think it would be better to create your own tool that does this and does whatever is required to generate Scala output. |
Thanks for the comment. Makes sense. |
Actually, I've been piping the output to scalagen to achieve that... It's still less code than doing it myself from the ground up. I understand what you mean about supporting two "different" languages, so maybe as some sort of plug-ins? EDIT: see how javatoscala uses scalagen to do that conversion |
@anthony-cros If we could achieve this by allowing a post-processor to be configured for the Java output then this might be okay. As long as it's a purely mechanical process and doesn't require customization or modification every time we add a new feature. |
I've been experimenting with this one and I've had some success (thanks @anthony-cros!). I think I can enable this feature soon. I expect with some careful adjustment of config properties, people will be able to get useful Scala. |
I've implemented something. If someone could install the latest 0.5.0-SNAPSHOT locally and try this it would be much appreciated. With the maven plugin simply add: <targetLanguage>scala</targetLanguage> to your configuration. Of course, tweak your other config options accordingly to change the Scala output. |
I'm having some problems with the scalagen dependency due to the way it defines artifact names via profile activation. I'll reopen this until I have this sorted. |
Are there some examples of using this for scala around? |
That would be terrific :)
I may be able to contribute actually, given a few pointers!
The text was updated successfully, but these errors were encountered: