Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

android - Maven publication with documentation

I am trying to include the documentation into maven publication. The publication itself works fine. I can also publish with the setup bellow sources and javadoc to gitlab packages. I can download and open the javadoc.jar and sources.jar which contains those comments/documentation of classes. However when I include that library as a dependency to my android app as a gradle dependency, I can not see the comments on my interfaces/classes with F1 or when I open that class.

Any help would be appreciated.

Using kotlin DSL

    id("maven-publish")
    id("org.jetbrains.dokka")
tasks {
    dokka {
        outputFormat = "javadoc"
        outputDirectory = "$buildDir/javadoc"
        moduleName = rootProject.name
    }
}

val dokkaJar by tasks.creating(Jar::class) {
    group = JavaBasePlugin.DOCUMENTATION_GROUP
    description = "Assembles Kotlin docs with Dokka"
    archiveClassifier.set("javadoc")
    from(tasks.dokka)
    dependsOn(tasks.dokka)
}

val sourcesJar by tasks.registering(Jar::class) {
    archiveClassifier.set("sources")
    from(android.sourceSets.getByName("main").java.srcDirs)
}

artifacts {
    archives(sourcesJar)
    archives(dokkaJar)
}
afterEvaluate {
    publishing {
        publications {
            create<MavenPublication>("snapshot_aar") {
                groupId = libGroupId
                artifactId = libArticactId
                version = getVersionNameForSnapshot()
                artifact(tasks.getByName("bundleDebugAar"))
                artifact(dokkaJar)
                artifact(sourcesJar)

                pom.withXml {
                    fun groovy.util.Node.addDependency(dependency: Dependency) {
                        appendNode("dependency").apply {
                            appendNode("groupId", dependency.group)
                            appendNode("artifactId", dependency.name)
                            appendNode("version", dependency.version)
                        }
                    }

                    asNode().appendNode("dependencies").let { dependencies ->
                        configurations.api.get().allDependencies.forEach {
                            dependencies.addDependency(it)
                        }
                        configurations.implementation.get().allDependencies.forEach {
                            dependencies.addDependency(it)
                        }
                    }
                }
            }
...
question from:https://stackoverflow.com/questions/65934402/maven-publication-with-documentation

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...