I have troubles to publish a Kotlin/JS library to ...
# javascript
h
I have troubles to publish a Kotlin/JS library to the local maven repository. Here's my
build.gradle.kts
file:
Copy code
plugins {
    kotlin("js") version "1.4.10"
    id("org.jetbrains.dokka") version "1.4.10"
    `maven-publish`
}

group = "dev.fritz2"
version = "0.8-SNAPSHOT"

repositories {
    mavenLocal()
    mavenCentral()
    maven("<https://oss.jfrog.org/artifactory/jfrog-dependencies>")
    maven("<https://oss.sonatype.org/content/repositories/snapshots/>")
    jcenter()
}

dependencies {
    implementation("dev.fritz2:core:0.8-SNAPSHOT")
}

kotlin {
    explicitApi()
    js {
        browser {
            testTask {
                useKarma {
                    useChromeHeadless()
                }
            }
        }
    }
}
If I execute
gradle publishToMavenLocal
nothing gets published to my local maven repo. I remember this worked sometime ago. Does anybody else facing the same issue? The code / project is also available on GitHub: https://github.com/hpehl/fritz2-elemento
v
You didn't define any publication that could be published.
Read the docs of the
maven-publish
plugin 😉
h
Thanks @Vampire, I already read the
maven-publish
plugin documentation (e.g. https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:complete_example). Problem is that the documentation refers to Java libraries and I don't know how to apply to Kotlin/JS.
v
Well, the question is what you want to publish to Maven Central probably. Or do you maybe want to publish to NPM? For that a community plugin exists.
h
The library I want to publish should be consumed by other Kotlin/JS libs and apps. NPM is no option atm.
Workaround is to switch to
Copy code
kotlin("multiplatform") version "1.4.10"
Now the lib gets published w/o any further configuration.
b
For npm publishing check out npm-publish (integrates seemlesly with both, multiplatform and js plugins)
Odd that K/JS plugin does not setup publications for you...
h
Thanks @Big Chungus. Yeah seems to be a bug in K/JS compared to MPP.
b
Probably worth raising a youtrack as both plugins are built from the same codebase
h
Seems I'm not the only one with this issue: https://youtrack.jetbrains.com/issue/KT-36132
👍 1
r
you can check https://github.com/rjaros/navigo-kotlin to see how to setup publication to maven/bintray from kotlin/js project
❤️ 1
h
👍