This message was deleted.
# community-support
s
This message was deleted.
n
You can share IntelliJ run configurations, just check the
Store as project file
checkbox in the run configuration popup. But a custom task is also possible of course 🙂
Do you really need an extra task, given that you always want to add those arguments? Can't you just set the args on the existing
app:run
task?
a
Thanks Niels, but just so I learn more about Gradle I would really like to do it in Gradle. How can I set the args on app:run in Gradle?
n
Copy code
tasks.run {
    jvmArgs(...)
    args(...)
}
if gradle doesn't provide the accessor automatically, you can also use
tasks.named("run")
a
Ok, great! And now for the "chrome plating"" Let's say I have 3 or more environments that I might want to connect to so I'd like to have 3 (or more) parameterized version of app:run pre-defined?
t
Maybe have a look at Jetbrains' idea-ext Gradle plugin? https://github.com/JetBrains/gradle-idea-ext-plugin/wiki#runConfigurations
a
Also, tasks..run deosn't let me set args and jvmArgs
Thanks Thomas, I'll definitely check out that plugin!
n
yeah, you'll need
tasks.named("run")
, as
tasks.run
is "captured" by kotlin stdlib
v
pure
tasks.run
in Kotlin DSL does not work. It will not use the task accessor but the standard Kotlin
run
extension function. You need to use
tasks.named<JavaExec>("run") { ... }
or
tasks.run.configure { ... }
, or
import kotlin.run as run_
(or any other name). See https://www.linen.dev/s/gradle-community/t/2699183/how-can-i-add-an-enviroment-variable-to-the-gradle-run-task-
tasks.named("run")
is not enough, as you then only get
Task
to configure
a
Thanks Vampire, that explains why I couldn't get it to work. will try accordingly. Any suggestions on how to define more than one parameterization of the app:run? Any idea why application suports defining default jvm argumetns but not application arguments?
v
Probably because it does not make too much sense, because application arguments are to be supplied by the caller of that application.
To have multiple parametrizations, you can either make the parametrization depending on some project properties or similar, if it is enough to call one task in one Gradle run.
Alternatively do not configure the standard
run
task, but properly register additional
JavaExec
tasks
Then you can also run them in the same Gradle invocation
a
That is what I started out trying to do... But I always stumble on it not finding the javafx modules that app:run manages to find. I even tried looking at ApplicationPlugin.java to see what it does in addRunTask to do the same in my task definition. But it is not clear to me how to translate what it does with getModularity (which I assume where it gets the two javafx modules that I define with the help of the gluon plugin) to my kotlin task definition. I was hoping they'd be in the configuration runtimeClasspath but they are not. They are in the Gradle local repo and somehow app:run finds them but I have not figured out how to point my task to them
You can see my best attempt in the intial post
v
That's most probably because JavaFX has a complete non-sense module-structure and does not work properly outside of Maven. That's why you need the special JavaFX Gradle plugin that mitigates the non-sense they made there. Could well be that it cares about fixing up the standard
run
task too and you need to do the same separately, not sure. Maybe if you could knit an MCVE "someone" could throw an eye on it.
a
Thank you to everybody that answered, especially Vampire. I got it to work for one configuration/target environment with: tasks._named_<JavaExec>("run") { args("--engine", "rmi://taurus:1100/PKSE") jvmArgs("-Djava.util.logging.config.file=logging.properties") }
👌 1
✅ 1