-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: "Could not determine the dependencies of task ':<project>:dokkatooGenerateModuleHtml'." #122
Comments
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/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! |
I think this is a Gradle bug gradle/gradle#27265. For some reason Gradle forgets about the 'artifactType' being set to 'jar'. |
Hi, any update on this issue? currently, I have a custom build variant in my library modules. |
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: dokkatoo/modules/dokkatoo-plugin/src/main/kotlin/adapters/DokkatooAndroidAdapter.kt Lines 169 to 213 in 8767999
However Gradle seems to get confused and it can't discriminate between all the different options. It also ignores 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 |
I've done a little bit more digging! There are apparently two problems:
|
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
I think this might be possible if you hook into the |
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
The question is how do I get that file... As a very quick and hacky example, if you copy this into the project's 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
And for some reason it's missing ui-android. |
Copy this into an Android project's // 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}" })
}
}
|
I have a lead: |
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. |
Hi, after upgrading to |
That's wonderful to hear, thanks for the update @MirzaUkas! |
I'm trying to add Dokkatoo generation to this Android project (see the feat/dokkatoo branch of my fork). However, running the
:dokkatooGeneratePublicationHtml
task results in the following Gradle error:Expand to view error
(I've also experienced this issue with another project that is yet to be synced)
The version of Dokkatoo used is 2.0.0. Here's a Gradle Build Scan if necessary
The text was updated successfully, but these errors were encountered: