Deploy JavaScript Binding to Maven


#1

I’ve create a ThreeJs binding and I like to upload this binding to maven central, but I have no idea how to do this is there a guide somewhere explaining the steps? I’m not asking for general “how to deploy to maven”-guide but specifically how to deploy kotlin code which can be used by other kotlin javascript projects.


#2

Have a look here: https://jitpack.io/docs/#publishing-on-jitpack

Jitpack is the easiest way to publish something on a Maven repository, in this case the JitPack repository. You just need to collect your artifacts as jar files using few tasks in Gradle. You can add sources, documentation and whatever you like. Have a look to an example of mine here.

As you can see from line 43 to 59 I’m declaring the tasks needed to create the artifacts, then on line 61 and 62 I add them to the artifacts collection and the maven plugin and JitPack will do the rest. Of course the project needs to be published on GitHub.

If you need to publish the artifact on a regular maven repo use the maven-publish plugin instead and add something like this in you build.gradle.kts:

publishing {
    repositories {
        maven(url = "URL OF YOUR REPOSITORY HERE")
            .credentials {
                username = "username"
                password = "password"
            }
    }
    version = project.version
    group = project.group
    publications{
        register("mavenJava", MavenPublication::class){
            from(components["java"])
            artifact(sourcesJar)
            artifact(dokkaJar)
        }
    }
}

Of course I am using Kotlin DSL for Gradle :sunglasses:
Hope it helps! :slight_smile: