Align nativeTest to native to make it multi-modules friendly
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[early-access:true toolchain:true version:24], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[early-access:true toolchain:true version:24], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:22], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:22], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run
Details
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Waiting to run
Details
Build and Deploy Snapshot / Trigger Docs Build (push) Blocked by required conditions
Details
Build and Deploy Snapshot / Verify (push) Blocked by required conditions
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[early-access:true toolchain:true version:24], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[early-access:true toolchain:true version:24], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:17], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:21], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:22], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:false version:22], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }} name:Linux]) (push) Waiting to run
Details
CI / ${{ matrix.os.name}} | Java ${{ matrix.java.version}} (map[toolchain:true version:23], map[id:windows-latest name:Windows]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:false version:17]) (push) Waiting to run
Details
Run System Tests / Java ${{ matrix.java.version}} (map[toolchain:true version:21]) (push) Waiting to run
Details
This commit harmonizes the behavior of the native and nativeTest Maven profiles. Previously, enabling the nativeTest profile would automatically add an execution of the Spring Boot and Native Build Tools plugins, even in a module that doesn't represent an application or a Spring Boot-related module. With this commit, the native testing feature is only enabled if the plugins are defined in the project, either directly, or in a parent. The documentation has been updated as the behavior of both profiles is now much more consistent. Closes gh-44696
This commit is contained in:
parent
77159205ed
commit
d0cdae2369
|
@ -85,7 +85,9 @@ You should have a `<parent>` section that looks like this:
|
|||
</parent>
|
||||
----
|
||||
|
||||
The `spring-boot-starter-parent` declares a `nativeTest` profile that configures the executions that are needed to run the native tests.
|
||||
The `spring-boot-starter-parent` defines a `nativeTest` profile that provides the necessary configuration for the Spring Boot and Native Build Tools plugins.
|
||||
First you need to add those two plugin in the module to opt-in for the feature.
|
||||
Your tests are executed in native mode only when the `nativeTest` is enabled.
|
||||
You can activate profiles using the `-P` flag on the command line.
|
||||
|
||||
TIP: If you don't want to use `spring-boot-starter-parent` you'll need to configure executions for the `process-test-aot` goal from the Spring Boot plugin and the `test` goal from the Native Build Tools plugin.
|
||||
|
|
|
@ -306,31 +306,33 @@ publishing.publications.withType(MavenPublication) {
|
|||
}
|
||||
}
|
||||
build {
|
||||
plugins {
|
||||
plugin {
|
||||
delegate.groupId('org.springframework.boot')
|
||||
delegate.artifactId('spring-boot-maven-plugin')
|
||||
executions {
|
||||
execution {
|
||||
delegate.id('process-test-aot')
|
||||
goals {
|
||||
delegate.goal('process-test-aot')
|
||||
pluginManagement {
|
||||
plugins {
|
||||
plugin {
|
||||
delegate.groupId('org.springframework.boot')
|
||||
delegate.artifactId('spring-boot-maven-plugin')
|
||||
executions {
|
||||
execution {
|
||||
delegate.id('process-test-aot')
|
||||
goals {
|
||||
delegate.goal('process-test-aot')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin {
|
||||
delegate.groupId('org.graalvm.buildtools')
|
||||
delegate.artifactId('native-maven-plugin')
|
||||
configuration {
|
||||
delegate.classesDirectory('${project.build.outputDirectory}')
|
||||
delegate.requiredVersion('22.3')
|
||||
}
|
||||
executions {
|
||||
execution {
|
||||
delegate.id('native-test')
|
||||
goals {
|
||||
delegate.goal('test')
|
||||
plugin {
|
||||
delegate.groupId('org.graalvm.buildtools')
|
||||
delegate.artifactId('native-maven-plugin')
|
||||
configuration {
|
||||
delegate.classesDirectory('${project.build.outputDirectory}')
|
||||
delegate.requiredVersion('22.3')
|
||||
}
|
||||
executions {
|
||||
execution {
|
||||
delegate.id('native-test')
|
||||
goals {
|
||||
delegate.goal('test')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>aot</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- tag::aot[] -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>process-test-aot</id>
|
||||
<goals>
|
||||
<goal>process-test-aot</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- end::aot[] -->
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
|
|
@ -90,17 +90,33 @@ include::partial$goals/process-aot.adoc[leveloffset=+1]
|
|||
== Processing Tests
|
||||
|
||||
The AOT engine can be applied to JUnit 5 tests that use Spring's Test Context Framework.
|
||||
Suitable tests are processed by the AOT engine in order to generate `ApplicationContextInitializer` code.
|
||||
Those tests are processed by the AOT engine and are then executed in a native image.
|
||||
|
||||
To configure your application to use this feature, add an execution for the `process-test-aot` goal, as shown in the following example:
|
||||
Just like <<aot.processing-applications.using-the-native-profile,for production code>>, the `spring-boot-starter-parent` defines a `nativeTest` profile that can be used to streamline the steps required to execute your tests in a native image.
|
||||
|
||||
The `nativeTest` profile configures the following:
|
||||
|
||||
* Execution of `process-test-aot` when the Spring Boot Maven Plugin is applied on a project.
|
||||
* Execution of `test` when the {url-native-build-tools-docs-maven-plugin}[Native Build Tools Maven Plugin] is applied on a project.
|
||||
The execution defines sensible defaults, in particular:
|
||||
** Making sure the plugin uses the raw classpath, and not the main jar file as it does not understand our repackaged jar format.
|
||||
** Validate that a suitable GraalVM version is available.
|
||||
** Download third-party reachability metadata.
|
||||
|
||||
To benefit from the `nativeTest` profile, a module that represents an application should define two plugins, as shown in the following example:
|
||||
|
||||
[source,xml,indent=0,subs="verbatim,attributes"]
|
||||
----
|
||||
include::example$aot-test/pom.xml[tags=aot]
|
||||
include::example$aot-native/pom.xml[tags=aot-native]
|
||||
----
|
||||
|
||||
TIP: If you are using `spring-boot-starter-parent`, this execution is automatically configured if you enable the `nativeTest` profile.
|
||||
Once the above is in place for each module that needs this feature, you can build your multi-modules project and execute your tests in a native image in the relevant sub-modules, as shown in the following example:
|
||||
|
||||
As with application AOT processing, the `BeanFactory` is fully prepared at build-time.
|
||||
[source,shell]
|
||||
----
|
||||
$ mvn test -PnativeTest
|
||||
----
|
||||
|
||||
NOTE: As with application AOT processing, the `BeanFactory` is fully prepared at build-time.
|
||||
|
||||
include::partial$goals/process-test-aot.adoc[leveloffset=+1]
|
||||
|
|
Loading…
Reference in New Issue