Rob Elliot
10/25/2024, 7:59 AMSam
10/25/2024, 8:11 AMSam
10/25/2024, 8:14 AMRob Elliot
10/25/2024, 8:24 AM~/.gradle
(and $project_dir/.gradle
) as a cache mount:
RUN --mount=type=cache,target=~/myproject/.gradle \
--mount=type=cache,target=~/.gradle \
./gradlew assemble
which should mean both build cache and dependencies are maintained across builds.Rob Elliot
10/25/2024, 8:25 AMcompileKotlin
is still taking 30 seconds or so for a single file change.Sam
10/25/2024, 8:32 AMtapchicoma
10/25/2024, 9:40 AMkotlin.compiler.execution.strategy=in-process
kotlin.compiler.runViaBuildToolsApi=true
This should also support Gradle build cache feature.Rob Elliot
10/25/2024, 9:43 AMRob Elliot
10/25/2024, 9:53 AM./gradlew --info classes
I'm seeing:
#25 5.282 Task ':compileKotlin' is not up-to-date because:
#25 5.282 Output property 'classpathSnapshotProperties.classpathSnapshotDir' file /home/worker/work/build/kotlin/compileKotlin/classpath-snapshot has been removed.
#25 5.282 Output property 'classpathSnapshotProperties.classpathSnapshotDir' file /home/worker/work/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin has been removed.
#25 5.282 Output property 'destinationDirectory' file /home/worker/work/build/classes/kotlin/main has been removed.
#25 5.282 and more...
#25 5.282 and more...
#25 5.282 and more...
#25 5.282 The input changes require a full rebuild for incremental task ':compileKotlin'.
tapchicoma
10/25/2024, 9:53 AMtapchicoma
10/25/2024, 9:54 AMRob Elliot
10/25/2024, 10:09 AMRUN --mount=type=cache,target=~/myproject/.gradle \
--mount=type=cache,target=~/myproject/build \
--mount=type=cache,target=~/.gradle \
./gradlew assemble
Rob Elliot
10/25/2024, 10:59 AMENV GRADLE_PROPS="\
-Pkotlin.compiler.execution.strategy=in-process \
-Pkotlin.compiler.runViaBuildToolsApi=true \
"
RUN --mount=type=cache,target=~/myproject/.gradle \
--mount=type=cache,target=~/myproject/build/kotlin \
--mount=type=cache,target=~/myproject/build/classes/kotlin \
--mount=type=cache,target=~/.gradle/caches/build-cache-1 \
--mount=type=cache,target=~/.gradle/caches/transforms-4 \
./gradlew "$GRADLE_PROPS" assemble
Honestly, if Gradle and JetBrains had actively set out to make it as hard as possible to get an efficient multi-stage docker build I'm not sure they could have made it any harder.
(I also love that next time they increment build-cache-1
to build-cache-2
or transforms-4
to transforms-5
my optimisation will silently stop working... why couldn't they have nested those under a directory?!)tapchicoma
10/25/2024, 11:03 AMRob Elliot
10/25/2024, 11:09 AMtapchicoma
10/25/2024, 11:09 AMwasyl
10/25/2024, 1:30 PM<projectDir>/.kotlin
directory that was recently added?tapchicoma
10/25/2024, 4:10 PM