From c0a707681799f3cd38386c8129ba95c0f8df1b11 Mon Sep 17 00:00:00 2001 From: Gasper Kojek Date: Thu, 6 Nov 2025 21:46:22 +0100 Subject: [PATCH 1/5] Added a simple scala project for maven caching samples --- build-caching-maven-samples/pom.xml | 1 + .../scala-project/pom.xml | 52 +++++++++++++++++++ .../src/main/scala/com/example/App.scala | 9 ++++ .../src/test/scala/com/example/AppTest.scala | 9 ++++ 4 files changed, 71 insertions(+) create mode 100644 build-caching-maven-samples/scala-project/pom.xml create mode 100644 build-caching-maven-samples/scala-project/src/main/scala/com/example/App.scala create mode 100644 build-caching-maven-samples/scala-project/src/test/scala/com/example/AppTest.scala diff --git a/build-caching-maven-samples/pom.xml b/build-caching-maven-samples/pom.xml index 6d3f0f910..81d968257 100644 --- a/build-caching-maven-samples/pom.xml +++ b/build-caching-maven-samples/pom.xml @@ -21,6 +21,7 @@ kotlin-project pmd-project protobuf-project + scala-project spotbugs-project spring-cloud-contract-project diff --git a/build-caching-maven-samples/scala-project/pom.xml b/build-caching-maven-samples/scala-project/pom.xml new file mode 100644 index 000000000..855143cbc --- /dev/null +++ b/build-caching-maven-samples/scala-project/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + scala-project + jar + + + com.example + develocity-maven-caching-sample + 1.0-SNAPSHOT + + + + 2.13.12 + 2.13 + + + + + org.scala-lang + scala-library + ${scala.version} + + + + org.scalatest + scalatest_${scala.binary.version} + 3.2.17 + test + + + + + + + net.alchim31.maven + scala-maven-plugin + 4.8.1 + + + + compile + testCompile + + + + + + + diff --git a/build-caching-maven-samples/scala-project/src/main/scala/com/example/App.scala b/build-caching-maven-samples/scala-project/src/main/scala/com/example/App.scala new file mode 100644 index 000000000..25729a3e5 --- /dev/null +++ b/build-caching-maven-samples/scala-project/src/main/scala/com/example/App.scala @@ -0,0 +1,9 @@ +package com.example + +object App { + def greet(name: String): String = s"Hello, $name!" + + def main(args: Array[String]): Unit = { + println(greet("World")) + } +} diff --git a/build-caching-maven-samples/scala-project/src/test/scala/com/example/AppTest.scala b/build-caching-maven-samples/scala-project/src/test/scala/com/example/AppTest.scala new file mode 100644 index 000000000..4622c2a95 --- /dev/null +++ b/build-caching-maven-samples/scala-project/src/test/scala/com/example/AppTest.scala @@ -0,0 +1,9 @@ +package com.example + +import org.scalatest.funsuite.AnyFunSuite + +class AppTest extends AnyFunSuite { + test("greet returns correct greeting") { + assert(App.greet("Scala") == "Hello, Scala!") + } +} From ac95630f02d95e29c127a17b1954b24d28ae14d5 Mon Sep 17 00:00:00 2001 From: Gasper Kojek Date: Thu, 6 Nov 2025 21:53:32 +0100 Subject: [PATCH 2/5] Added caching configuration for scala-maven-plugin in the scala-project in maven caching samples --- .../scala-project/README.md | 1 + .../scala-project/pom.xml | 378 ++++++++++++++++++ 2 files changed, 379 insertions(+) create mode 100644 build-caching-maven-samples/scala-project/README.md diff --git a/build-caching-maven-samples/scala-project/README.md b/build-caching-maven-samples/scala-project/README.md new file mode 100644 index 000000000..e4165ef13 --- /dev/null +++ b/build-caching-maven-samples/scala-project/README.md @@ -0,0 +1 @@ +Example configuration for making the `compile` and `testCompile` goals of the `scala-maven-plugin` cacheable. diff --git a/build-caching-maven-samples/scala-project/pom.xml b/build-caching-maven-samples/scala-project/pom.xml index 855143cbc..8da078c36 100644 --- a/build-caching-maven-samples/scala-project/pom.xml +++ b/build-caching-maven-samples/scala-project/pom.xml @@ -40,13 +40,391 @@ 4.8.1 + scala-compile compile + + process-resources + + + scala-test-compile + testCompile + process-test-resources + + + + + com.gradle + develocity-maven-extension + + + + + net.alchim31.maven + scala-maven-plugin + + + scala-compile + + + + sourceDir + includes + excludes + + true + true + + + + classpathElements + COMPILE_CLASSPATH + + + compilerPlugins + IGNORED_PATH + + + + + addJavacArgs + + + addScalacArgs + + + additionalDependencies + + + args + + + checkMultipleScalaVersions + + + compileOrder + + + displayCmd + + + encoding + + + failOnMultipleScalaVersions + + + forceUseArgFile + + + fork + + + javacArgs + + + jvmArgs + + + recompileMode + + + release + + + scalaClassName + + + scalaCompatVersion + + + scalaHome + + + scalaOrganization + + + scalaVersion + + + sendJavaToScalac + + + skipMain + + + source + + + target + + + useCanonicalPath + + + + project + session + notifyCompilation + javacGenerateDebugSymbols + classpath + + + + + pluginArtifacts + + + + groupId + + + artifactId + + + version + + + baseVersion + + + type + + + classifier + + + scope + + + + + + dependencies + + + + groupId + + + artifactId + + + version + + + classifier + + + + + + + compilation is CPU-bound + + + outputDir + + + + + + + secondaryCacheDir + + + analysisCacheFile + + + + + + scala-test-compile + + skip + + + + + testSourceDir + includes + excludes + + true + true + + + + classpathElements + COMPILE_CLASSPATH + + + compilerPlugins + IGNORED_PATH + + + + + addJavacArgs + + + addScalacArgs + + + additionalDependencies + + + args + + + checkMultipleScalaVersions + + + compileOrder + + + displayCmd + + + encoding + + + failOnMultipleScalaVersions + + + forceUseArgFile + + + fork + + + javacArgs + + + jvmArgs + + + recompileMode + + + release + + + scalaClassName + + + scalaCompatVersion + + + scalaHome + + + scalaOrganization + + + scalaVersion + + + sendJavaToScalac + + + source + + + target + + + useCanonicalPath + + + + project + session + notifyCompilation + javacGenerateDebugSymbols + + + + + pluginArtifacts + + + + groupId + + + artifactId + + + version + + + baseVersion + + + type + + + classifier + + + scope + + + + + + dependencies + + + + groupId + + + artifactId + + + version + + + classifier + + + + + + + compilation is CPU-bound with well-defined inputs and outputs + + + testOutputDir + + + + + + + secondaryCacheDir + + + testAnalysisCacheFile + + + + + + + + + + + + From 7d14d8b9bb30c557df3cd7e6b5f282c0148f7cba Mon Sep 17 00:00:00 2001 From: Gasper Kojek Date: Fri, 7 Nov 2025 08:18:56 +0100 Subject: [PATCH 3/5] Fixed the scala project sample getting false cache hits --- build-caching-maven-samples/scala-project/pom.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-caching-maven-samples/scala-project/pom.xml b/build-caching-maven-samples/scala-project/pom.xml index 8da078c36..67c241576 100644 --- a/build-caching-maven-samples/scala-project/pom.xml +++ b/build-caching-maven-samples/scala-project/pom.xml @@ -33,6 +33,9 @@ + src/main/scala + src/test/scala + net.alchim31.maven From 6e32c1617bab7e8b72627b3c2dfcf4fe7456640c Mon Sep 17 00:00:00 2001 From: Gasper Kojek Date: Fri, 14 Nov 2025 13:41:26 +0100 Subject: [PATCH 4/5] Added tracking the scala source directories manually This is done because otherwise, if build.sourceDirectory and build.testSourceDirectory are not set and there's only scals sources in a subproject, they aren't tracked as inputs for some reason. --- .../scala-project/pom.xml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/build-caching-maven-samples/scala-project/pom.xml b/build-caching-maven-samples/scala-project/pom.xml index 67c241576..774daf156 100644 --- a/build-caching-maven-samples/scala-project/pom.xml +++ b/build-caching-maven-samples/scala-project/pom.xml @@ -76,6 +76,16 @@ scala-compile + + sourceDirectory + + src/main/scala + + + true + true + + sourceDir includes @@ -254,6 +264,16 @@ + + testSourceDirectory + + src/test/scala + + + true + true + + testSourceDir includes From 98e92a8dbd5a158886226ee0bd3dfd29845079a3 Mon Sep 17 00:00:00 2001 From: Gasper Kojek Date: Fri, 14 Nov 2025 13:59:15 +0100 Subject: [PATCH 5/5] Added publishing .data for maven verification on failure --- .../maven-build-caching-samples-verification.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/maven-build-caching-samples-verification.yml b/.github/workflows/maven-build-caching-samples-verification.yml index fc39f518d..3e467167a 100644 --- a/.github/workflows/maven-build-caching-samples-verification.yml +++ b/.github/workflows/maven-build-caching-samples-verification.yml @@ -50,6 +50,12 @@ jobs: goals: ${{ env.GOALS }} args: ${{ env.ARGS }} failIfNotFullyCacheable: true + - name: Publish .data for experiment 1 + uses: actions/upload-artifact@v5 + if: failure() + with: + path: develocity-maven-build-validation/.data/01-validate-local-build-caching-same-location/latest/ + name: 01-validate-local-build-caching-same-location-data-dir - name: Run experiment 2 uses: gradle/develocity-build-validation-scripts/.github/actions/maven/experiment-2@actions-stable with: @@ -59,3 +65,9 @@ jobs: goals: ${{ env.GOALS }} args: ${{ env.ARGS }} failIfNotFullyCacheable: true + - name: Publish .data for experiment 2 + uses: actions/upload-artifact@v5 + if: failure() + with: + path: develocity-maven-build-validation/.data/02-validate-local-build-caching-different-locations/latest/ + name: 02-validate-local-build-caching-different-locations-data-dir