Skip to content

Commit

Permalink
[gradle plugin] revert applying kotlin-dsl plugin, do that in Kotlin#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aSemy committed Oct 18, 2022
1 parent d2e05d0 commit 572494c
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 77 deletions.
6 changes: 3 additions & 3 deletions runners/gradle-plugin/build.gradle.kts
Expand Up @@ -3,18 +3,18 @@ import org.jetbrains.*

plugins {
`java-gradle-plugin`
`kotlin-dsl`
org.jetbrains.conventions.`maven-publish`
id("com.gradle.plugin-publish")// version "0.20.0"
id("com.gradle.plugin-publish")
}

dependencies {
api(project(":core"))

compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin")
compileOnly("com.android.tools.build:gradle:4.0.1")

compileOnly(gradleKotlinDsl())
testImplementation(project(":test-utils"))
testImplementation(gradleKotlinDsl())
testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
testImplementation("com.android.tools.build:gradle:4.0.1")

Expand Down
Expand Up @@ -4,22 +4,22 @@ import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.internal.plugins.DslObject
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Nested
import org.gradle.kotlin.dsl.container
import org.gradle.work.DisableCachingByDefault

@DisableCachingByDefault(because = "Abstract super-class, not to be instantiated directly")
abstract class AbstractDokkaLeafTask : AbstractDokkaTask() {

@get:Internal
val dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSetBuilder> =
project.container(GradleDokkaSourceSetBuilder::class, gradleDokkaSourceSetBuilderFactory()).also { container ->
DslObject(this).extensions.add("dokkaSourceSets", container)
project.kotlinOrNull?.sourceSets?.all sourceSet@{
container.register(name) {
configureWithKotlinSourceSet(this@sourceSet)
project.container(GradleDokkaSourceSetBuilder::class.java, gradleDokkaSourceSetBuilderFactory())
.also { container ->
DslObject(this).extensions.add("dokkaSourceSets", container)
project.kotlinOrNull?.sourceSets?.all { kotlinSourceSet ->
container.register(kotlinSourceSet.name) { dokkaSourceSet ->
dokkaSourceSet.configureWithKotlinSourceSet(kotlinSourceSet)
}
}
}
}

/**
* Only contains source sets that are marked with `isDocumented`.
Expand Down
Expand Up @@ -35,8 +35,8 @@ internal fun Project.maybeCreateDokkaRuntimeConfiguration(dokkaTaskName: String)
extendsFrom(maybeCreateDokkaDefaultRuntimeConfiguration())
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, "java-runtime"))
isCanBeConsumed = false
defaultDependencies {
add(project.dokkaArtifacts.dokkaCore)
defaultDependencies { dependencies ->
dependencies.add(project.dokkaArtifacts.dokkaCore)
}
}
}
Expand Up @@ -18,8 +18,8 @@ class AbstractDokkaParentTaskTest {
private val subSubproject0 = ProjectBuilder.builder().withName("subSubproject0").withParent(subproject0).build()

init {
rootProject.subprojects {
tasks.create<DokkaTask>("dokkaTask")
rootProject.subprojects { project ->
project.tasks.create<DokkaTask>("dokkaTask")
}
}

Expand Down Expand Up @@ -196,3 +196,5 @@ internal open class TestDokkaParentTask : AbstractDokkaParentTask() {
}

private val Project.dokkaTask: DokkaTask get() = tasks.getByName<DokkaTask>("dokkaTask")


Expand Up @@ -95,9 +95,9 @@ class ConfigureWithKotlinSourceSetGistTest {
mainSourceSet.kotlin.sourceDirectories.elements.get().map { it.asFile }.forEach { it.mkdirs() }

/* Make sure to remove dependencies that cannot be resolved during test */
project.configurations.configureEach {
withDependencies {
removeIf { dependency -> dependency !is FileCollectionDependency }
project.configurations.configureEach { configuration ->
configuration.withDependencies { dependencies ->
dependencies.removeIf { dependency -> dependency !is FileCollectionDependency }
}
}

Expand Down
Expand Up @@ -19,25 +19,25 @@ class DokkaCollectorTaskTest {
val childProject = ProjectBuilder.builder().withParent(rootProject).build()
childProject.plugins.apply("org.jetbrains.kotlin.jvm")

rootProject.allprojects {
plugins.apply("org.jetbrains.dokka")
tasks.withType<AbstractDokkaTask>().configureEach {
plugins.withDependencies { clear() }
rootProject.allprojects { project ->
project.plugins.apply("org.jetbrains.dokka")
project.tasks.withType<AbstractDokkaTask>().configureEach { task ->
task.plugins.withDependencies { dependencies -> dependencies.clear() }
}
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
classpath.setFrom(emptyList<Any>())
project.tasks.withType<DokkaTask>().configureEach { task ->
task.dokkaSourceSets.configureEach { sourceSet ->
sourceSet.classpath.setFrom(emptyList<Any>())
}
}
}

val collectorTasks = rootProject.tasks.withType<DokkaCollectorTask>()
collectorTasks.configureEach {
moduleName by "custom Module Name"
outputDirectory by File("customOutputDirectory")
cacheRoot by File("customCacheRoot")
failOnWarning by true
offlineMode by true
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
}

assertTrue(collectorTasks.isNotEmpty(), "Expected at least one collector task")
Expand Down Expand Up @@ -68,7 +68,7 @@ class DokkaCollectorTaskTest {
fun `with no child tasks throws DokkaException`() {
val project = ProjectBuilder.builder().build()
val collectorTask = project.tasks.create<DokkaCollectorTask>("collector")
project.configurations.all { withDependencies { clear() } }
project.configurations.all { configuration -> configuration.withDependencies { it.clear() } }
assertFailsWith<DokkaException> { collectorTask.generateDocumentation() }
}
}
Expand Up @@ -17,27 +17,29 @@ class DokkaConfigurationJsonTest {
val project = ProjectBuilder.builder().build()
project.plugins.apply("org.jetbrains.dokka")
val dokkaTask = project.tasks.withType<DokkaTask>().first()
dokkaTask.plugins.withDependencies { clear() }
dokkaTask.plugins.withDependencies { dependencies ->
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.dokkaSourceSets.create("main") {
displayName by "customSourceSetDisplayName"
reportUndocumented by true
this.dokkaSourceSets.create("main") { sourceSet ->
sourceSet.displayName by "customSourceSetDisplayName"
sourceSet.reportUndocumented by true

externalDocumentationLink {
packageListUrl by URL("http://some.url")
url by URL("http://some.other.url")
sourceSet.externalDocumentationLink { link ->
link.packageListUrl by URL("http://some.url")
link.url by URL("http://some.other.url")
}
perPackageOption {
includeNonPublic by true
reportUndocumented by true
skipDeprecated by true
documentedVisibilities by setOf(DokkaConfiguration.Visibility.PRIVATE)
sourceSet.perPackageOption { packageOption ->
packageOption.includeNonPublic by true
packageOption.reportUndocumented by true
packageOption.skipDeprecated by true
packageOption.documentedVisibilities by setOf(DokkaConfiguration.Visibility.PRIVATE)
}
}
}
Expand Down
Expand Up @@ -25,28 +25,30 @@ class DokkaConfigurationSerializableTest {
val project = ProjectBuilder.builder().build()
project.plugins.apply("org.jetbrains.dokka")
val dokkaTask = project.tasks.withType<DokkaTask>().first()
dokkaTask.plugins.withDependencies { clear() }
dokkaTask.plugins.withDependencies { dependencies ->
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.dokkaSourceSets.create("main") {
displayName by "customSourceSetDisplayName"
reportUndocumented by true
this.dokkaSourceSets.create("main") { sourceSet ->
sourceSet.displayName by "customSourceSetDisplayName"
sourceSet.reportUndocumented by true

externalDocumentationLink {
packageListUrl by URL("http://some.url")
url by URL("http://some.other.url")
sourceSet.externalDocumentationLink { link ->
link.packageListUrl by URL("http://some.url")
link.url by URL("http://some.other.url")
}

perPackageOption {
includeNonPublic by true
reportUndocumented by true
skipDeprecated by true
documentedVisibilities by setOf(DokkaConfiguration.Visibility.PRIVATE)
sourceSet.perPackageOption { packageOption ->
packageOption.includeNonPublic by true
packageOption.reportUndocumented by true
packageOption.skipDeprecated by true
packageOption.documentedVisibilities by setOf(DokkaConfiguration.Visibility.PRIVATE)
}
}
}
Expand Down
Expand Up @@ -26,9 +26,9 @@ class DokkaMultiModuleTaskTest {
}

init {
rootProject.allprojects {
tasks.withType<AbstractDokkaTask>().configureEach {
plugins.withDependencies { clear() }
rootProject.allprojects { project ->
project.tasks.withType<AbstractDokkaTask>().configureEach { task ->
task.plugins.withDependencies { dependencies -> dependencies.clear() }
}
}
}
Expand Down Expand Up @@ -56,7 +56,7 @@ class DokkaMultiModuleTaskTest {
dokkaSourceSets.create("main")
dokkaSourceSets.create("test")
dokkaSourceSets.configureEach {
includes.from(include1, include2)
it.includes.from(include1, include2)
}
}

Expand Down Expand Up @@ -135,7 +135,7 @@ class DokkaMultiModuleTaskTest {
fun `multimodule task with no child tasks throws DokkaException`() {
val project = ProjectBuilder.builder().build()
val multimodule = project.tasks.create<DokkaMultiModuleTask>("multimodule")
project.configurations.configureEach { withDependencies { clear() } }
project.configurations.configureEach { it.withDependencies { it.clear() } }
assertFailsWith<DokkaException> { multimodule.generateDocumentation() }
}

Expand All @@ -147,17 +147,17 @@ class DokkaMultiModuleTaskTest {

childDokkaTask.apply {
dokkaSourceSets.create("main") {
includes.from(childDokkaTaskInclude1, childDokkaTaskInclude2)
it.includes.from(childDokkaTaskInclude1, childDokkaTaskInclude2)
}
dokkaSourceSets.create("main2") {
includes.from(childDokkaTaskInclude3)
it.includes.from(childDokkaTaskInclude3)
}
}

val secondChildDokkaTaskInclude = childProject.file("include4")
val secondChildDokkaTask = childProject.tasks.create<DokkaTaskPartial>("secondChildDokkaTask") {
dokkaSourceSets.create("main") {
includes.from(secondChildDokkaTaskInclude)
it.includes.from(secondChildDokkaTaskInclude)
}
}
multiModuleTask.addChildTask(secondChildDokkaTask)
Expand Down
Expand Up @@ -11,12 +11,12 @@ class DokkaTaskTest {
fun `no suppressed source sets are present after in built configuration`() {
val project = ProjectBuilder.builder().build()
val task = project.tasks.create<DokkaTask>("dokkaTask")
project.configurations.all { withDependencies { clear() } }
project.configurations.all { configuration -> configuration.withDependencies { it.clear() } }

task.dokkaSourceSets.register("main")
task.dokkaSourceSets.register("jvm")
task.dokkaSourceSets.register("test") {
suppress by true
it.suppress by true
}

assertEquals(
Expand All @@ -30,7 +30,7 @@ class DokkaTaskTest {
fun `module version is not present if not specified`(){
val project = ProjectBuilder.builder().build()
val task = project.tasks.create<DokkaTask>("dokkaTask")
project.configurations.all { withDependencies { clear() } }
project.configurations.all { configuration -> configuration.withDependencies { it.clear() } }

task.dokkaSourceSets.register("main")
assertNull(task.buildDokkaConfiguration().moduleVersion)
Expand Down
Expand Up @@ -226,9 +226,9 @@ class GradleDokkaSourceSetBuilderTest {
})

sourceSet.sourceLink {
remoteLineSuffix by "ls2"
localDirectory by project.file("p2")
remoteUrl by URL("https://u2")
it.remoteLineSuffix by "ls2"
it.localDirectory by project.file("p2")
it.remoteUrl by URL("https://u2")
}

sourceSet.sourceLink(project.closureOf<GradleSourceLinkBuilder> {
Expand Down Expand Up @@ -270,7 +270,7 @@ class GradleDokkaSourceSetBuilderTest {
})

sourceSet.perPackageOption {
matchingRegex by "p2.*"
it.matchingRegex by "p2.*"
}

sourceSet.perPackageOption(project.closureOf<GradlePackageOptionsBuilder> {
Expand Down Expand Up @@ -312,7 +312,7 @@ class GradleDokkaSourceSetBuilderTest {
)

sourceSet.externalDocumentationLink {
url by URL("https://u2")
it.url by URL("https://u2")
}

sourceSet.externalDocumentationLink(project.closureOf<GradleExternalDocumentationLinkBuilder> {
Expand Down
Expand Up @@ -14,7 +14,7 @@ class KotlinDslDokkaTaskConfigurationTest {
val project = ProjectBuilder.builder().build()
project.plugins.apply("org.jetbrains.dokka")
project.tasks.withType<DokkaTask>().configureEach {
outputDirectory by File("test")
it.outputDirectory by File("test")
}

project.tasks.withType(DokkaTask::class.java).forEach { dokkaTask ->
Expand All @@ -31,7 +31,7 @@ class KotlinDslDokkaTaskConfigurationTest {
dokkaTask.dokkaSourceSets.run {
val commonMain = create("commonMain")
val jvmMain = create("jvmMain") {
dependsOn("commonMain")
it.dependsOn("commonMain")
}

assertEquals(
Expand Down Expand Up @@ -65,7 +65,7 @@ class KotlinDslDokkaTaskConfigurationTest {
dokkaSourceSets.run {
val commonMain = create("commonMain")
val jvmMain = create("jvmMain") {
dependsOn(commonMain)
it.dependsOn(commonMain)
}

assertEquals(
Expand All @@ -86,7 +86,7 @@ class KotlinDslDokkaTaskConfigurationTest {
project.tasks.withType(DokkaTask::class.java).first().apply {
dokkaSourceSets.run {
val special = create("special") {
dependsOn(kotlin.sourceSets.getByName("main"))
it.dependsOn(kotlin.sourceSets.getByName("main"))
}

assertEquals(
Expand Down
Expand Up @@ -117,8 +117,8 @@ class KotlinSourceSetGistTest {

/* Only work with file dependencies */
project.configurations.forEach { configuration ->
configuration.withDependencies {
removeIf { dependency ->
configuration.withDependencies { dependencies ->
dependencies.removeIf { dependency ->
dependency !is FileCollectionDependency
}
}
Expand Down

0 comments on commit 572494c

Please sign in to comment.