Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around gradle issue and optionally include graalvm project #1522

Merged
merged 2 commits into from
Oct 15, 2024
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
2 changes: 1 addition & 1 deletion .evergreen/run-graalvm-native-image-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions graalvm-native-image-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
12 changes: 6 additions & 6 deletions graalvm-native-image-app/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ you need to inform Gradle about that location as specified in https://docs.gradl
Assuming that your MongoDB deployment is accessible at `mongodb://localhost:27017`,
run from the driver project root directory:

| # | Command | Description |
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| 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`. |
| 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. |
| 2 | `./graalvm-native-image-app/build/native/nativeCompile/NativeImageApp` | Run the application that has been built. |
| 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. |
| # | Command | Description |
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
| 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`. |
| 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. |
| 2 | `./graalvm-native-image-app/build/native/nativeCompile/NativeImageApp` | Run the application that has been built. |
| 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. |

#### Specifying a custom connection string

Expand Down
2 changes: 1 addition & 1 deletion gradle/javaToolchain.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions gradle/javadoc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down
6 changes: 4 additions & 2 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
5 changes: 4 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}