Skip to content
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

Command line run #28

Open
dvlp-r opened this issue Dec 1, 2023 · 5 comments
Open

Command line run #28

dvlp-r opened this issue Dec 1, 2023 · 5 comments

Comments

@dvlp-r
Copy link

dvlp-r commented Dec 1, 2023

Hi, I have downloaded your template and I am struggling about how to run the Day01.kt file from command line.

Gradle build -> gradle run does not work since there is no a run task in the build script.

Thank you in advance for your help.

@MaaxGr
Copy link

MaaxGr commented Dec 1, 2023

Any reason why you don't just use the intellij run icon next to main()?
image

If you still want/need to use gradle, you can reconfigure the build.gradle.kts and then use gradle run.

plugins {
    kotlin("jvm") version "1.9.20"
    application
}

application {
    mainClass = "Day01Kt"
}

@dvlp-r
Copy link
Author

dvlp-r commented Dec 1, 2023

Hi @MaaxGr , thanks for your response.
yes, sometimes I code in codespaces from iPad and I need to use command line.
I knew this alternative but I was interested in knowing the underling command used by IntelliJ to build and run, without the need of modifying anything in the template, so to be able to use it both in intelllij and in other envs.

@hsz
Copy link
Collaborator

hsz commented Dec 2, 2023

This template provides a minimal setup for running Advent of Code solutions via IDE.

Using @MaaxGr suggestion, we can go further and parametrize the mainClass with:

plugins {
    kotlin("jvm") version "1.9.20"
    application
}

sourceSets {
    main {
        kotlin.srcDir("src")
    }
}

application {
    mainClass = providers.gradleProperty("day").map { "Day${it}Kt" }
}

tasks {
    wrapper {
        gradleVersion = "8.5"
    }
}

and run it with:

./gradlew run -Pday="01"

@mikaello
Copy link

mikaello commented Dec 3, 2023

I have the same usecase as @dvlp-r, using codespaces while on the run, so running the program through the CLI is essential. I like your suggestion @hsz.

@codingmickey
Copy link

codingmickey commented Dec 7, 2024

Thanks alot for this thread!!

I had soo much issues with running it on vscode(Intellij is still downloading and I thought to try it out in vscode, but damn it was a pain to setup)

Any idea how to setup the autocomplete on vscode ..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants