-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor DokkatooKotlinAdapter, fix AndroidJVM target, add DokkatooAn…
…droidAdapter (#59) * fix getName() in DokkaSourceSetIdSpec.kt * add DokkatooAndroidAdapter * align Kotlin version to match Gradle's embedded Kotlin version * add KotlinPlatform.AndroidJVM, refactor to rename 'key' to 'displayName' * rm deprecated helper in TestFixtures * update test after KotlinPlatform refactor * tidy build config * add kotlinx-coroutines dependency to DokkaGenerator classpath * big ol' refactor of DokkatooKotlinAdapter - tidy up the complication/source set details extractors - move extractors into specific companion objects - update logic to better match DGP code * update API dump * add link to Kotlin/dokka#2977 * refactor DokkatooKotlinAdapter to better organise logic into specific builder utility classes * update conventions for Android/JDK documentation links, so they're enabled dynamically based on the analysis platform * add cacheRoot comment * sort KotlinPlatform alphabetically * tidy up KotlinAdapter, update AndroidAdapter to fetch android.jar, update the configuration-files-fetch logic to fetch JAVA_RUNTIME files * lots of changes, so bump the minor version * remove conditional default for enableJdkDocumentationLink - it seems to result in the wrong Java version in the KotlinMultiplatformExample test...?
- Loading branch information
Showing
22 changed files
with
509 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/multimodule-example/dokkatoo/parentProject/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/multimodule-example/dokkatoo/parentProject/childProjectA/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/multimodule-example/dokkatoo/parentProject/childProjectB/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
modules/dokkatoo-plugin/src/main/kotlin/adapters/DokkatooAndroidAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package dev.adamko.dokkatoo.adapters | ||
|
||
import com.android.build.gradle.internal.dependency.VariantDependencies | ||
import com.android.build.gradle.internal.publishing.AndroidArtifacts | ||
import dev.adamko.dokkatoo.DokkatooBasePlugin | ||
import dev.adamko.dokkatoo.DokkatooExtension | ||
import dev.adamko.dokkatoo.dokka.parameters.KotlinPlatform | ||
import dev.adamko.dokkatoo.internal.DokkatooInternalApi | ||
import dev.adamko.dokkatoo.internal.collectIncomingFiles | ||
import javax.inject.Inject | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.file.FileCollection | ||
import org.gradle.api.logging.Logging | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.kotlin.dsl.* | ||
|
||
@DokkatooInternalApi | ||
abstract class DokkatooAndroidAdapter @Inject constructor( | ||
private val objects: ObjectFactory, | ||
) : Plugin<Project> { | ||
|
||
override fun apply(project: Project) { | ||
logger.info("applied DokkatooAndroidAdapter to ${project.path}") | ||
|
||
project.plugins.withType<DokkatooBasePlugin>().configureEach { | ||
project.pluginManager.apply { | ||
withPlugin("com.android.base") { configure(project) } | ||
withPlugin("com.android.application") { configure(project) } | ||
withPlugin("com.android.library") { configure(project) } | ||
} | ||
} | ||
} | ||
|
||
protected fun configure(project: Project) { | ||
val dokkatooExtension = project.extensions.getByType<DokkatooExtension>() | ||
|
||
dokkatooExtension.dokkatooSourceSets.configureEach { | ||
|
||
val androidClasspath: Provider<FileCollection> = | ||
analysisPlatform.map { | ||
val compilationClasspath = objects.fileCollection() | ||
if (it == KotlinPlatform.AndroidJVM) { | ||
|
||
fun collectConfiguration(named: String) { | ||
project.configurations.collectIncomingFiles(named, compilationClasspath) | ||
// need to fetch JARs explicitly, because Android Gradle Plugin is weird | ||
// and doesn't seem to register the attributes properly | ||
@Suppress("UnstableApiUsage") | ||
project.configurations.collectIncomingFiles(named, compilationClasspath) { | ||
withVariantReselection() | ||
attributes { | ||
attribute(AndroidArtifacts.ARTIFACT_TYPE, AndroidArtifacts.ArtifactType.JAR.type) | ||
} | ||
lenient(true) | ||
} | ||
} | ||
|
||
// fetch android.jar | ||
collectConfiguration(named = VariantDependencies.CONFIG_NAME_ANDROID_APIS) | ||
} | ||
|
||
compilationClasspath | ||
} | ||
|
||
classpath.from(androidClasspath) | ||
} | ||
} | ||
|
||
@DokkatooInternalApi | ||
companion object { | ||
private val logger = Logging.getLogger(DokkatooAndroidAdapter::class.java) | ||
} | ||
} |
Oops, something went wrong.