Add bootTestRun to run app using test source set output and classpath
Closes gh-35248
This commit is contained in:
@@ -14,12 +14,13 @@ When Gradle's {java-plugin}[`java` plugin] is applied to a project, the Spring B
|
||||
2. Configures the `assemble` task to depend on the `bootJar` task.
|
||||
3. Configures the `jar` task to use `plain` as the convention for its archive classifier.
|
||||
4. Creates a {boot-build-image-javadoc}[`BootBuildImage`] task named `bootBuildImage` that will create a OCI image using a https://buildpacks.io[buildpack].
|
||||
5. Creates a {boot-run-javadoc}[`BootRun`] task named `bootRun` that can be used to run your application.
|
||||
6. Creates a configuration named `bootArchives` that contains the artifact produced by the `bootJar` task.
|
||||
7. Creates a configuration named `developmentOnly` for dependencies that are only required at development time, such as Spring Boot's Devtools, and should not be packaged in executable jars and wars.
|
||||
8. Creates a configuration named `productionRuntimeClasspath`. It is equivalent to `runtimeClasspath` minus any dependencies that only appear in the `developmentOnly` configuration.
|
||||
9. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
|
||||
10. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument.
|
||||
5. Creates a {boot-run-javadoc}[`BootRun`] task named `bootRun` that can be used to run your application using the `main` source set to find its main method and provide its runtime classpath.
|
||||
6. Creates a {boot-run-javadoc}['BootRun`] task named `bootTestRun` that can be used to run your application using the `test` source set to find its main method and provide its runtime classpath.
|
||||
7. Creates a configuration named `bootArchives` that contains the artifact produced by the `bootJar` task.
|
||||
8. Creates a configuration named `developmentOnly` for dependencies that are only required at development time, such as Spring Boot's Devtools, and should not be packaged in executable jars and wars.
|
||||
9. Creates a configuration named `productionRuntimeClasspath`. It is equivalent to `runtimeClasspath` minus any dependencies that only appear in the `developmentOnly` configuration.
|
||||
10. Configures any `JavaCompile` tasks with no configured encoding to use `UTF-8`.
|
||||
11. Configures any `JavaCompile` tasks to use the `-parameters` compiler argument.
|
||||
|
||||
|
||||
|
||||
@@ -59,7 +60,7 @@ When Gradle's {application-plugin}[`application` plugin] is applied to a project
|
||||
The task is configured to use the `applicationDefaultJvmArgs` property as a convention for its `defaultJvmOpts` property.
|
||||
2. Creates a new distribution named `boot` and configures it to contain the artifact in the `bootArchives` configuration in its `lib` directory and the start scripts in its `bin` directory.
|
||||
3. Configures the `bootRun` task to use the `mainClassName` property as a convention for its `main` property.
|
||||
4. Configures the `bootRun` task to use the `applicationDefaultJvmArgs` property as a convention for its `jvmArgs` property.
|
||||
4. Configures the `bootRun` and `bootTestRun` tasks to use the `applicationDefaultJvmArgs` property as a convention for their `jvmArgs` property.
|
||||
5. Configures the `bootJar` task to use the `mainClassName` property as a convention for the `Start-Class` entry in its manifest.
|
||||
6. Configures the `bootWar` task to use the `mainClassName` property as a convention for the `Start-Class` entry in its manifest.
|
||||
|
||||
|
||||
@@ -141,3 +141,12 @@ include::../gradle/running/boot-run-source-resources.gradle.kts[tags=source-reso
|
||||
----
|
||||
|
||||
This makes them reloadable in the live application which can be helpful at development time.
|
||||
|
||||
|
||||
|
||||
[[running-your-application.using-a-test-main-class]]
|
||||
== Using a Test Main Class
|
||||
In addition to `bootRun` a `bootTestRun` task is also registered.
|
||||
Like `bootRun`, `bootTestRun` is an instance of `BootRun` but it's configured to use a main class found in the output of the test source set rather than the main source set.
|
||||
It also uses the test source set's runtime classpath rather than the main source set's runtime classpath.
|
||||
As `bootTestRun` is an instance of `BootRun`, all of the configuration options described above for `bootRun` can also be used with `bootTestRun`.
|
||||
|
||||
Reference in New Issue
Block a user