From e43249b992ba087b3ce0f2f1226281210015a8d1 Mon Sep 17 00:00:00 2001 From: aSemy <897017+aSemy@users.noreply.github.com> Date: Mon, 30 Jan 2023 22:26:27 +0100 Subject: Replace `by` helper function with the standard `set()` (#2834) --- .../dokka/gradle/CheckSourceSetDependenciesTest.kt | 2 +- .../dokka/gradle/DokkaCollectorTaskTest.kt | 10 ++-- .../dokka/gradle/DokkaConfigurationJsonTest.kt | 39 +++++++------- .../gradle/DokkaConfigurationSerializableTest.kt | 24 ++++----- .../dokka/gradle/DokkaMultiModuleFileLayoutTest.kt | 14 ++--- .../dokka/gradle/DokkaMultiModuleTaskTest.kt | 46 +++++++++++------ .../org/jetbrains/dokka/gradle/DokkaTaskTest.kt | 2 +- .../gradle/GradleDokkaSourceSetBuilderTest.kt | 59 +++++++++++----------- .../gradle/KotlinDslDokkaTaskConfigurationTest.kt | 2 +- 9 files changed, 107 insertions(+), 91 deletions(-) (limited to 'runners/gradle-plugin/src/test/kotlin') diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt index cc0efea4..2cd216fd 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt @@ -50,7 +50,7 @@ class CheckSourceSetDependenciesTest { GradleDokkaSourceSetBuilder("common", project), GradleDokkaSourceSetBuilder("intermediate", project).apply { dependsOn("common") - suppress by true + suppress.set(true) }, GradleDokkaSourceSetBuilder("jvm", project).apply { dependsOn("intermediate") diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt index 6e9bef38..bb2b5c1f 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt @@ -33,11 +33,11 @@ class DokkaCollectorTaskTest { val collectorTasks = rootProject.tasks.withType() collectorTasks.configureEach { task -> - task.moduleName by "custom Module Name" - task.outputDirectory by File("customOutputDirectory") - task.cacheRoot by File("customCacheRoot") - task.failOnWarning by true - task.offlineMode by true + task.moduleName.set("custom Module Name") + task.outputDirectory.set(File("customOutputDirectory")) + task.cacheRoot.set(File("customCacheRoot")) + task.failOnWarning.set(true) + task.offlineMode.set(true) } assertTrue(collectorTasks.isNotEmpty(), "Expected at least one collector task") diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt index 877d3b37..a598284f 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt @@ -1,10 +1,11 @@ -@file:Suppress("UnstableApiUsage") - package org.jetbrains.dokka.gradle import org.gradle.kotlin.dsl.withType import org.gradle.testfixtures.ProjectBuilder -import org.jetbrains.dokka.* +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfigurationImpl +import org.jetbrains.dokka.PluginConfigurationImpl +import org.jetbrains.dokka.toJsonString import java.io.File import java.net.URL import kotlin.test.Test @@ -21,25 +22,29 @@ class DokkaConfigurationJsonTest { dependencies.clear() } dokkaTask.apply { - this.failOnWarning by true - this.offlineMode by true - this.outputDirectory by File("customOutputDir") - this.cacheRoot by File("customCacheRoot") - this.pluginsConfiguration.add(PluginConfigurationImpl("A", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value1" } """)) - this.pluginsConfiguration.add(PluginConfigurationImpl("B", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """)) + this.failOnWarning.set(true) + this.offlineMode.set(true) + this.outputDirectory.set(File("customOutputDir")) + this.cacheRoot.set(File("customCacheRoot")) + this.pluginsConfiguration.add( + PluginConfigurationImpl("A", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value1" } """) + ) + this.pluginsConfiguration.add( + PluginConfigurationImpl("B", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """) + ) this.dokkaSourceSets.create("main") { sourceSet -> - sourceSet.displayName by "customSourceSetDisplayName" - sourceSet.reportUndocumented by true + sourceSet.displayName.set("customSourceSetDisplayName") + sourceSet.reportUndocumented.set(true) sourceSet.externalDocumentationLink { link -> - link.packageListUrl by URL("http://some.url") - link.url by URL("http://some.other.url") + link.packageListUrl.set(URL("http://some.url")) + link.url.set(URL("http://some.other.url")) } sourceSet.perPackageOption { packageOption -> - packageOption.includeNonPublic by true - packageOption.reportUndocumented by true - packageOption.skipDeprecated by true - packageOption.documentedVisibilities by setOf(DokkaConfiguration.Visibility.PRIVATE) + packageOption.includeNonPublic.set(true) + packageOption.reportUndocumented.set(true) + packageOption.skipDeprecated.set(true) + packageOption.documentedVisibilities.set(setOf(DokkaConfiguration.Visibility.PRIVATE)) } } } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt index 811f7736..3ef1ed74 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt @@ -29,26 +29,26 @@ class DokkaConfigurationSerializableTest { dependencies.clear() } dokkaTask.apply { - this.failOnWarning by true - this.offlineMode by true - this.outputDirectory by File("customOutputDir") - this.cacheRoot by File("customCacheRoot") + this.failOnWarning.set(true) + this.offlineMode.set(true) + this.outputDirectory.set(File("customOutputDir")) + this.cacheRoot.set(File("customCacheRoot")) this.pluginsConfiguration.add(PluginConfigurationImpl("A", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value1" } """)) this.pluginsConfiguration.add(PluginConfigurationImpl("B", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """)) this.dokkaSourceSets.create("main") { sourceSet -> - sourceSet.displayName by "customSourceSetDisplayName" - sourceSet.reportUndocumented by true + sourceSet.displayName.set("customSourceSetDisplayName") + sourceSet.reportUndocumented.set(true) sourceSet.externalDocumentationLink { link -> - link.packageListUrl by URL("http://some.url") - link.url by URL("http://some.other.url") + link.packageListUrl.set(URL("http://some.url")) + link.url.set(URL("http://some.other.url")) } sourceSet.perPackageOption { packageOption -> - packageOption.includeNonPublic by true - packageOption.reportUndocumented by true - packageOption.skipDeprecated by true - packageOption.documentedVisibilities by setOf(DokkaConfiguration.Visibility.PRIVATE) + packageOption.includeNonPublic.set(true) + packageOption.reportUndocumented.set(true) + packageOption.skipDeprecated.set(true) + packageOption.documentedVisibilities.set(setOf(DokkaConfiguration.Visibility.PRIVATE)) } } } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayoutTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayoutTest.kt index 7d2a9609..54a34e91 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayoutTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleFileLayoutTest.kt @@ -18,7 +18,7 @@ class DokkaMultiModuleFileLayoutTest { val project = ProjectBuilder.builder().build() val child = project.tasks.create("child") val parent = project.tasks.create("parent") - child.outputDirectory by File("some/path") + child.outputDirectory.set(File("some/path")) assertEquals( File("some/path"), NoCopy.targetChildOutputDirectory(parent, child), @@ -57,11 +57,7 @@ class DokkaMultiModuleFileLayoutTest { subFolder.mkdirs() subFolder.resolve("other.file").writeText("other text") - parentTask.fileLayout by object : DokkaMultiModuleFileLayout { - override fun targetChildOutputDirectory(parent: DokkaMultiModuleTask, child: AbstractDokkaTask): File { - return parent.project.file("target/output") - } - } + parentTask.fileLayout.set(DokkaMultiModuleFileLayout { parent, _ -> parent.project.file("target/output") }) parentTask.copyChildOutputDirectory(childTask) /* Assertions */ @@ -105,9 +101,9 @@ class DokkaMultiModuleFileLayoutTest { val project = ProjectBuilder.builder().build() val childTask = project.tasks.create("child") val parentTask = project.tasks.create("parent") - parentTask.fileLayout by DokkaMultiModuleFileLayout { _, child -> + parentTask.fileLayout.set(DokkaMultiModuleFileLayout { _, child -> child.outputDirectory.getSafe().resolve("subfolder") - } + }) assertFailsWith { parentTask.copyChildOutputDirectory(childTask) } } @@ -116,7 +112,7 @@ class DokkaMultiModuleFileLayoutTest { val project = ProjectBuilder.builder().build() val childTask = project.tasks.create("child") val parentTask = project.tasks.create("parent") - parentTask.fileLayout by NoCopy + parentTask.fileLayout.set(NoCopy) parentTask.copyChildOutputDirectory(childTask) } } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt index 6e851326..e308742e 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt @@ -61,13 +61,19 @@ class DokkaMultiModuleTaskTest { } multiModuleTask.apply { - moduleVersion by "1.5.0" - moduleName by "custom Module Name" - outputDirectory by project.buildDir.resolve("customOutputDirectory") - cacheRoot by File("customCacheRoot") - pluginsConfiguration.add(PluginConfigurationImpl("pluginA", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """)) - failOnWarning by true - offlineMode by true + moduleVersion.set("1.5.0") + moduleName.set("custom Module Name") + outputDirectory.set(project.buildDir.resolve("customOutputDirectory")) + cacheRoot.set(File("customCacheRoot")) + pluginsConfiguration.add( + PluginConfigurationImpl( + "pluginA", + DokkaConfiguration.SerializationFormat.JSON, + """ { "key" : "value2" } """ + ) + ) + failOnWarning.set(true) + offlineMode.set(true) includes.from(listOf(topLevelInclude)) } @@ -78,7 +84,13 @@ class DokkaMultiModuleTaskTest { moduleVersion = "1.5.0", outputDir = multiModuleTask.project.buildDir.resolve("customOutputDirectory"), cacheRoot = File("customCacheRoot"), - pluginsConfiguration = mutableListOf(PluginConfigurationImpl("pluginA", DokkaConfiguration.SerializationFormat.JSON, """ { "key" : "value2" } """)), + pluginsConfiguration = mutableListOf( + PluginConfigurationImpl( + "pluginA", + DokkaConfiguration.SerializationFormat.JSON, + """ { "key" : "value2" } """ + ) + ), pluginsClasspath = emptyList(), failOnWarning = true, offlineMode = true, @@ -97,14 +109,14 @@ class DokkaMultiModuleTaskTest { } @Test - fun `multimodule task should not include unspecified version`(){ + fun `multimodule task should not include unspecified version`() { childDokkaTask.apply { dokkaSourceSets.create("main") dokkaSourceSets.create("test") } multiModuleTask.apply { - moduleVersion by "unspecified" + moduleVersion.set("unspecified") } val dokkaConfiguration = multiModuleTask.buildDokkaConfiguration() @@ -117,7 +129,10 @@ class DokkaMultiModuleTaskTest { assertEquals(1, dependenciesInitial.size, "Expected one dependency") val dependency = dependenciesInitial.single() - assertTrue(dependency is DokkaTaskPartial, "Expected dependency to be of Type ${DokkaTaskPartial::class.simpleName}") + assertTrue( + dependency is DokkaTaskPartial, + "Expected dependency to be of Type ${DokkaTaskPartial::class.simpleName}" + ) assertEquals(childProject, dependency.project, "Expected dependency from child project") @@ -184,7 +199,7 @@ class DokkaMultiModuleTaskTest { val childTask = child.tasks.create("child") parentTask.addChildTask(childTask) - childTask.outputDirectory by child.file("custom/output") + childTask.outputDirectory.set(child.file("custom/output")) assertEquals( listOf(parent.file("child/custom/output")), parentTask.sourceChildOutputDirectories, @@ -202,10 +217,9 @@ class DokkaMultiModuleTaskTest { parentTask.addChildTask(childTask) - @Suppress("NAME_SHADOWING") // ¯\_(ツ)_/¯ - parentTask.fileLayout by DokkaMultiModuleFileLayout { parent, child -> - parent.project.buildDir.resolve(child.name) - } + parentTask.fileLayout.set(DokkaMultiModuleFileLayout { taskParent, taskChild -> + taskParent.project.buildDir.resolve(taskChild.name) + }) assertEquals( listOf(parent.project.buildDir.resolve("child")), parentTask.targetChildOutputDirectories, diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt index 546a59db..85a320a8 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTaskTest.kt @@ -16,7 +16,7 @@ class DokkaTaskTest { task.dokkaSourceSets.register("main") task.dokkaSourceSets.register("jvm") task.dokkaSourceSets.register("test") { - it.suppress by true + it.suppress.set(true) } assertEquals( diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt index 9babeefd..e0476c1f 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt @@ -62,8 +62,7 @@ class GradleDokkaSourceSetBuilderTest { "after building source set with no ${GradleDokkaSourceSetBuilder::displayName.name} being set" ) - sourceSet.displayName by "displayName" - + sourceSet.displayName.set("displayName") assertEquals( "displayName", sourceSet.build().displayName, "Expected previously set ${GradleDokkaSourceSetBuilder::displayName.name} to be present after build" @@ -220,21 +219,21 @@ class GradleDokkaSourceSetBuilderTest { sourceSet.sourceLinks.add( GradleSourceLinkBuilder(project).apply { - this.remoteLineSuffix by "ls1" - this.localDirectory by project.file("p1") - this.remoteUrl by URL("https://u1") + this.remoteLineSuffix.set("ls1") + this.localDirectory.set(project.file("p1")) + this.remoteUrl.set(URL("https://u1")) }) sourceSet.sourceLink { - it.remoteLineSuffix by "ls2" - it.localDirectory by project.file("p2") - it.remoteUrl by URL("https://u2") + it.remoteLineSuffix.set("ls2") + it.localDirectory.set(project.file("p2")) + it.remoteUrl.set(URL("https://u2")) } sourceSet.sourceLink(project.closureOf { - this.remoteLineSuffix by "ls3" - this.localDirectory by project.file("p3") - this.remoteUrl by URL("https://u3") + this.remoteLineSuffix.set("ls3") + this.localDirectory.set(project.file("p3")) + this.remoteUrl.set(URL("https://u3")) }) assertEquals( @@ -266,15 +265,15 @@ class GradleDokkaSourceSetBuilderTest { assertEquals(emptyList(), sourceSet.build().perPackageOptions, "Expected no default per package options") sourceSet.perPackageOptions.add(GradlePackageOptionsBuilder(project).apply { - this.matchingRegex by "p1.*" + this.matchingRegex.set("p1.*") }) sourceSet.perPackageOption { - it.matchingRegex by "p2.*" + it.matchingRegex.set("p2.*") } sourceSet.perPackageOption(project.closureOf { - this.matchingRegex by "p3.*" + this.matchingRegex.set("p3.*") }) assertEquals( @@ -296,9 +295,9 @@ class GradleDokkaSourceSetBuilderTest { @Test fun externalDocumentationLink() { val sourceSet = GradleDokkaSourceSetBuilder("", project) - sourceSet.noAndroidSdkLink by true - sourceSet.noJdkLink by true - sourceSet.noStdlibLink by true + sourceSet.noAndroidSdkLink.set(true) + sourceSet.noJdkLink.set(true) + sourceSet.noStdlibLink.set(true) assertEquals( emptySet(), sourceSet.build().externalDocumentationLinks, "Expected no default external documentation links" @@ -306,17 +305,17 @@ class GradleDokkaSourceSetBuilderTest { sourceSet.externalDocumentationLinks.add( GradleExternalDocumentationLinkBuilder(project).apply { - this.url by URL("https://u1") - this.packageListUrl by URL("https://pl1") + this.url.set(URL("https://u1")) + this.packageListUrl.set(URL("https://pl1")) } ) sourceSet.externalDocumentationLink { - it.url by URL("https://u2") + it.url.set(URL("https://u2")) } sourceSet.externalDocumentationLink(project.closureOf { - url by URL("https://u3") + url.set(URL("https://u3")) }) sourceSet.externalDocumentationLink(url = "https://u4", packageListUrl = "https://pl4") @@ -340,7 +339,7 @@ class GradleDokkaSourceSetBuilderTest { val sourceSet = GradleDokkaSourceSetBuilder("", project) assertNull(sourceSet.build().languageVersion, "Expected no language version being set by default") - sourceSet.languageVersion by "JAVA_20" + sourceSet.languageVersion.set("JAVA_20") assertEquals( "JAVA_20", sourceSet.build().languageVersion, "Expected previously set language version to be present after build" @@ -352,7 +351,7 @@ class GradleDokkaSourceSetBuilderTest { val sourceSet = GradleDokkaSourceSetBuilder("", project) assertNull(sourceSet.build().apiVersion, "Expected no api version being set by default") - sourceSet.apiVersion by "20" + sourceSet.apiVersion.set("20") assertEquals( "20", sourceSet.build().apiVersion, "Expected previously set api version to be present after build" @@ -368,7 +367,7 @@ class GradleDokkaSourceSetBuilderTest { "https://kotlinlang.org/api" in it.url.toURI().toString() }, "Expected kotlin stdlib in external documentation links") - sourceSet.noStdlibLink by true + sourceSet.noStdlibLink.set(true) assertEquals( 0, sourceSet.build().externalDocumentationLinks.count { @@ -386,7 +385,7 @@ class GradleDokkaSourceSetBuilderTest { "https://docs.oracle.com/" in it.url.toURI().toString() }, "Expected java jdk in external documentation links") - sourceSet.noJdkLink by true + sourceSet.noJdkLink.set(true) assertEquals( 0, sourceSet.build().externalDocumentationLinks.count { @@ -417,18 +416,20 @@ class GradleDokkaSourceSetBuilderTest { }, "Expected android sdk in external documentation links") assertEquals(1, sourceSet.build().externalDocumentationLinks.count { - "https://developer.android.com/reference/kotlin/androidx/package-list" in it.packageListUrl.toURI().toString() + "https://developer.android.com/reference/kotlin/androidx/package-list" in it.packageListUrl.toURI() + .toString() }, "Expected androidx in external documentation links") - sourceSet.noAndroidSdkLink by true + sourceSet.noAndroidSdkLink.set(true) assertEquals(0, sourceSet.build().externalDocumentationLinks.count { "https://developer.android.com/reference" in it.url.toURI().toString() }, "Expected no android sdk in external documentation links") assertEquals(0, sourceSet.build().externalDocumentationLinks.count { - "https://developer.android.com/reference/kotlin/androidx/package-list" in it.packageListUrl.toURI().toString() + "https://developer.android.com/reference/kotlin/androidx/package-list" in it.packageListUrl.toURI() + .toString() }, "Expected no androidx in external documentation links") } @@ -479,7 +480,7 @@ class GradleDokkaSourceSetBuilderTest { val sourceSet = GradleDokkaSourceSetBuilder("", project) assertEquals(Platform.DEFAULT, sourceSet.build().analysisPlatform, "Expected default platform if not specified") - sourceSet.platform by Platform.common + sourceSet.platform.set(Platform.common) assertEquals( Platform.common, sourceSet.build().analysisPlatform, "Expected previously set analysis platform being present after build" diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt index 9c788a01..58b86495 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt @@ -14,7 +14,7 @@ class KotlinDslDokkaTaskConfigurationTest { val project = ProjectBuilder.builder().build() project.plugins.apply("org.jetbrains.dokka") project.tasks.withType().configureEach { - it.outputDirectory by File("test") + it.outputDirectory.set(File("test")) } project.tasks.withType(DokkaTask::class.java).forEach { dokkaTask -> -- cgit