Slackbot
07/05/2023, 2:01 PMChris Lee
07/05/2023, 2:03 PMBen Stav
07/05/2023, 2:04 PMChris Lee
07/05/2023, 2:06 PMAdam
07/05/2023, 2:07 PMChris Lee
07/05/2023, 2:08 PMAdam
07/05/2023, 2:09 PMblah.main.kts script and use Clikt?Adam
07/05/2023, 2:12 PMChris Lee
07/05/2023, 2:13 PMBen Stav
07/05/2023, 3:28 PMyou could have a convention plugin expose a custom “init subproject” task (perhaps it differs by type of subproject) that creates standard directories etc.That's an interesting option! I haven't thought of that Maybe combining that with some commandline options would be Good Enough territory for now
Ben Stav
07/05/2023, 3:30 PMif you wanted to make an interactive task you could just make aInteresting, I'm an absolute Kotlin newbie so thanks for the Clikt referencescript and use Clikt?blah.main.kts
Ben Stav
07/05/2023, 3:32 PMI think UserInputHandler is intended for the Init or Scan plugins?Yes, I looked into the init plugin code to see how it does things, and it's all in an internal directory. It does seem like there's (currently) nothing exposed But thanks for the pointers, I'll look into some of the alternatives
Ben Stav
07/05/2023, 3:45 PMblah.main.kts part? Do you mean for that to be as part of the project? How would someone run it?Adam
07/05/2023, 3:53 PMinternal package… but that’s only because the Gradle team can change it without warning. If you just want to make a tool for a local project, and it doesn’t matter if it randomly breaks when you update Gradle, then I’d just use UserInputHandler (especially because you’d be using it for a util that’s not critical, and can be done manually if desired)Adam
07/05/2023, 4:02 PMActually could you maybe please elaborate on theSure thing! anyone can run apart? Do you mean for that to be as part of the project? How would someone run it?blah.main.kts
*.main.kts script so long as they have Kotlin installed on PATH (e.g. brew install kotlin and then ./blah.main.kts)
Kotlin Scripting is still in early stages, but it’s nice because you can write regular Kotlin code rather than Bash scripts, and that tends to be more readable and easier to maintain. And okay, it’s more difficult to access all of the other cli utils so the scripts will be more verbose than a shell script equivalent, but a .kts script will be more compatible on on different OSes.
For example, I wrote a kts script for publishing a Gradle Plugin release https://github.com/adamko-dev/dokkatoo/blob/9e1c87e5c65bc3fe5bde8d47a5be23c20f935533/devOps/release.main.kts. It uses Clikt to get the version to release, and calls the GitHub CLI to create PRs and wait for releases. It’s still very rough around the edges though.
So if you wanted to have an interactive script, to help with project set up, then I think a .kts is a good idea. You could ask the user for the type of project to make, and just then create some functions in the script that would create some directories and a build.gradle.kts with the convention plugins applied.Ben Stav
07/06/2023, 6:47 AMIf you just want to make a tool for a local project, and it doesn’t matter if it randomly breaks when you update GradleThat's true, updating gradle would be done by someone who knows the infra so they can update both in lockstep
Ben Stav
07/06/2023, 6:47 AM