Hi there, has anyone tried to create a KMM module ...
# multiplatform
p
Hi there, has anyone tried to create a KMM module and publish it as a native Android library on maven? My understanding is that this is not possible because of the transitive dependencies that may exists in KMM module. I would like to hear your thoughts.
p
It's a pure aar if you publish
b
Sure it's possible. Here's a template for you github.com/mpetuska/template-kmp-library
p
@Big Chungus thanks I will check.
Have you tested on a native Android application as a maven dependency?
p
It's really the standard. There is nothing else than native, its really just jvm bytecode
As you are probably using coroutines that's already a multiplatform lib you are already consuming as a jar
p
Let me be more specific. With the setup below:
Copy code
project.afterEvaluate {
    publishing {
        publications {

            localLibrary(MavenPublication) {
                groupId LIB_GROUP_ID
                artifactId LIB_ARTIFACT_ID
                version '1.0.0-beta'
                artifact(sourceJar)
                artifact (bundleReleaseAar)

                //generate pom nodes for dependencies
                pom.withXml {
                    def dependenciesNode = asNode().appendNode('dependencies')
                    configurations.compile.allDependencies.each { dependency ->
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', dependency.group)
                        dependencyNode.appendNode('artifactId', dependency.name)
                        dependencyNode.appendNode('version', dependency.version)
                    }
                }
            }
        }
    }
}
the publishLocalLibraryPublicationToMavenLocal gradle finishes with success but the pom file does not contain any depedencies.
update: changing the
Copy code
configurations.compile.allDependencies
to
Copy code
configurations.implementation.allDependencies
seems to add the androidMain depedencies but not the commonMain
update2: changing to
Copy code
configurations.releaseRuntimePublication.allDependencies
seems to work just fine and it adds all dependencies correctly