Comments (12)
hi @EdricChan03 and @MirzaUkas, I've made some adjustments to how Dokkatoo handles Android projects in #150. Could you check the 2.1.0-SNAPSHOT to see if it helps?
You'll have to add Maven Central snapshots as a plugin repo:
repositories {
// add Maven Central snapshot repository
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "MavenCentralSnapshots"
mavenContent { snapshotsOnly() }
}
}
I expect that you won't receive an error about Gradle resolution, however you might see 'unknown class' in the rendered docs.
from dokkatoo.
Hi, after upgrading to 2.1.0
I don't get this issue again. I can run dokkatooGeneratePublicationHtml
with multivariant module/library. Thank you @aSemy
from dokkatoo.
Thanks for the report, and the example project. I've checked it out and I can reproduce the problem. I think it's something to do with the :material3
subproject having a library variant.
// material3/build.gradle.kts
// ...
kotlin {
// ...
androidTarget {
publishLibraryVariants("release")
}
}
I suspect the fix will be setting 'artifactType' to 'jar' somewhere in DokkatooAndroidAdapter, but I'm not sure where. I'll try experimenting, but I'm not an Android developer so help would be appreciated!
from dokkatoo.
I think this is a Gradle bug gradle/gradle#27265. For some reason Gradle forgets about the 'artifactType' being set to 'jar'.
from dokkatoo.
Hi, any update on this issue? currently, I have a custom build variant in my library modules.
from dokkatoo.
hi @MirzaUkas - I don't have any updates.
Dokkatoo needs to get all of the compile-time dependencies of a project. For Android project here's the code that does it:
However Gradle seems to get confused and it can't discriminate between all the different options. It also ignores lenient(true)
which is supposed to ignore these errors.
I'd be grateful if you could take a look! Maybe Dokkatoo isn't using the Gradle API correctly. And I'm not an Android developer, so maybe there's a better way to fetch the dependencies?
As a workaround, maybe I could disable this bit of code, or catch & log the error. But that would probably result in Error class: unknown class
appearing in the generated docs.
from dokkatoo.
I've done a little bit more digging!
There are apparently two problems:
-
the
Could not determine the dependencies of task ':dokkatooGenerateModuleHtml'
error is triggered in DokkatooKotlinAdapter, not in DokkatooAndroidAdapter as I thought!If I comment out
compilation.compileDependencyFiles
then generation succeeds (but of course the docs containsError class: unknown class
) -
DokkatooAndroidAdapter isn't fetching all JARs. This is where my lack of Android knowledge will show. How can I fetch all the JARs/Classes used to compile an Android source set? What's the difference between an AAR and a JAR?
from dokkatoo.
What's the difference between an AAR and a JAR?
An AAR provides additional resources (strings/dimensions/string arrays/etc, styles, layouts, drawables, etc), any additional manifest declarations (e.g. a library might want to declare a runtime permission, which can then be added into the library's AndroidManifest.xml
file to be merged into the resulting Android application), and other Android-specific stuff I might not be aware of.
How can I fetch all the JARs/Classes used to compile an Android source set?
I think this might be possible if you hook into the AndroidComponentsExtension
(or its variants, e.g. LibraryAndroidComponentsExtension
for modules that apply com.android.library
, ApplicationAndroidComponentsExtension
for modules that apply com.android.application
) that Google provides as part of AGP, where you can access lazy configuration-compatible properties/providers via the onVariants
DSL? (Further up they also define the other build points) They have a section in the docs on hooking up to the artifacts that AGP would produce. Personally, I'm not certain if you can actually access the data though, but hope that helps
from dokkatoo.
Thanks @EdricChan03! The AARs don't sound relevant for Dokka so I can leave them out.
I think accessing the compilation of an Android project works fine at the moment. The bigger problem is getting the compile-time dependencies as JARs with Java classes.
Looking at your example project, I can see in TopAppBarMenuItems the Modifier
class. In IntelliJ I can ctrl+click on that class and then see where it comes from
/Users/me/.local/state/gradle/caches/transforms-3/78818b83fcc8d01bda1c8f99abed49cb/transformed/ui-release/jars/classes.jar
The question is how do I get that file...
As a very quick and hacky example, if you copy this into the project's build.gradle.kts
, this roughly shows what Dokkatoo is doing to fetch the compile-time classpath for Kotlin projects.
afterEvaluate {
val kotlinCompileDependencyFiles =
kotlin.targets.flatMap { target ->
target.compilations.flatMap { compilation ->
configurations.named(compilation.compileDependencyConfigurationName)
.map {
it.incoming
.artifactView {
// lenient(true)
attributes {
attribute(Attribute.of("artifactType", String::class.java), "jar")
}
}
.artifacts
.artifactFiles
}
.get()
}
}
println(kotlinCompileDependencyFiles.joinToString("\n") { " - ${it.name}" })
}
which prints
- kotlin-stdlib-jdk8-1.9.10.jar
- kotlin-stdlib-jdk7-1.9.10.jar
- kotlin-stdlib-1.9.10.jar
- annotations-13.0.jar
- kotlin-stdlib-jdk8-1.9.10.jar
- kotlin-stdlib-jdk7-1.9.10.jar
- kotlin-stdlib-1.9.10.jar
- annotations-13.0.jar
- kotlin-stdlib-jdk8-1.9.10.jar
- kotlin-stdlib-jdk7-1.9.10.jar
- kotlin-stdlib-1.9.10.jar
- annotations-13.0.jar
- kotlin-stdlib-jdk8-1.9.10.jar
- kotlin-stdlib-jdk7-1.9.10.jar
- kotlin-stdlib-1.9.10.jar
- annotations-13.0.jar
- kotlin-stdlib-jdk8-1.9.10.jar
- kotlin-stdlib-jdk7-1.9.10.jar
- kotlin-stdlib-1.9.10.jar
- annotations-13.0.jar
- core-metadata-1.0.jar
- material3-metadata-1.5.3.jar
- material-ripple-metadata-1.5.3.jar
- foundation-metadata-1.5.3.jar
- animation-metadata-1.5.3.jar
- animation-core-metadata-1.5.3.jar
- foundation-layout-metadata-1.5.3.jar
- material-icons-core-metadata-1.5.3.jar
- ui-metadata-1.5.3.jar
- ui-text-metadata-1.5.3.jar
- ui-graphics-metadata-1.5.3.jar
- ui-unit-metadata-1.5.3.jar
- runtime-saveable-metadata-1.5.3.jar
- ui-geometry-metadata-1.5.3.jar
- runtime-metadata-1.5.3.jar
- ui-util-metadata-1.5.3.jar
- kotlinx-datetime-metadata-0.4.0-all.jar
- skiko-metadata-0.7.77.jar
- kotlinx-coroutines-core-metadata-1.6.4-all.jar
- kotlinx-serialization-core-metadata-1.3.2-all.jar
- atomicfu-metadata-0.17.3-all.jar
- kotlin-stdlib-1.8.20.jar
- kotlin-stdlib-common-1.9.10.jar
- annotations-13.0.jar
And for some reason it's missing ui-android.
from dokkatoo.
androidComponents.onVariants {}
doesn't seem to help either...
Copy this into an Android project's build.gradle.kts
and run gradle logAndroidComponentsCompileClasspath
// build.gradle.kts
/** Aggregate compile classpath from all Android components */
val androidComponentsCompileClasspath = objects.fileCollection()
androidComponents {
onVariants { variant ->
fun collect(artifactType: String) {
val artifactTypeFiles = variant.compileConfiguration.incoming
.artifactView {
attributes {
attribute(
Attribute.of("artifactType", String::class.java),
artifactType,
)
}
// withVariantReselection()
// lenient(true)
}
.artifacts
.resolvedArtifacts
.map { artifacts -> artifacts.map(ResolvedArtifactResult::getFile) }
androidComponentsCompileClasspath.from(artifactTypeFiles)
}
collect("android-classes-jar")
collect("android-lint")
collect("android-lint-local-aar")
collect("android-manifest")
collect("android-renderscript")
collect("android-symbol-with-package-name")
collect("jar")
collect("r-class-jar")
}
}
val logAndroidComponentsCompileClasspath by tasks.registering {
group = project.name
val cc = androidComponentsCompileClasspath
inputs.files(cc).withPropertyName("cc")
doLast {
println(cc.joinToString("\n") { " - ${it.invariantSeparatorsPath}" })
}
}
- […]/compose-menuprovider-example/core/build/intermediates/compile_library_classes_jar/debug/classes.jar
- […]/transformed/material3-1.1.1-api.jar
- […]/transformed/material-icons-core-1.4.1-api.jar
- […]/transformed/material-ripple-1.4.1-api.jar
- […]/transformed/animation-core-release-api.jar
- […]/transformed/animation-release-api.jar
- […]/transformed/foundation-layout-release-api.jar
- […]/transformed/foundation-release-api.jar
- […]/transformed/ui-unit-release-api.jar
- […]/transformed/ui-geometry-release-api.jar
- […]/transformed/ui-text-release-api.jar
- […]/transformed/ui-graphics-release-api.jar
- […]/transformed/ui-release-api.jar
- […]/transformed/runtime-saveable-release-api.jar
- […]/transformed/runtime-release-api.jar
- […]gradle/caches/[…]/kotlinx-coroutines-core-jvm-1.6.4.jar
- […]gradle/caches/[…]/kotlinx-coroutines-android-1.6.4.jar
- […]gradle/caches/[…]/kotlin-stdlib-jdk8-1.9.10.jar
- […]gradle/caches/[…]/kotlin-stdlib-jdk7-1.9.10.jar
- […]gradle/caches/[…]/annotation-jvm-1.6.0.jar
- […]gradle/caches/[…]/kotlin-stdlib-1.9.10.jar
- […]gradle/caches/[…]/annotations-13.0.jar
- […]/compose-menuprovider-example/core/build/intermediates/lint_publish_jar/global/lint.jar
- […]/transformed/material3-1.1.1/jars/lint.jar
- […]/transformed/animation-core-release/jars/lint.jar
- […]/transformed/animation-release/jars/lint.jar
- […]/transformed/foundation-release/jars/lint.jar
- […]/transformed/ui-graphics-release/jars/lint.jar
- […]/transformed/ui-release/jars/lint.jar
- […]/transformed/runtime-saveable-release/jars/lint.jar
- […]/transformed/runtime-release/jars/lint.jar
- […]/compose-menuprovider-example/core/build/intermediates/local_aar_for_lint/debug/out.aar
- […]/compose-menuprovider-example/core/build/intermediates/merged_manifest/debug/AndroidManifest.xml
- […]/transformed/material3-1.1.1/AndroidManifest.xml
- […]/transformed/material-icons-core-1.4.1/AndroidManifest.xml
- […]/transformed/material-ripple-1.4.1/AndroidManifest.xml
- […]/transformed/animation-core-release/AndroidManifest.xml
- […]/transformed/animation-release/AndroidManifest.xml
- […]/transformed/foundation-layout-release/AndroidManifest.xml
- […]/transformed/foundation-release/AndroidManifest.xml
- […]/transformed/ui-unit-release/AndroidManifest.xml
- […]/transformed/ui-geometry-release/AndroidManifest.xml
- […]/transformed/ui-text-release/AndroidManifest.xml
- […]/transformed/ui-graphics-release/AndroidManifest.xml
- […]/transformed/ui-release/AndroidManifest.xml
- […]/transformed/runtime-saveable-release/AndroidManifest.xml
- […]/transformed/runtime-release/AndroidManifest.xml
- […]/compose-menuprovider-example/core/build/intermediates/renderscript_headers/debug/out
- […]/compose-menuprovider-example/core/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt
- […]/transformed/androidx.compose.material3-r.txt
- […]/transformed/androidx.compose.material.icons-r.txt
- […]/transformed/androidx.compose.material.ripple-r.txt
- […]/transformed/androidx.compose.animation.core-r.txt
- […]/transformed/androidx.compose.animation-r.txt
- […]/transformed/androidx.compose.foundation.layout-r.txt
- […]/transformed/androidx.compose.foundation-r.txt
- […]/transformed/androidx.compose.ui.unit-r.txt
- […]/transformed/androidx.compose.ui.geometry-r.txt
- […]/transformed/androidx.compose.ui.text-r.txt
- […]/transformed/androidx.compose.ui.graphics-r.txt
- […]/transformed/androidx.compose.ui-r.txt
- […]/transformed/androidx.compose.runtime.saveable-r.txt
- […]/transformed/androidx.compose.runtime-r.txt
- […]/compose-menuprovider-example/core/build/intermediates/full_jar/debug/full.jar
- […]/transformed/material3-1.1.1/jars/classes.jar
- […]/transformed/material-icons-core-1.4.1/jars/classes.jar
- […]/transformed/material-ripple-1.4.1/jars/classes.jar
- […]/transformed/animation-core-release/jars/classes.jar
- […]/transformed/animation-release/jars/classes.jar
- […]/transformed/foundation-layout-release/jars/classes.jar
- […]/transformed/foundation-release/jars/classes.jar
- […]/transformed/ui-unit-release/jars/classes.jar
- […]/transformed/ui-geometry-release/jars/classes.jar
- […]/transformed/ui-text-release/jars/classes.jar
- […]/transformed/ui-graphics-release/jars/classes.jar
- […]/transformed/ui-release/jars/classes.jar
- […]/transformed/runtime-saveable-release/jars/classes.jar
- […]/transformed/runtime-release/jars/classes.jar
- […]/compose-menuprovider-example/core/build/intermediates/compile_r_class_jar/debug/R.jar
- […]/compose-menuprovider-example/core/build/intermediates/compile_library_classes_jar/release/classes.jar
- […]/compose-menuprovider-example/core/build/intermediates/local_aar_for_lint/release/out.aar
- […]/compose-menuprovider-example/core/build/intermediates/merged_manifest/release/AndroidManifest.xml
- […]/compose-menuprovider-example/core/build/intermediates/renderscript_headers/release/out
- […]/compose-menuprovider-example/core/build/intermediates/symbol_list_with_package_name/release/package-aware-r.txt
- […]/compose-menuprovider-example/core/build/intermediates/full_jar/release/full.jar
- […]/compose-menuprovider-example/core/build/intermediates/compile_r_class_jar/release/R.jar
from dokkatoo.
I have a lead: transformed/ui-release/jars/classes.jar
above does contain the required classes! However, it's not being passed to Dokka. In fact I only see one classes.jar
being passed to Dokka. Maybe jars with duplicate names are being de-duplicated somewhere?
from dokkatoo.
That's wonderful to hear, thanks for the update @MirzaUkas!
from dokkatoo.
Related Issues (20)
- Use Gradle to download & cache package lists HOT 2
- Sub-modules don't inherit the footer message for HTML Dokka docs HOT 2
- Update Dokka to 1.9.0 HOT 3
- README for examples HOT 1
- Empty publication when Kotlin plugin applied to subprojects, but not to root project (with apply=false) HOT 9
- Dependency Dashboard
- Update default Dokka version to 1.9.10 HOT 2
- Warning "Configuration 'dokkatooHtmlResolver' was resolved during configuration time" in Android projects HOT 1
- Add warning when trying to generate a HTML publication with modules, but `all-modules-page-plugin` is not in the plugin classpath
- Consider using different Gradle attributes for `dokkatooHtmlPublicationPluginClasspathApiOnlyConsumable` HOT 9
- How to fix OOM HOT 6
- Compilation error only happening during Dokka build HOT 24
- feature request: support multiple aggregations at the root for the same project HOT 1
- Using dokkatoo in precompiled script plugins causes "Internal Dokkatoo API" warnings HOT 4
- Dokka plugin support HOT 4
- Allow applying Dokkatoo to pure Java projects
- Dokkatoo uses typesafe Attributes, which are bugged in Gradle
- How to keep class with ViewDataBinding - Error class: unknown class and show subModule HOT 5
- Point default Kotlin stdlib external doc URL to new location
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dokkatoo.