https://kotlinlang.org logo
#fleet
Title
# fleet
s

Stylianos Gakis

12/01/2023, 10:42 PM
I thought I’d give AOC a try with amper + fleet, just to see how that experience would be like. Copied over https://github.com/kotlin-hands-on/advent-of-code-kotlin-template, but how do I make a run configuration to run the
fun main
of a specific file? Generating a run.json file, autocompletion could get me as far as this
Copy code
{
    "configurations": [
        {
            "type": "gradle",
            "name": "Run 01",
            "tasks": [],
        },
    ]
}
But it doesn’t help further than that. When doing this in a gradle.kts file we’d specify the class name in there, but what should one do in this scenario? Should this be some configuration in amper, or something inside Fleet’s run.json?
m

maiatoday

12/02/2023, 6:35 AM
I use the gutter icon and then fleet remembers it
I also have this:
Copy code
{
    "configurations": [
        {
            "type": "gradle",
            "name": "Run main",
            "tasks": [
                "run"
            ],
        },
    ]
}
because
./gradlew run
works in my project
I didn't use the template to convert my project though
s

Stylianos Gakis

12/02/2023, 7:06 AM
Hm, but how does it know what to run in the first place? Do you also have a build.gtadle.kts file in your project? If not, how is your file that contains the
fun main
called?
m

maiatoday

12/02/2023, 7:16 AM
the plugins should find the
fun main
does it not work for you if I type
./gradlew help --task run
it says the `run task will run the project as a jvm application. The plugin controls this I believe but I see the link you shared isn't the amper project template
z

zsmb

12/02/2023, 9:27 AM
If you have a run configuration, for example by running something with a gutter icon next to a
main
function, you can copy that config and then paste it into the
run.json
(this will be even simpler in upcoming Fleet releases):
This is what I get from my
Day1.kt
file for example:
Copy code
{
  "name": "Day01",
  "type": "gradle",
  "workingDir": "$PROJECT_DIR$",
  "tasks": [
    "jvmRun"
  ],
  "args": [
    "-DmainClass=Day01Kt",
    "--quiet"
  ],
  "initScripts": {
    "flmapper": "ext.mapPath = { path -> null }"
  }
}
You can see that the
mainClass
is passed in as an argument, so that you know which
main
function will be executed.
👍 1
s

Stylianos Gakis

12/03/2023, 11:52 AM
Copy Configuration
is interesting, I did completely miss that myself! Yeah I don’t think I would’ve figured this out myself, I would in any case have to open intellij to get the gutter action and go from there. In fleet, I only got autocompletion in there for “gradle” in type, all the rest, even $PROJECT_DIR$ there was no autocompletion, so I guess the best bet is to copy as you show. Good to note that when I click on “Copy configuration” I get nothing on my clipboard surprisingly, so I haven’t gotten that part to work for me. Despite all this, after copying your configuration it now works properly when I run the Fleet configuration. But when gradle tries to sync, it just errors out with a long stacktrace (attached later) which means that Fleet now does not offer me auto-completion help in the code itself. Since gradle sync fails. And I made sure my setup looks exactly like it does here btw https://github.com/zsmb13/advent-of-code-2023. Oh well, back to IntelliJ I think it is, I haven’t gotten this to work for me for the past few days 😄
message has been deleted
z

zsmb

12/03/2023, 11:59 AM
Can you please create an issue on https://youtrack.jetbrains.com/issues/FL with that error output and a description of the problem?
8 Views