https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
a

addamsson

11/06/2018, 9:14 AM
I have been releasing multiplatform stuff to MC with the old architecture but with this new one it doesn't work. MC only accepts artifacts which have sources jar and javadoc jar and I can't create a javadoc jar out of a common project. With the old way I just released each platform-specific implementation by hand but with
kotlin-multiplatform
this is not an option because they are not separate projects in Gradle.
h

h0tk3y

11/06/2018, 8:36 PM
Yes, sources JARs are created by default, but you need to add Javadoc JARs manually, by using the
publishing { ... }
DSL of the
maven-publish
plugin, basically adding another artifact to all of the publications the
kotlin-multiplatform
plugin creates.
a

addamsson

11/06/2018, 9:39 PM
I tried using dokka
from this example
but this is not working for multiplatform projects
since there is no
java
I'm also not sure where to put the
publishing
part
What is the relationship between
mavenPublication
and
publishing
?
But the whole documentation is very lacking and I was not able to find the source code of the plugin either 😞
h

h0tk3y

11/07/2018, 1:02 PM
publishing { ... }
is the DSL provided by the Gradle
maven-publish
plugin. It contains the publications under the
publications
named domain object collection. The MPP docs describe the names of the publications that the
kotlin-multiplatform
plugin creates by default here: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#publishing-a-multiplatform-library. The
mavenPublication { ... }
is a shorthand for configuring a publication for a specific target, it is equivalent to configuring
publishing { publications { myTargetName { ... } } }
.
The docs coverage will improve over time, for sure. 🙂 Please submit issues (https://kotl.in/issue) for any specific topic that you think is not covered good enough so we can properly monitor this, or submit pull requests to the docs directly if you are willing to contribute.
a

addamsson

11/07/2018, 1:23 PM
I don't see the sources.jar generated in my projects
although I followed the directions to the latter
that's why I asked this here
It would be a great help if I could use
build.gradle.kts
so then I could navigate the source code and see what's there
for example right now I have no idea how I add signed artifacts to my build
which is a prerequisite of publishing to Maven Central
so this is what I have in my config now:
Copy code
kotlin {
    targets {
        fromPreset(presets.jvm, 'jvm') {
            tasks.getByName(compilations.main.compileKotlinTaskName).kotlinOptions {
                jvmTarget = '1.8'
            }
            tasks.getByName(compilations.test.compileKotlinTaskName).kotlinOptions {
                jvmTarget = '1.8'
            }
        }
        fromPreset(presets.js, 'web') {
            tasks.getByName(compilations.main.compileKotlinTaskName).kotlinOptions {
                sourceMap = true
            } 
        }
    }
}
and no sources.jar gets generated, yet the docs state that it will be generated by default
By default, a sources JAR is added to each publication in addition to its main artifact. The sources JAR contains the sources used by the main compilation of the target.
I could add this according to the docs:
Copy code
mavenPublication { 
                artifactId = 'sample-lib-jvm'
                artifact(jvmJavadocJar)
            }
but what's
jvmJavadocJar
? is this some magic variable? Where does it come from? How do I add javadoc for common projects?
even if I add this to my config nothing new gets generated in the
build/libs
directory