[IntelliJ Platform Gradle Plugin] Recipes: task awares example

This commit is contained in:
Jakub Chrzanowski 2024-07-25 00:13:19 +02:00
parent d02559f237
commit 70d3b0861a
No known key found for this signature in database
GPG Key ID: C39095BFD769862E
3 changed files with 20 additions and 3 deletions

View File

@ -432,7 +432,7 @@
<toc-element topic="tools_intellij_platform_gradle_plugin_gradle_properties.md"/>
<toc-element topic="tools_intellij_platform_gradle_plugin_jetbrains_runtime.md"/>
<toc-element topic="tools_intellij_platform_gradle_plugin_migration.md"/>
<toc-element topic="tools_intellij_platform_gradle_plugin_recipies.md"/>
<toc-element topic="tools_intellij_platform_gradle_plugin_recipes.md"/>
<toc-element topic="tools_intellij_platform_gradle_plugin_faq.md" toc-title="Frequently Asked Questions"/>
</toc-element>
<toc-element topic="tools_gradle_grammar_kit_plugin.md"/>

View File

@ -294,7 +294,7 @@ intellijPlatform { ... }
```
The plugin also introduces a task listener which allows for creating custom tasks decorated with [](tools_intellij_platform_gradle_plugin_task_awares.md).
See [](tools_intellij_platform_gradle_plugin_recipies.md) for more details.
See [](tools_intellij_platform_gradle_plugin_recipes.md) for more details.
### Available tasks
{#base-available-tasks}

View File

@ -4,7 +4,7 @@
<link-summary>Recipes for solving particular tasks with IntelliJ Platform Gradle Plugin</link-summary>
## Run custom task with customized sandbox location
## Run a custom task with customized sandbox location
To create a custom task with the sandbox directory specified outside of the default <path>build/idea-sandbox/[TYPE]-[VERSION]/</path> location, pass the new location to its `prepareSandboxTask` sandbox producer configuration:
@ -30,3 +30,20 @@ build/
│   └── system
...
```
## Access IntelliJ Platform from any Gradle task
With [](tools_intellij_platform_gradle_plugin_task_awares.md) it is possible to enhance any Gradle task with features provided with the IntelliJ Platform Gradle Plugin.
```kotlin
abstract class MyTask : DefaultTask(), IntelliJPlatformVersionAware
val myTask by tasks.registering(MyTask::class) {
doLast {
println("platformPath = \n${platformPath}")
println("productInfo.buildNumber = ${productInfo.buildNumber}")
}
}
```
As soon as the registered task inherits from the `*Aware` interface, such as [`IntelliJPlatformVersionAware`](tools_intellij_platform_gradle_plugin_task_awares.md#IntelliJPlatformVersionAware), all the related information will be injected during the configuration phase.