From 78b9b1768c834126063abd6b8210625dfed0a051 Mon Sep 17 00:00:00 2001 From: Marc Schlegel Date: Thu, 15 Jan 2026 11:23:48 +0100 Subject: [PATCH 1/5] Integrated example project for Mill into CI task The example project uses Mills meta-build to resolve the snapshot version from a properties file. The properties-file is now integrated into `release_version_update.sh`. --- .github/workflows/mill-plugin-tests.yaml | 44 +++++++++++++++++++ bin/utils/release/release_version_update.sh | 1 + .../api/petstore-invalid.yaml} | 0 .../{mill-test => example}/api/petstore.yaml | 0 .../{mill-test => example}/build.mill | 10 ++--- .../{mill-test => example}/mill | 0 .../example/mill-build/build.mill | 36 +++++++++++++++ .../example/mill-build/version.properties | 3 ++ .../{mill-test => example}/mill.bat | 0 .../acme/foo/boundary/web/TestController.java | 0 .../mill-test/README.md | 9 ---- .../mill-test/mill-build/build.mill | 17 ------- .../mill-test/version | 1 - 13 files changed, 88 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/mill-plugin-tests.yaml rename modules/openapi-generator-mill-plugin/{mill-test/api/petstore-v3.0-invalid.yaml => example/api/petstore-invalid.yaml} (100%) rename modules/openapi-generator-mill-plugin/{mill-test => example}/api/petstore.yaml (100%) rename modules/openapi-generator-mill-plugin/{mill-test => example}/build.mill (83%) rename modules/openapi-generator-mill-plugin/{mill-test => example}/mill (100%) create mode 100644 modules/openapi-generator-mill-plugin/example/mill-build/build.mill create mode 100644 modules/openapi-generator-mill-plugin/example/mill-build/version.properties rename modules/openapi-generator-mill-plugin/{mill-test => example}/mill.bat (100%) rename modules/openapi-generator-mill-plugin/{mill-test => example}/src/main/java/com/acme/foo/boundary/web/TestController.java (100%) delete mode 100644 modules/openapi-generator-mill-plugin/mill-test/README.md delete mode 100644 modules/openapi-generator-mill-plugin/mill-test/mill-build/build.mill delete mode 100644 modules/openapi-generator-mill-plugin/mill-test/version diff --git a/.github/workflows/mill-plugin-tests.yaml b/.github/workflows/mill-plugin-tests.yaml new file mode 100644 index 000000000000..e20752f71938 --- /dev/null +++ b/.github/workflows/mill-plugin-tests.yaml @@ -0,0 +1,44 @@ +name: Mill plugin tests + +on: + push: + paths: + - modules/openapi-generator-mill-plugin/** + pull_request: + paths: + - modules/openapi-generator-mill-plugin/** + +jobs: + test: + name: Mill plugin tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Set up JDK 11 + uses: actions/setup-java@v5 + with: + java-version: 11 + distribution: 'temurin' + - name: Cache maven dependencies + uses: actions/cache@v5 + env: + cache-name: cache-maven-repository + with: + path: | + ~/.m2/repository + ~/.gradle + !~/.gradle/caches/*/plugin-resolution/ + !~/.m2/repository/org/openapitools/ + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-test-mill-plugin-${{ env.cache-name }}- + ${{ runner.os }}-test-mill-plugin- + - name: Run tests + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + run: | + ./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true + (cd modules/openapi-generator-mill-plugin/example/ && ./mill __.compile) + (cd modules/openapi-generator-mill-plugin/example/ && ./mill openapi.validate) + (cd modules/openapi-generator-mill-plugin/example/ && ./mill validateOpenapiSpec $(pwd)/api/petstore-invalid.yaml) + diff --git a/bin/utils/release/release_version_update.sh b/bin/utils/release/release_version_update.sh index 9026c07afbde..1920a2339edb 100755 --- a/bin/utils/release/release_version_update.sh +++ b/bin/utils/release/release_version_update.sh @@ -93,6 +93,7 @@ declare -a xml_files=( declare -a properties_files=( "${root}/modules/openapi-generator-gradle-plugin/gradle.properties" "${root}/modules/openapi-generator-gradle-plugin/samples/local-spec/gradle.properties" + "${root}/modules/openapi-generator-mill-plugin/example/mill-build/version.properties" ) ${cwd}/bump.sh -f ${version} -i ${inc} ${xml_files[@]} diff --git a/modules/openapi-generator-mill-plugin/mill-test/api/petstore-v3.0-invalid.yaml b/modules/openapi-generator-mill-plugin/example/api/petstore-invalid.yaml similarity index 100% rename from modules/openapi-generator-mill-plugin/mill-test/api/petstore-v3.0-invalid.yaml rename to modules/openapi-generator-mill-plugin/example/api/petstore-invalid.yaml diff --git a/modules/openapi-generator-mill-plugin/mill-test/api/petstore.yaml b/modules/openapi-generator-mill-plugin/example/api/petstore.yaml similarity index 100% rename from modules/openapi-generator-mill-plugin/mill-test/api/petstore.yaml rename to modules/openapi-generator-mill-plugin/example/api/petstore.yaml diff --git a/modules/openapi-generator-mill-plugin/mill-test/build.mill b/modules/openapi-generator-mill-plugin/example/build.mill similarity index 83% rename from modules/openapi-generator-mill-plugin/mill-test/build.mill rename to modules/openapi-generator-mill-plugin/example/build.mill index 85a6ef8b981f..cb7e7a0c27fb 100644 --- a/modules/openapi-generator-mill-plugin/mill-test/build.mill +++ b/modules/openapi-generator-mill-plugin/example/build.mill @@ -1,7 +1,8 @@ //| mill-version: 1.0.6 -//| mvnDeps: -//| - com.lihaoyi::mill-contrib-versionfile:$MILL_VERSION -//| - org.openapitools:openapi-generator-mill-plugin:$MILL_OPENAPITOOLS_PLUGIN_VERSION +//| # usually you would add the plugin dependency like the following, +//| # but for testing with SNAPSHOT versions, the plugin dependency is added in the meta-build +//| # mvnDeps: +//| # - org.openapitools:openapi-generator-mill-plugin:$MILL_OPENAPITOOLS_PLUGIN_VERSION //| package build @@ -12,13 +13,10 @@ import mill.scalalib.publish.PomSettings import mill.util.BuildInfo.{millBinPlatform, millVersion} import javalib.* -import mill.contrib.versionfile.VersionFileModule import org.openapitools.generator.mill.OpenApiModule object `package` extends JavaModule with MavenModule with OpenApiModule { - // dependency on openapi-generator is set in Mills meta-build - // this is needed to point to a local maven repo override def mvnDeps = Seq( mvn"jakarta.platform:jakarta.jakartaee-api:11.0.0", mvn"com.fasterxml.jackson.core:jackson-databind:2.20.0", diff --git a/modules/openapi-generator-mill-plugin/mill-test/mill b/modules/openapi-generator-mill-plugin/example/mill similarity index 100% rename from modules/openapi-generator-mill-plugin/mill-test/mill rename to modules/openapi-generator-mill-plugin/example/mill diff --git a/modules/openapi-generator-mill-plugin/example/mill-build/build.mill b/modules/openapi-generator-mill-plugin/example/mill-build/build.mill new file mode 100644 index 000000000000..bb47bcf8ce73 --- /dev/null +++ b/modules/openapi-generator-mill-plugin/example/mill-build/build.mill @@ -0,0 +1,36 @@ + +import coursier.LocalRepositories.Dangerous +import coursier.Repositories +import mill.scalalib.DepSyntax +import mill.* +import mill.api.Task +import mill.meta.MillBuildRootModule +import java.util.Properties +import java.io.FileInputStream +import scala.util.Using + +object `package` extends MillBuildRootModule { + + override def repositories = Task { + Seq( + // central needed for default deps + Repositories.central.root, + // the previously installed snapshot is in local maven + // see docs on Coursier, why m2 is considered dangerous + Dangerous.maven2Local.root) + } + + def propsFile = Task.Source("version.properties") + + def readOpenapiSnapshotVersion: Task[String] = Task { + val props = new Properties() + Using(new FileInputStream(propsFile().path.toIO)) { fis => + props.load(fis) + props.getProperty("openApiGeneratorVersion") + }.get + } + + override def mvnDeps = Seq( + mvn"org.openapitools:openapi-generator-mill-plugin:${readOpenapiSnapshotVersion()}" + ) +} \ No newline at end of file diff --git a/modules/openapi-generator-mill-plugin/example/mill-build/version.properties b/modules/openapi-generator-mill-plugin/example/mill-build/version.properties new file mode 100644 index 000000000000..d5f39ef63359 --- /dev/null +++ b/modules/openapi-generator-mill-plugin/example/mill-build/version.properties @@ -0,0 +1,3 @@ +# RELEASE_VERSION +openApiGeneratorVersion=7.19.0-SNAPSHOT +# /RELEASE_VERSION \ No newline at end of file diff --git a/modules/openapi-generator-mill-plugin/mill-test/mill.bat b/modules/openapi-generator-mill-plugin/example/mill.bat similarity index 100% rename from modules/openapi-generator-mill-plugin/mill-test/mill.bat rename to modules/openapi-generator-mill-plugin/example/mill.bat diff --git a/modules/openapi-generator-mill-plugin/mill-test/src/main/java/com/acme/foo/boundary/web/TestController.java b/modules/openapi-generator-mill-plugin/example/src/main/java/com/acme/foo/boundary/web/TestController.java similarity index 100% rename from modules/openapi-generator-mill-plugin/mill-test/src/main/java/com/acme/foo/boundary/web/TestController.java rename to modules/openapi-generator-mill-plugin/example/src/main/java/com/acme/foo/boundary/web/TestController.java diff --git a/modules/openapi-generator-mill-plugin/mill-test/README.md b/modules/openapi-generator-mill-plugin/mill-test/README.md deleted file mode 100644 index a8040d15ce78..000000000000 --- a/modules/openapi-generator-mill-plugin/mill-test/README.md +++ /dev/null @@ -1,9 +0,0 @@ -To test the Mill plugin, this project can be used. - -> ![NOTE] -> The `mill-build` folder is only needed to look up the plugin from the local Maven repository for development purposes. - -It requires that the current SNAPSHOT version of the plugin is installed in the local Maven repository. -Replace the version in `build.mill` or set the environment variable `$MILL_OPENAPITOOLS_PLUGIN_VERSION` to the desired version. - -Run `./mill __.compile` to test if the plugin works or some of the modules tasks like `./mill openapi.validate`. \ No newline at end of file diff --git a/modules/openapi-generator-mill-plugin/mill-test/mill-build/build.mill b/modules/openapi-generator-mill-plugin/mill-test/mill-build/build.mill deleted file mode 100644 index b4a79ea0e18c..000000000000 --- a/modules/openapi-generator-mill-plugin/mill-test/mill-build/build.mill +++ /dev/null @@ -1,17 +0,0 @@ - -import coursier.LocalRepositories.Dangerous -import coursier.Repositories -import mill.api.Task -import mill.meta.MillBuildRootModule - -object `package` extends MillBuildRootModule { - - override def repositories = Task { - Seq( - // central needed for default deps - Repositories.central.root, - // the previously installed snapshot is in local maven - // see docs on Coursier, why m2 is considered dangerous - Dangerous.maven2Local.root) - } -} \ No newline at end of file diff --git a/modules/openapi-generator-mill-plugin/mill-test/version b/modules/openapi-generator-mill-plugin/mill-test/version deleted file mode 100644 index 653dba67d0cc..000000000000 --- a/modules/openapi-generator-mill-plugin/mill-test/version +++ /dev/null @@ -1 +0,0 @@ -7.16.0-SNAPSHOT \ No newline at end of file From 673f714e740df799afd1db1508e8dc5345bd51f7 Mon Sep 17 00:00:00 2001 From: Marc Schlegel Date: Thu, 15 Jan 2026 12:29:49 +0100 Subject: [PATCH 2/5] Add coursier cache to actions-cache --- .github/workflows/mill-plugin-tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/mill-plugin-tests.yaml b/.github/workflows/mill-plugin-tests.yaml index e20752f71938..48f2aa0de73a 100644 --- a/.github/workflows/mill-plugin-tests.yaml +++ b/.github/workflows/mill-plugin-tests.yaml @@ -27,8 +27,10 @@ jobs: path: | ~/.m2/repository ~/.gradle + ~/.cache/coursier !~/.gradle/caches/*/plugin-resolution/ !~/.m2/repository/org/openapitools/ + !~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/openapitools/ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-test-mill-plugin-${{ env.cache-name }}- From e8b6c02b8b30d985fca67973ae24e096e3bdf4e2 Mon Sep 17 00:00:00 2001 From: Marc Schlegel Date: Thu, 15 Jan 2026 12:55:33 +0100 Subject: [PATCH 3/5] Split Mill tests into separate steps --- .github/workflows/mill-plugin-tests.yaml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mill-plugin-tests.yaml b/.github/workflows/mill-plugin-tests.yaml index 48f2aa0de73a..776e41f137c4 100644 --- a/.github/workflows/mill-plugin-tests.yaml +++ b/.github/workflows/mill-plugin-tests.yaml @@ -35,12 +35,27 @@ jobs: restore-keys: | ${{ runner.os }}-test-mill-plugin-${{ env.cache-name }}- ${{ runner.os }}-test-mill-plugin- - - name: Run tests + - name: Maven Clean Install env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} run: | ./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true - (cd modules/openapi-generator-mill-plugin/example/ && ./mill __.compile) - (cd modules/openapi-generator-mill-plugin/example/ && ./mill openapi.validate) + + - name: Mill Example - Test Validation Command + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + run: | (cd modules/openapi-generator-mill-plugin/example/ && ./mill validateOpenapiSpec $(pwd)/api/petstore-invalid.yaml) + + - name: Mill Example - Test Validation Task + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + run: | + (cd modules/openapi-generator-mill-plugin/example/ && ./mill openapi.validate) + + - name: Mill Example - Test Compile Task + env: + GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} + run: | + (cd modules/openapi-generator-mill-plugin/example/ && ./mill __.compile) From 161084e67160fc757969a6aaa5632b58bc1b45cb Mon Sep 17 00:00:00 2001 From: Marc Schlegel Date: Thu, 15 Jan 2026 13:05:19 +0100 Subject: [PATCH 4/5] try to exclude problematic dependencies from maven-cache so they are downloaded by coursier --- .github/workflows/mill-plugin-tests.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/mill-plugin-tests.yaml b/.github/workflows/mill-plugin-tests.yaml index 776e41f137c4..03bfe20b3ad3 100644 --- a/.github/workflows/mill-plugin-tests.yaml +++ b/.github/workflows/mill-plugin-tests.yaml @@ -31,6 +31,9 @@ jobs: !~/.gradle/caches/*/plugin-resolution/ !~/.m2/repository/org/openapitools/ !~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/openapitools/ + !~/.m2/repository/com/fasterxml/ + !~/.m2/repository/org/slf4j/ + !~/.m2/repository/javax/validation/ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-test-mill-plugin-${{ env.cache-name }}- From 041488bb0be506b01da09e71466fe6c905605f37 Mon Sep 17 00:00:00 2001 From: Marc Schlegel Date: Thu, 15 Jan 2026 15:09:09 +0100 Subject: [PATCH 5/5] clear m2-cache prior to mill execution --- .github/workflows/mill-plugin-tests.yaml | 25 +++++++++++-------- .../example/build.mill | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/mill-plugin-tests.yaml b/.github/workflows/mill-plugin-tests.yaml index 03bfe20b3ad3..321bae8cf82f 100644 --- a/.github/workflows/mill-plugin-tests.yaml +++ b/.github/workflows/mill-plugin-tests.yaml @@ -19,10 +19,9 @@ jobs: with: java-version: 11 distribution: 'temurin' - - name: Cache maven dependencies - uses: actions/cache@v5 - env: - cache-name: cache-maven-repository + - name: Restore cache (read-only) + # only use restore keys, no save key because we need to clear the cache before running the examples + uses: actions/cache/restore@v4 with: path: | ~/.m2/repository @@ -31,19 +30,25 @@ jobs: !~/.gradle/caches/*/plugin-resolution/ !~/.m2/repository/org/openapitools/ !~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/openapitools/ - !~/.m2/repository/com/fasterxml/ - !~/.m2/repository/org/slf4j/ - !~/.m2/repository/javax/validation/ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }} - restore-keys: | - ${{ runner.os }}-test-mill-plugin-${{ env.cache-name }}- - ${{ runner.os }}-test-mill-plugin- + - name: Maven Clean Install env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} run: | ./mvnw clean install -DskipTests -Dmaven.javadoc.skip=true + # This is needed because of differences in how Maven and Coursier download artifacts + # Maven will only download the pom when the transitive dependency is not needed in the current projects compile classpath + # whereas Coursier expects the artifact (jar) to be present in a Maven repository. When Coursier encounters a + # artifact folder with a pom it considers the artifact to be available and will then crash when the jar is missing. + - name: Clear m2 cache except openapitools (because otherwise coursier will fail to resolve artifacts where only poms are downloaded) + run: | + mv ~/.m2/repository/org/openapitools /tmp/openapitools-backup || true + rm -rf ~/.m2/repository/* + mkdir -p ~/.m2/repository/org + mv /tmp/openapitools-backup ~/.m2/repository/org/openapitools || true + - name: Mill Example - Test Validation Command env: GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }} diff --git a/modules/openapi-generator-mill-plugin/example/build.mill b/modules/openapi-generator-mill-plugin/example/build.mill index cb7e7a0c27fb..796a97a8c741 100644 --- a/modules/openapi-generator-mill-plugin/example/build.mill +++ b/modules/openapi-generator-mill-plugin/example/build.mill @@ -18,7 +18,7 @@ import org.openapitools.generator.mill.OpenApiModule object `package` extends JavaModule with MavenModule with OpenApiModule { override def mvnDeps = Seq( - mvn"jakarta.platform:jakarta.jakartaee-api:11.0.0", + mvn"jakarta.platform:jakarta.jakartaee-api:10.0.0", mvn"com.fasterxml.jackson.core:jackson-databind:2.20.0", mvn"org.openapitools:jackson-databind-nullable:0.2.8" )