Status Update
Comments
ki...@gmail.com <ki...@gmail.com> #2
Using the latest AGP 8.3.0 is still able to reproduce it.
we...@iherb.com <we...@iherb.com> #3
bo...@google.com <bo...@google.com>
je...@google.com <je...@google.com>
ga...@google.com <ga...@google.com> #4
Running
val resolvableConfiguration: Configuration = project.configurations.detachedConfiguration().also {
it.attributes.run<AttributeContainer, Unit> {
attribute(
Category.CATEGORY_ATTRIBUTE,
project.objects.named(Category::class.java, Category.DOCUMENTATION)
)
attribute(Attribute.of("artifactType", String::class.java), ArtifactTypeDefinition.JAR_TYPE)
attribute(
DocsType.DOCS_TYPE_ATTRIBUTE,
project.objects.named(DocsType::class.java, DocsType.SOURCES)
)
}
}
resolvableConfiguration.dependencies.add(project.dependencies.create("com.jakewharton.timber:timber:5.0.1"))
val artifacts = resolvableConfiguration.incoming.artifactView {
this.lenient(true)
}.artifacts
tasks.register("fetchSources").configure {
doFirst {
artifacts.forEach {
println("${it.id} with file ${it.file}")
}
}
}
does not print anything, and this is how sources are fetched in the IDE. I've reached out to Gradle to check if this is an issue on their end.
On the publishing side,
ga...@google.com <ga...@google.com> #5
Gradle team confirmed this is working as intended from the Gradle side: if libraries are using Gradle metadata it is expected that all variants (e.g. API/runtime/javadoc/sources) are specified in that file. E.g.:
https://repo1.maven.org/maven2/io/coil-kt/coil/2.6.0/coil-2.6.0.module contains sources (releaseVariantReleaseSourcePublication
)https://repo1.maven.org/maven2/io/coil-kt/coil/1.4.0/coil-1.4.0.module does not contain sources (it hasreleaseApiPublication
andreleaseRuntimePublication
)https://repo1.maven.org/maven2/com/jakewharton/timber/timber/5.0.1/timber-5.0.1.module does not contain sources
Can you please file a bug on
As a temporary workaround, you can add
@CacheableRule
abstract class SourcesAndJavadocVariantRule : ComponentMetadataRule {
@get: Inject
abstract val objectFactory: ObjectFactory
override fun execute(ctx: ComponentMetadataContext) {
if(ctx.getDescriptor(IvyModuleDescriptor::class.java) != null) {
return
}
val id = ctx.details.id
val coordinates = id.group + ":" + id.name + ":" + id.version
val allowed = setOf(
"com.jakewharton.timber:timber:5.0.1",
"io.coil-kt:coil:1.4.0",
)
if (coordinates !in allowed) return
ctx.details.addVariant("derived-sources") {
this.attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objectFactory.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objectFactory.named(DocsType.SOURCES))
}
this.withFiles {
this.addFile("${id.name}-${id.version}-sources.jar")
}
}
ctx.details.addVariant("derived-javadoc") {
this.attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objectFactory.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objectFactory.named(DocsType.JAVADOC))
}
this.withFiles {
this.addFile("${id.name}-${id.version}-javadoc.jar")
}
}
}
}
project.dependencies.components.all(SourcesAndJavadocVariantRule::class.java)
to the mylibrary/build.gradle.kts
(or even better to where your build logic is). This will create synthetic variants for sources/doc for Timber and Coil (1.4.0). With this the IDE will fetch sources/javadoc. However, the real fix is on the publishing side of Timber. Thanks!
ki...@gmail.com <ki...@gmail.com> #6
We have a lot of internal libraries with various versions. Each library
may depend on another with a different version. How do I apply this to all
libraries (will all exist versions)? Shouldn't the Gradle team fix this
issue? The real problem is that. when we use the new IDE version (from
Iguana), we cannot navigate to the source code of the old version of our
existing libraries. For example, this easily happened when we traced the
bug from the library project that has an old version of dependencies. The
change from Gradle is impacting so much on our daily tasks.
On Tue, Mar 26, 2024 at 2:09 AM <buganizer-system@google.com> wrote:
ki...@gmail.com <ki...@gmail.com> #7
ga...@google.com <ga...@google.com> #8
I think there are 2 things you can do:
- update the bit in the snippet in #5 that filters libraries. E.g. if you'd like to add synthetic variants for all libraries from a particular Maven group, you can do
if (ctx.details.id.group == "com.company") { ... ctx.details.addVariant(...) }
- Publish internal libraries with sources/javadoc in Gradle metadata file. See for
and seepublishing Java libraries .publishing Android libraries
Also, if you feel like this limitation is too strict, please file an issue at
Thanks!
ga...@google.com <ga...@google.com> #9
We are going to add a workaround in Android Studio to handle this scenario. Eventually, this should be fixed by the library authors and Gradle metadata should contain javadoc and sources. The workaround is going to add some overhead on the 1st project import, but there is no way around it (except for adding snippets similar to #5). Also, another thing to keep in mind is that some AndroidX libraries started shipping code samples, and for those to work we need to use ArtifactView
to resolve sources.
With that in mind, the workaround is:
- in
AdditionalClassifierArtifactsModelBuilder.buildAll
collect javadoc/sources for all libraries usingArtifactView
(com.android.ide.gradle.model.artifacts.builder.AdditionalClassifierArtifactsModelBuilder#getArtifacts
) - keep track of every library for which sources were not fetched (
missingJavadocArtifacts
), and for every library which javadoc was not fetched (missingSourcesArtifacts
) - use
getJavadocAndSourcesWithArtifactResolutionQuery
to query javadoc and sources for of these artifacts.
We cannot switch entirely to getJavadocAndSourcesWithArtifactResolutionQuery
because samples sources published from AndroidX will be missing.
ga...@google.com <ga...@google.com> #10
Increased to P1/S0 based on increased number of comments from
bi...@google.com <bi...@google.com>
bi...@google.com <bi...@google.com> #11
Fixed with I70a827338a7578a79773416adf0eafab2ff6ec45
an...@google.com <an...@google.com> #12
Thank you for your patience while our engineering team worked to resolve this issue. A fix for this issue is now available in:
- Android Studio Koala | 2024.1.1 Canary 8
- Android Gradle Plugin 8.5.0-alpha08
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
Thank you for taking the time to submit feedback — we really appreciate it!
an...@google.com <an...@google.com> #13
The fixes for this issue are now also available in:
- Android Studio Jellyfish | 2023.3.1 Patch 1
- Android Gradle Plugin 8.4.1
We encourage you to try the latest update.
If you notice further issues or have questions, please file a new bug report.
di...@gmail.com <di...@gmail.com> #14
Responden menyatakan fungsional
tt...@gmail.com <tt...@gmail.com> #15
Thank you
ha...@gmail.com <ha...@gmail.com> #16
How can I add this library in android studio koala
implementation 'com.plattysoft.leonids:LeonidsLib:1.3.2'
Description