Skip to content

Commit 877425e

Browse files
authored
Work around gradle issue and optionally include graalvm project (#1522)
JAVA-5637
1 parent 5d11fe0 commit 877425e

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

.evergreen/run-graalvm-native-image-app.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ echo "The Gradle version is"
2222
./gradlew --version
2323

2424
echo "Building and running the GraalVM native image app"
25-
./gradlew -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} :graalvm-native-image-app:nativeRun
25+
./gradlew -PincludeGraalvm -PjavaVersion=${JAVA_VERSION} -Dorg.mongodb.test.uri=${MONGODB_URI} :graalvm-native-image-app:nativeRun

graalvm-native-image-app/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
// Note requires a Gradle project flag `-PincludeGraalvm` (see settings.gradle).
18+
1719
plugins {
1820
id 'application'
1921
id 'org.graalvm.buildtools.native' version '0.9.23'

graalvm-native-image-app/readme.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ you need to inform Gradle about that location as specified in https://docs.gradl
4747
Assuming that your MongoDB deployment is accessible at `mongodb://localhost:27017`,
4848
run from the driver project root directory:
4949

50-
| # | Command | Description |
51-
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
52-
| 0 | `env JAVA_HOME="${JDK17}" ./gradlew -PjavaVersion=21 :graalvm-native-image-app:nativeCompile` | Build the application relying on the reachability metadata stored in `graalvm-native-image-app/src/main/resources/META-INF/native-image`. |
53-
| 1 | `env JAVA_HOME="${JDK17}" ./gradlew clean && env JAVA_HOME=${JDK21_GRAALVM} ./gradlew -PjavaVersion=21 -Pagent :graalvm-native-image-app:run && env JAVA_HOME=${JDK21_GRAALVM} ./gradlew :graalvm-native-image-app:metadataCopy` | Collect the reachability metadata and update the files storing it. Do this before building the application only if building fails otherwise. |
54-
| 2 | `./graalvm-native-image-app/build/native/nativeCompile/NativeImageApp` | Run the application that has been built. |
55-
| 3 | `env JAVA_HOME="${JDK17}" ./gradlew -PjavaVersion=21 :graalvm-native-image-app:nativeRun` | Run the application using Gradle, build it if necessary relying on the stored reachability metadata. |
50+
| # | Command | Description |
51+
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
52+
| 0 | `env JAVA_HOME="${JDK17}" ./gradlew -PincludeGraalvm -PjavaVersion=21 :graalvm-native-image-app:nativeCompile` | Build the application relying on the reachability metadata stored in `graalvm-native-image-app/src/main/resources/META-INF/native-image`. |
53+
| 1 | `env JAVA_HOME="${JDK17}" ./gradlew clean && env JAVA_HOME=${JDK21_GRAALVM} ./gradlew -PincludeGraalvm -PjavaVersion=21 -Pagent :graalvm-native-image-app:run && env JAVA_HOME=${JDK21_GRAALVM} ./gradlew -PincludeGraalvm :graalvm-native-image-app:metadataCopy` | Collect the reachability metadata and update the files storing it. Do this before building the application only if building fails otherwise. |
54+
| 2 | `./graalvm-native-image-app/build/native/nativeCompile/NativeImageApp` | Run the application that has been built. |
55+
| 3 | `env JAVA_HOME="${JDK17}" ./gradlew -PincludeGraalvm -PjavaVersion=21 :graalvm-native-image-app:nativeRun` | Run the application using Gradle, build it if necessary relying on the stored reachability metadata. |
5656

5757
#### Specifying a custom connection string
5858

gradle/javaToolchain.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ allprojects {
8080
options.encoding = "UTF-8"
8181
options.release.set(17)
8282
}
83-
} else if (project == project(':graalvm-native-image-app')) {
83+
} else if (project.name == 'graalvm-native-image-app') {
8484
tasks.withType(JavaCompile) {
8585
options.encoding = 'UTF-8'
8686
options.release.set(DEFAULT_JDK_VERSION)

gradle/javadoc.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import static org.gradle.util.CollectionUtils.single
1717
*/
1818

1919

20-
def projectsThatDoNotPublishJavaDocs = project(":util").allprojects + project(":driver-benchmarks") + project("driver-workload-executor") + project("driver-lambda") + project(":graalvm-native-image-app")
21-
def javaMainProjects = subprojects - projectsThatDoNotPublishJavaDocs
20+
def projectNamesThatDoNotPublishJavaDocs =["driver-benchmarks", "driver-lambda", "driver-workload-executor", "graalvm-native-image-app", "util",
21+
"spock", "taglets"]
22+
def javaMainProjects = subprojects.findAll { !projectNamesThatDoNotPublishJavaDocs.contains(it.name) }
2223

2324
task docs {
2425
dependsOn javaMainProjects.collect { it.tasks.withType(Javadoc) + it.tasks.withType(ScalaDoc) }

gradle/publish.gradle

+4-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,10 @@ ext {
7272
}
7373
}
7474

75-
def projectsNotPublishedToMaven = project(":util").allprojects + project(":driver-benchmarks") + project("driver-workload-executor") + project("driver-lambda") + project(":graalvm-native-image-app")
76-
def publishedProjects = subprojects - projectsNotPublishedToMaven
75+
76+
def projectNamesNotToBePublished = ["driver-benchmarks", "driver-lambda", "driver-workload-executor", "graalvm-native-image-app", "util",
77+
"spock", "taglets"]
78+
def publishedProjects = subprojects.findAll { !projectNamesNotToBePublished.contains(it.name) }
7779
def scalaProjects = publishedProjects.findAll { it.name.contains('scala') }
7880
def javaProjects = publishedProjects - scalaProjects
7981
def projectsWithManifest = publishedProjects.findAll {it.name != 'driver-legacy' }

settings.gradle

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ include ':driver-scala'
3232
include ':mongodb-crypt'
3333
include 'util:spock'
3434
include 'util:taglets'
35-
include ':graalvm-native-image-app'
35+
36+
if(hasProperty("includeGraalvm")) {
37+
include ':graalvm-native-image-app'
38+
}

0 commit comments

Comments
 (0)