What is happening? What should have happened instead?
If a package with both java and kotlin source files has package-level annotations in the package-info.java files, I expect the annotations to be present on the DPackage after the java and kotlin DModules have been merged. This was the previous dokka behavior, but between versions and 2.3.0-dev-423 and 2.3.0-dev-424 the behavior changed and the annotations are no longer present on the merged DPackage.
From debugging, this is because the behavior of Annotations.mergeStrategyFor is inconsistent depending on which Annotations is left and which is right:
override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy<AnnotationTarget> =
MergeStrategy.Replace(Annotations(left.myContent + right.myContent))
Because myContent is SourceSetDependent<List<Annotation>>, typealias for Map<DokkaSourceSet, List<Annotation>>. When adding two Maps together, if the same key is present in both Maps, the corresponding entries aren't merged in any way, the second entry is just used. So when merging, if the java package Annotations are left while they empty Annotations from the kotlin DPackage are right, the resultant DPackage has empty Annotations.
Reproducer
/src/com/sample/package-info.java
@Deprecated
package com.sample;
/src/com/sample/Foo.kt
package com.sample
class Foo
/src/com/sample/Bar.java
package com.sample;
public class Bar {}
Dokka version
2.3.0-dev-424
Kotlin Gradle Plugin (KGP) version
No response
Android Gradle Plugin (AGP) version (if applicable)
No response
Build tool
Gradle
Project type
Anything else? (optional)
No response
What is happening? What should have happened instead?
If a package with both java and kotlin source files has package-level annotations in the
package-info.javafiles, I expect the annotations to be present on theDPackageafter the java and kotlinDModules have been merged. This was the previous dokka behavior, but between versions and 2.3.0-dev-423 and 2.3.0-dev-424 the behavior changed and the annotations are no longer present on the mergedDPackage.From debugging, this is because the behavior of
Annotations.mergeStrategyForis inconsistent depending on whichAnnotationsisleftand which isright:Because
myContentisSourceSetDependent<List<Annotation>>, typealias forMap<DokkaSourceSet, List<Annotation>>. When adding twoMaps together, if the same key is present in bothMaps, the corresponding entries aren't merged in any way, the second entry is just used. So when merging, if the java packageAnnotationsareleftwhile they emptyAnnotationsfrom the kotlinDPackageareright, the resultantDPackagehas emptyAnnotations.Reproducer
/src/com/sample/package-info.java/src/com/sample/Foo.kt/src/com/sample/Bar.javaDokka version
2.3.0-dev-424
Kotlin Gradle Plugin (KGP) version
No response
Android Gradle Plugin (AGP) version (if applicable)
No response
Build tool
Gradle
Project type
Anything else? (optional)
No response