Skip to content

Commit

Permalink
Customizing the sandboxDirectory and sandboxSuffix when configuri…
Browse files Browse the repository at this point in the history
…ng `SandboxAware` tasks
  • Loading branch information
hsz committed Jun 10, 2024
1 parent f59dad2 commit 7d6012d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Replace base archive file of the `Jar` task with `ComposedJarTask` archive file in all configuration artifact sets
- Redundant whitespace when parsing plugin dependency IDs
- Plugin Verifier: introduce partial configuration for resolving IntelliJ Platform dependencies with same coordinates but different versions
- Customizing the `sandboxDirectory` and `sandboxSuffix` when configuring `SandboxAware` tasks

## [2.0.0-beta5] - 2024-05-30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ internal fun <T : Task> Project.preconfigureTask(task: T) {
SplitModeTarget.BACKEND -> ""
SplitModeTarget.BOTH -> ""
}
sandboxSuffix.convention("-$taskSubject".lowercase().trimEnd('-') + suffix)
val taskName = "prepare" + taskSubject + splitModeVariant + "Sandbox" + suffix

return tasks.maybeCreate<PrepareSandboxTask>(taskName).also { task ->
val taskSubjectSuffix = "-$taskSubject".lowercase().trimEnd('-') + suffix
task.sandboxSuffix.convention(taskSubjectSuffix)
sandboxSuffix.convention(taskSubjectSuffix)
sandboxDirectory.convention(task.sandboxDirectory)
task.sandboxSuffix.convention(sandboxSuffix)
task.sandboxDirectory.set(sandboxDirectory)

if (this is CustomIntelliJPlatformVersionAware) {
task.disabledPlugins = the<IntelliJPlatformPluginsExtension>().disabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.jetbrains.intellij.platform.gradle.*
import org.jetbrains.intellij.platform.gradle.Constants.Sandbox
import org.jetbrains.intellij.platform.gradle.Constants.Tasks
import org.jetbrains.intellij.platform.gradle.tasks.aware.SplitModeAware
import java.nio.file.Path
import kotlin.io.path.*
import kotlin.test.Ignore
import kotlin.test.Test
Expand Down Expand Up @@ -925,4 +924,59 @@ class PrepareSandboxTaskTest : IntelliJPluginTestBase() {
collectPaths(sandbox),
)
}

@Test
fun `create sandbox in a custom location`() {
val taskName = "customRunIde"

buildFile write //language=kotlin
"""
val $taskName by tasks.registering(CustomRunIdeTask::class) {
sandboxDirectory = project.layout.buildDirectory.dir("custom-sandbox")
enabled = false
}
""".trimIndent()

build(taskName)

assertExists(buildDirectory.resolve("custom-sandbox/config_$taskName"))
assertExists(buildDirectory.resolve("custom-sandbox/plugins_$taskName"))
assertExists(buildDirectory.resolve("custom-sandbox/log_$taskName"))
assertExists(buildDirectory.resolve("custom-sandbox/system_$taskName"))
}

@Test
fun `create test sandbox in a custom location`() {
val taskName = "customTest"

buildFile write //language=kotlin
"""
val $taskName by tasks.registering(CustomTestIdeTask::class) {
sandboxDirectory = project.layout.buildDirectory.dir("custom-sandbox")
}
""".trimIndent()

build(taskName)

assertExists(buildDirectory.resolve("custom-sandbox/config-test_$taskName"))
assertExists(buildDirectory.resolve("custom-sandbox/plugins-test_$taskName"))
assertExists(buildDirectory.resolve("custom-sandbox/log-test_$taskName"))
assertExists(buildDirectory.resolve("custom-sandbox/system-test_$taskName"))

buildFile write //language=kotlin
"""
tasks {
$taskName {
sandboxSuffix = "-foo"
}
}
""".trimIndent()

build(taskName)

assertExists(buildDirectory.resolve("custom-sandbox/config-foo"))
assertExists(buildDirectory.resolve("custom-sandbox/plugins-foo"))
assertExists(buildDirectory.resolve("custom-sandbox/log-foo"))
assertExists(buildDirectory.resolve("custom-sandbox/system-foo"))
}
}

0 comments on commit 7d6012d

Please sign in to comment.