-
Notifications
You must be signed in to change notification settings - Fork 61
More conversions #29
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
More conversions #29
Conversation
…Convert java primitives to kotlin types.
…aining a 'val' (for old groovy 'def foo=42') convertArrayExpression: Prevent mapping array lookups (if lookup by integer literal) Added convertMapExpression for handling maps Added convertAndroidBuildConfigFunctions for more functions() conversions like buildConfigField() Added convertProductFlavors: Added 'productFlavor { create("name") {' conversion (like others) Added more equals conversions, eg databinding
Really awesome!! Thanks a lot! Shouldn't Windows people use winget instead of other things? I'm not sure kotlin is available there, but everybody should have access to it. Second, do you mind updating our test file? It is currently failing, since the output changed. There is a file with the expected output, and github performs the diff on every commit. |
Ah, tests are a thing. Sounds wise. I've added a few more details to the conversion. I've updated the test so some of the new stuff is tested, and updated the expected result, as you can see. Your expected actually contained a bad block with garbled code, due to the bug which duplicated arbitrary sections. That's what happens on quick and dirty copy my output as expected test-result. But its also pretty understandable how that can happen, it kind of did look right on first glance, and any test is still its far better than no test. I tried comparing the input with the output with beyond compare, and it looks reasonable now. I also tried adding some links in the output, though it kind of sucks to have it there, but it can really help with some good guides, and I stumbled across one such |
That's great, thanks! |
Ah, about windows, the winget is still in insider mode, and didn't work for me, maybe because I already had it installed in non-insider variant. Anayway scoop is fine for now for windows users. |
* Allow non-number fields, but warn user and link to info on buildSrc. Convert java primitives to kotlin types. * convertVariableDeclaration: fixed wrong replacement when already containing a 'val' (for old groovy 'def foo=42') convertArrayExpression: Prevent mapping array lookups (if lookup by integer literal) Added convertMapExpression for handling maps Added convertAndroidBuildConfigFunctions for more functions() conversions like buildConfigField() Added convertProductFlavors: Added 'productFlavor { create("name") {' conversion (like others) Added more equals conversions, eg databinding * readme for windows * Use new com.android.tools.build:gradle:4.1.0 syntax for manifestPlaceholders * Updated expected build test * A few more conversions and added tests and updated expected test result * gitignore Co-authored-by: Alex Rune Berg <arberg.bnr@gmail.com>
You once helped me. I refactored the project into this website: https://gradle-kotlin-converter.vercel.app/ |
Thank you Bernardo, looks cool. I tried it on a java-library gradle file. It's still pretty neat for converting the simple stuff, and cool to have it simply in a url for get it up and running quickly, and interactive as well. Here are some few lines where it could be improved if you so desire. Though be warned, it could be a huge rabit hole to try to get it all, not that I'm up for that right now. This is the input:
Which should have given this output if it was to be 'perfect' :
|
Thank you for the almost awesome script, and certainly extremely helpful script. I have made it better, adding still more conversions, including map conversions, which turned out to be a bit to crazy to get right, but its nice :). I still miss parenthesis matching, but felt it wasn't worth it. The
myBlock
->named("myBlock")
messed up some source-code I had, but it was easy enough to revert, so not really worth modifying the script for that. Well I would have done it if I knew how to match parentesis in java without coding it myself...Once again, thanks for the script.