Hi, maybe a dumb question, but I'm trying to figur...
# gradle
h
Hi, maybe a dumb question, but I'm trying to figure out which gradle command to run to compile all my targets. Running
assemble
on the root project fails, its a multiplatform project which uses composeResources and I get some unresolved references in the generated Drawable code. Nothing bad because just building one of the targets works just fine. Also it seems assemble doesnt compile anything, so it doesnt give me guarantees that my codebase is still compilable. However I want make sure my project keeps compiling by running a compilation script on the build server. When I run Command + F9 (Build Project) from IntelliJ everything is compiled, somehow IntelliJ figured out which tasks to run, it runs a large array of tasks, probably dependent on the plugins I've applied and submodules I've added. (this build project action also doesnt encounter the issues that I have when I just run assemble) I would like something like what happens when you build the project from intellij but then on the build server, but without the maintenance of making sure the array of tasks is up to date whenever I add or remove a submodule or change something in the plugins. Is there some gradle command that I can use to figure out which tasks I should run, just as Command + F9 seems to do? The list of tasks that is run with Build Project:
Copy code
16:38:42: Executing ':my-project:linkIosSimulatorArm64 :my-project:linkIosX64 :my-project:linkIosArm64 :my-project-catalog:iosX64TestBinaries :my-project-brand:wasmJsMainClasses :my-project:iosArm64MainBinaries :my-project:wasmJsTestClasses :my-project-catalog:iosSimulatorArm64MainBinaries :my-project:metadataMainClasses :my-project-catalog:iosArm64TestBinaries :my-project-brand:iosArm64TestBinaries :my-project-brand:iosSimulatorArm64MainBinaries :my-project-catalog:iosArm64MainBinaries :my-project-catalog:wasmJsTestClasses :my-project:jvmMainClasses :my-project-brand:iosX64TestBinaries :my-project-catalog:desktopMainClasses :my-project:iosX64MainBinaries :my-project-brand:jvmTestClasses :my-project-catalog:metadataMainClasses :my-project:iosSimulatorArm64TestBinaries :my-project:iosSimulatorArm64MainBinaries :my-project-brand:wasmJsTestClasses :my-project-brand:metadataMainClasses :my-project:iosArm64TestBinaries :my-project-catalog:iosX64MainBinaries :my-project-brand:iosArm64MainBinaries :my-project-catalog:iosSimulatorArm64TestBinaries :my-project:wasmJsMainClasses :my-project-brand:linkIosSimulatorArm64 :my-project-brand:linkIosX64 :my-project-brand:linkIosArm64 :my-project-catalog:linkIosSimulatorArm64 :my-project-catalog:linkIosX64 :my-project-catalog:linkIosArm64 :my-project-catalog:desktopTestClasses :my-project-brand:iosSimulatorArm64TestBinaries :my-project-brand:iosX64MainBinaries :my-project:jvmTestClasses :my-project-brand:jvmMainClasses :my-project-catalog:wasmJsMainClasses :my-project:iosX64TestBinaries'...
t
./gradlew tasks
or in IDEA Gradle panel should show all available tasks in the project. Task
assemble
should trigger build for all targets, you could check which exact tasks it is depends on by running
./gradlew assemble -m
If assemble fails because of some error - better to understand which exact task fails (you could use Gradle build scan -
--scan
, if you don't like to check console/build log)
c
I'm trying to figure out which gradle command to run to compile all my targets.
The lifecycle tasks are: •
assemble
: compile everything that can be compiled, generate everything that can be generated, bundle everything that can be bundled… •
check
: do anything that could be considered a quality check: unit tests, integration tests, coverage checks, linters… •
build
: both together If your repository doesn't behave like this, then check the tasks you have configured / the plugins you use.
[IntelliJ] runs a large array of tasks
The very first line of the output should be the exact command IntelliJ is running. Otherwise, you can run with
--scan
and look in the header to see which tasks are started.
h
Thanks for the help. I still do not know how IntelliJ decides how to build everything (it even executes 2 separate gradle commands, the list I included is the first line of one of the gradle commands it executes) But i investigated why my assemble didnt work and apparantly it had to do with a bug in kotlin version 1.9.22, the
lazy
and
setOf
(and probably more) standard functions were not available in the commonMain sourceset. I fixed that by going to kotlin 1.9.23. Now I also see that assemble seems to assemble everything, it even does ios linking etc. exactly as I want. Thanks again 👍
c
Ah, what type of run configurations are you using? IntelliJ does weird stuff if you use anything else than Gradle run configs (not complaining, it doesn't have a choice)
h
I'm not entirely sure how/where to check that tbh
c
In the top right, near the ‘run’ green triangle, there's a drop down with a ‘configure’ option. That opens a menu with all the ways you can run your project, grouped by technology. When your project is configured using Gradle, you'll have wayyyy less issues if you only run stuff with the Gradle type, because it means Gradle does everything from start to finish. If you select another type (e.g. Kotlin Application), then IDEA has to guess what Gradle should do, what it should do, which Java version to use, etc, and sometimes it makes a different choice than Gradle did and that's just a whole world of pain.
h
in the edit configurations view (maybe i have a different intellij version) i have an
Android App
configuration and 5 gradle configurations, based on the last gradle scripts I ran from the gradle window, if that is what you mean.
c
Yes, that sounds fine then.