Skip to content

Commit

Permalink
Fix Gradle configuration cache warnings in JarSearchableOptionsTask &…
Browse files Browse the repository at this point in the history
… PrepareJarSearchableOptionsTask caused by lazy value calculation, which uses a task reference. It has been fixed by moving out the value of Task.enabled into a property and explicitly defining it as a task input. Also added explicit dependencies between buildSearchableOptions -> prepareJarSearchableOptions -> jarSearchableOptions.
  • Loading branch information
AlexanderBartash authored and hsz committed Sep 24, 2024
1 parent 4633113 commit 976c587
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Fix Gradle configuration cache warnings in `JarSearchableOptionsTask` & `PrepareJarSearchableOptionsTask`
- Added `PrepareSandboxTask.pluginName` for easier accessing of the plugin directory name
- Allow for using non-installer IDEs for plugin verification [#1715](../../issues/1715)
- Added `bundledModule()` dependency extension helpers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,59 @@ class BuildSearchableOptionsTaskTest : SearchableOptionsTestBase() {
assertTaskOutcome(Tasks.JAR_SEARCHABLE_OPTIONS, TaskOutcome.SKIPPED)
}
}

@Test
fun `build searchable options produces XML if enabled via property and explicitly configured`() {
pluginXml write getPluginXmlWithSearchableConfigurable()

getTestSearchableConfigurableJava() write getSearchableConfigurableCode()

gradleProperties write //language=properties
"""
org.jetbrains.intellij.platform.buildSearchableOptions = true
""".trimIndent()


buildFile write //language=kotlin
"""
intellijPlatform {
buildSearchableOptions = true
}
""".trimIndent()

build(Tasks.BUILD_SEARCHABLE_OPTIONS) {
assertContains("Searchable options index builder completed", output)
}

val xml = buildDirectory.resolve("tmp/${Tasks.BUILD_SEARCHABLE_OPTIONS}/projectName-1.0.0.jar/search/projectName-1.0.0.jar.searchableOptions.xml")
assertExists(xml)

xml.readText().let {
assertContains("<configurable id=\"test.searchable.configurable\" configurable_name=\"Test Searchable Configurable\">", it)
assertContains("hit=\"Label for Test Searchable Configurable\"", it)
}
}

@Test
fun `skip build searchable options if disabled via property and explicitly configured`() {

gradleProperties write //language=properties
"""
org.jetbrains.intellij.platform.buildSearchableOptions = false
""".trimIndent()

buildFile write //language=kotlin
"""
intellijPlatform {
buildSearchableOptions = providers.gradleProperty("org.jetbrains.intellij.platform.buildSearchableOptions").map {
it.toBoolean()
}
}
""".trimIndent()

build(Tasks.BUILD_PLUGIN) {
assertTaskOutcome(Tasks.BUILD_SEARCHABLE_OPTIONS, TaskOutcome.SKIPPED)
assertTaskOutcome(Tasks.JAR_SEARCHABLE_OPTIONS, TaskOutcome.SKIPPED)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,60 @@ class JarSearchableOptionsTaskTest : SearchableOptionsTestBase() {
assertEquals(setOf("projectName-1.0.0-searchableOptions.jar", "projectName-1.0.0-base.jar", "projectName-1.0.0.jar"), collectPaths(it))
}
}

@Test
fun `jar searchable options produces archive if enabled via property and explicitly configured`() {
pluginXml write getPluginXmlWithSearchableConfigurable()

gradleProperties write //language=properties
"""
org.jetbrains.intellij.platform.buildSearchableOptions = true
""".trimIndent()

buildFile write //language=kotlin
"""
intellijPlatform {
buildSearchableOptions = providers.gradleProperty("org.jetbrains.intellij.platform.buildSearchableOptions").map {
it.toBoolean()
}
}
""".trimIndent()

getTestSearchableConfigurableJava() write getSearchableConfigurableCode()

build(Tasks.JAR_SEARCHABLE_OPTIONS)

buildDirectory.resolve("libs").let {
assertExists(it)
assertEquals(setOf("projectName-1.0.0-searchableOptions.jar", "projectName-1.0.0-base.jar", "projectName-1.0.0.jar"), collectPaths(it))
}
}

@Test
fun `jar searchable options disabled via property and explicitly configured`() {
pluginXml write getPluginXmlWithSearchableConfigurable()

gradleProperties write //language=properties
"""
org.jetbrains.intellij.platform.buildSearchableOptions = false
""".trimIndent()

buildFile write //language=kotlin
"""
intellijPlatform {
buildSearchableOptions = providers.gradleProperty("org.jetbrains.intellij.platform.buildSearchableOptions").map {
it.toBoolean()
}
}
""".trimIndent()

getTestSearchableConfigurableJava() write getSearchableConfigurableCode()

build(Tasks.JAR_SEARCHABLE_OPTIONS)

buildDirectory.resolve("libs").let {
assertExists(it)
assertEquals(setOf("projectName-1.0.0-base.jar", "projectName-1.0.0.jar"), collectPaths(it))
}
}
}

0 comments on commit 976c587

Please sign in to comment.