From 511a63a18592966391d639a23af87f5fd81edddd Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Wed, 2 Oct 2024 14:24:21 +0100 Subject: [PATCH] Work around gradle issue and optionally include graalvm project JAVA-5637 --- .evergreen/run-graalvm-native-image-app.sh | 2 +- graalvm-native-image-app/build.gradle | 2 ++ graalvm-native-image-app/readme.md | 6 ++++-- gradle/javaToolchain.gradle | 2 +- gradle/javadoc.gradle | 5 +++-- gradle/publish.gradle | 6 ++++-- settings.gradle | 5 ++++- 7 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.evergreen/run-graalvm-native-image-app.sh b/.evergreen/run-graalvm-native-image-app.sh index 130b0ef7b4e..ba24ef764a8 100755 --- a/.evergreen/run-graalvm-native-image-app.sh +++ b/.evergreen/run-graalvm-native-image-app.sh @@ -22,4 +22,4 @@ echo "The Gradle version is" ./gradlew --version echo "Building and running the GraalVM native image app" -./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} :graalvm-native-image-app:nativeRun +./gradlew -PincludeGraalvm -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} :graalvm-native-image-app:nativeRun diff --git a/graalvm-native-image-app/build.gradle b/graalvm-native-image-app/build.gradle index 713b8c29a1a..b3d7335f9d9 100644 --- a/graalvm-native-image-app/build.gradle +++ b/graalvm-native-image-app/build.gradle @@ -14,6 +14,8 @@ * limitations under the License. */ +// Note requires a Gradle project flag `-PincludeGraalvm` (see settings.gradle). + plugins { id 'application' id 'org.graalvm.buildtools.native' version '0.9.23' diff --git a/graalvm-native-image-app/readme.md b/graalvm-native-image-app/readme.md index a659b7d1c07..1fda1453a80 100644 --- a/graalvm-native-image-app/readme.md +++ b/graalvm-native-image-app/readme.md @@ -62,10 +62,12 @@ you can specify the connection string used by the `:graalvm-native-image-app:run Gradle tasks, as well as by the built native application by passing the CLI argument `-Dorg.mongodb.test.uri=""` to `gradlew` or `NativeImageApp` respectively: +For gradle to include this project in the build you *must* include a project flag: `-PincludeGraalvm` + ```bash -./gradlew ... -Dorg.mongodb.test.uri="" +./gradlew ... -PincludeGraalvm -Dorg.mongodb.test.uri="" ``` ```bash -./graalvm-native-image-app/build/native/nativeCompile/NativeImageApp -Dorg.mongodb.test.uri="" +./graalvm-native-image-app/build/native/nativeCompile/NativeImageApp -PincludeGraalvm -Dorg.mongodb.test.uri="" ``` diff --git a/gradle/javaToolchain.gradle b/gradle/javaToolchain.gradle index 187b143eea6..f1c779dab33 100644 --- a/gradle/javaToolchain.gradle +++ b/gradle/javaToolchain.gradle @@ -80,7 +80,7 @@ allprojects { options.encoding = "UTF-8" options.release.set(17) } - } else if (project == project(':graalvm-native-image-app')) { + } else if (project.name == 'graalvm-native-image-app') { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' options.release.set(DEFAULT_JDK_VERSION) diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle index 8d425b693b8..b986747c647 100644 --- a/gradle/javadoc.gradle +++ b/gradle/javadoc.gradle @@ -17,8 +17,9 @@ import static org.gradle.util.CollectionUtils.single */ -def projectsThatDoNotPublishJavaDocs = project(":util").allprojects + project(":driver-benchmarks") + project("driver-workload-executor") + project("driver-lambda") + project(":graalvm-native-image-app") -def javaMainProjects = subprojects - projectsThatDoNotPublishJavaDocs +def projectNamesThatDoNotPublishJavaDocs =["driver-benchmarks", "driver-lambda", "driver-workload-executor", "graalvm-native-image-app", "util", + "spock", "taglets"] +def javaMainProjects = subprojects.findAll { !projectNamesThatDoNotPublishJavaDocs.contains(it.name) } task docs { dependsOn javaMainProjects.collect { it.tasks.withType(Javadoc) + it.tasks.withType(ScalaDoc) } diff --git a/gradle/publish.gradle b/gradle/publish.gradle index f72773c5ad7..9add25f9261 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -72,8 +72,10 @@ ext { } } -def projectsNotPublishedToMaven = project(":util").allprojects + project(":driver-benchmarks") + project("driver-workload-executor") + project("driver-lambda") + project(":graalvm-native-image-app") -def publishedProjects = subprojects - projectsNotPublishedToMaven + +def projectNamesNotToBePublished = ["driver-benchmarks", "driver-lambda", "driver-workload-executor", "graalvm-native-image-app", "util", + "spock", "taglets"] +def publishedProjects = subprojects.findAll { !projectNamesNotToBePublished.contains(it.name) } def scalaProjects = publishedProjects.findAll { it.name.contains('scala') } def javaProjects = publishedProjects - scalaProjects def projectsWithManifest = publishedProjects.findAll {it.name != 'driver-legacy' } diff --git a/settings.gradle b/settings.gradle index b1c5e185d37..4ebbb10c4e0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -32,4 +32,7 @@ include ':driver-scala' include ':mongodb-crypt' include 'util:spock' include 'util:taglets' -include ':graalvm-native-image-app' + +if(hasProperty("includeGraalvm")) { + include ':graalvm-native-image-app' +}