Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/mill-plugin-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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: 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
~/.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') }}

- 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 }}
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)

1 change: 1 addition & 0 deletions bin/utils/release/release_version_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -12,15 +13,12 @@ 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"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"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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()}"
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# RELEASE_VERSION
openApiGeneratorVersion=7.19.0-SNAPSHOT
# /RELEASE_VERSION
9 changes: 0 additions & 9 deletions modules/openapi-generator-mill-plugin/mill-test/README.md

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion modules/openapi-generator-mill-plugin/mill-test/version

This file was deleted.

Loading