kotlin-hands-on / advent-of-code-kotlin-template

The Advent of Code template project for Kotlin
https://blog.jetbrains.com/kotlin/2023/11/advent-of-code-2023-with-kotlin/
Apache License 2.0
599 stars 109 forks source link

Using the amper branch, how do we run specific `fun main` from specific files? #29

Open StylianosGakis opened 11 months ago

StylianosGakis commented 11 months ago

The README seems to imply that there should be a green play button next to it. When using Fleet, that does not seem to exist. Is that something that should be there, something that should be written in a custom fleet run.json, or what should one have to do in order to not have to use IntelliJ for this?

hsz commented 11 months ago

To use Amper, rely on a dedicated fork project linked in README:

[!NOTE]

There is a fork of this repository available that utilizes the Amper tool for project configuration, recently introduced by JetBrains.

For more, see Advent of Code Kotlin Template — Amper project.

hsz commented 11 months ago

Note, for Amper, there's a requirement of using the latest Fleet/IntelliJ IDEA:

[!WARNING]

Amper is supported since IntelliJ IDEA 2023.3 and Fleet 1.26 releases.

No extra configuration is required.

VictorIreri commented 11 months ago

Or maybe, like me, you used the Amper template to create your repo before the settings.gradle.kts bug was fixed?

StylianosGakis commented 11 months ago

It was not the fleet version, nor me forking too late unfortunately. What I did which ended up working was follow the help I got from Márton here https://slack-chats.kotlinlang.org/t/16101531/i-thought-i-d-give-aoc-a-try-with-amper-fleet-just-to-see-ho#5093cea1-4694-4e97-802d-a978501a1b5d

Basically Márton had to run the task on IntelliJ first, to get a configuration auto-generated, then copied that to a fleet configuration, which setup the right flags etc. I had to run jvmRun and not just run as a task, and I had to give it "-DmainClass=Day01Kt" as args. The flmapper part seems to not be necessary for it to run, but in any case, that was there too.

Good to note that when I try to do this "Copy configuration" I get nothing on my clipboard, so without this help, unless I wrote the configuration file myself manually I would not have succeeded in making this run. I don't see people who fork this project (the amper one) to also be able to quickly figure out that they have to add a run.json which looks smth like this

{
  "configurations"
: [
        {
            "name": "Day01",
            "type": "gradle",
            "workingDir": "$PROJECT_DIR$",
            "tasks": ["jvmRun"],
            "args": [
                "-DmainClass=Day01Kt",
                "--quiet"
            ]
        },

    ]
}

Maybe that should be part of the readme? If not just straight up checked into git completely, like the entire .fleet directory.