So the Shared Build Service seems like what I need...
# gradle
s
So the Shared Build Service seems like what I need, but what would be the best way to execute a task from it? I basically need to 1. Call a task in parallel for the Build Service (to run the
run
task of the server), and then kill the running task when the service is closed. 2. Call a command line command from the root project:
./gradlew :server:run
, and then kill it when the service is closed. Which is the best approach? I’m not even sure if #1 is possible.
g
I really don’t think it’s somehow Kotlin related
v
While gildor is right and you should probably better ask (or search) over at the Gradle community slack, you cannot call a task from a build service, besides maybe with using
exec
to start another Gradle process. But the normal way is, that you actually start the server in the build service via code, not that you execute any task which is impossible.
s
I was told at Kotlin conf a few years ago by a gradle dev to ask my gradle questions here 😛 Didn’t realize there was a gradle slack.
But the normal way is, that you actually start the server in the build service via code
So that mean I’d have to import the gradle server module as a dependency into the build? Is that possible?
v
I was told at Kotlin conf a few years ago by a gradle dev to ask my gradle questions here 😛 Didn’t realize there was a gradle slack.
See the channel topic for what to discuss here and how to get to the Gradle Community Slack. :-)
> But the normal way is, that you actually start the server in the build service via code
So that mean I’d have to import the gradle server module as a dependency into the build? Is that possible?
I don't know what a gradle server module is. If you want to start your code for the test, build service might not be the correct way, but like someone else said starting from within the test.
s
I don’t know what a gradle server module is.
I’m just talking about a normal Kotlin jvm gradle module that’s the code for my server. I have one big gradle project for my client and server. I’m just confused how I could add the module as a dependency as a build logic for the server, as the server module itself depends on the build logic. It’d be a circular dependency.
Does that make sense?
v
It makes sense and you are right and that's what I just said. In that case a shared build service is probably not what you want as it is kind of a chicken and egg problem. As I said you probably need to follow the other advice, starting your server from the test code I guess.
s
As I said you probably need to follow the other advice, starting your server from the test code I guess.
That doesn’t allow me to run my tests in non-jvm environments. i.e. against other kotlin multiplatform targets.
v
Then maybe you indeed need to start your server in one task the test task depends on and shut it down in task that finalizes the test task using
finalizedBy
relationship.