kotlinx / ast

Generic AST parsing library for kotlin multiplatform
Apache License 2.0
325 stars 23 forks source link

Publish somewhere different than jitpack.io #89

Open fhoner opened 2 years ago

fhoner commented 2 years ago

Due to unreliability of jitpack.io repository (https://github.com/jitpack/jitpack.io/issues/5239) I wanted to ask if it is possible to publish somewhere else, like maven central or anything. Our builds are constantly failing due to this.

drieks commented 2 years ago

Hello, I am very sorry. Unfortunately, I currently have very little time for this, but I had already considered changing this. If I find time I'll take a look.

alexmiragall commented 1 year ago

Hello @drieks would it be possible to publish this lib in mavenCentral. I'm using this lib currently in an internal tool but I have some restrictions to use it if it is not from mavenCentral. Thank you in advance!

drieks commented 1 year ago

Hi, I already created an account to upload to maven central, but I have to add a github action to build and deploy it.

https://issues.sonatype.org/browse/OSSRH-86438

alexmiragall commented 1 year ago

Oh that's great! Thanks. Do you have an ETA for doing this? I would like to help if needed but I don't think I can from a fork of the library.

drieks commented 1 year ago

Hi @alexmiragall , we need a github action for this, unfortunately I don't have much time at the moment, so I can't give an eta :disappointed:

fab1an commented 1 year ago

Hi, I just tested deployment to mavencentral for my own library using this guide: https://kotlinlang.org/docs/multiplatform-library.html#set-up-publication

Not meaning to nag, but it is really doable in two hours.

Could you maybe release the 1.0.0 version manually without a github action? I want to depend on it in a library.

drieks commented 1 year ago

Hi @fab1an, thank you for the link! I have already setup the maven central upload for antlr-kotlin, only the jar sign is missing. When this library is pbulished on central, it should be easy to publish kotlinx.ast on central. Unfortunately I don't have much time at the moment, if someone could help I would be very happy!

fab1an commented 1 year ago

@drieks Here is a great and simple tutorial:

Please read this section: https://kotlinlang.org/docs/multiplatform-library.html#set-up-publication

  1. Add a new Gradle project inside your library root project. For that, create a new folder named convention-plugins and create a new file build.gradle.kts inside of it.

  2. Place the following code into the new build.gradle.kts file:

plugins {
    `kotlin-dsl` // Is needed to turn our build logic written in Kotlin into the Gradle Plugin
}

repositories {
    gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
}
  1. In the convention-plugins directory, create a src/main/kotlin/convention.publication.gradle.kts file to store all the publication logic.

  2. Add all the required logic in the new file. Be sure to make changes to match your project configuration and where explicitly noted by angle brackets (i.e. ):

import org.gradle.api.publish.maven.MavenPublication
 {...}

import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.signing
import java.util.*

plugins {
   `maven-publish`
    signing
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
    secretPropsFile.reader().use {
        Properties().apply {
            load(it)
        }
    }.onEach { (name, value) ->
        ext[name.toString()] = value
    }
} else {
    ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
    ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
    ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
    ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
    ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}

val javadocJar by tasks.registering(Jar::class) {
    archiveClassifier.set("javadoc")
}

fun getExtraString(name: String) = ext[name]?.toString()

publishing {
    // Configure maven central repository
    repositories {
        maven {
            name = "sonatype"
            setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
            credentials {
                username = getExtraString("ossrhUsername")
                password = getExtraString("ossrhPassword")
            }
        }
    }

    // Configure all publications
    publications.withType<MavenPublication> {
        // Stub javadoc.jar artifact
        artifact(javadocJar.get())

        // Provide artifacts information requited by Maven Central
        pom {
            name.set("MPP Sample library")
            description.set("Sample Kotlin Multiplatform library (jvm + ios + js) test")
            url.set("https://github.com/<your-github-repo>/mpp-sample-lib")

            licenses {
                license {
                    name.set("MIT")
                    url.set("https://opensource.org/licenses/MIT")
                }
            }
            developers {
                developer {
                id.set("<your-github-profile>")
                name.set("<your-name>")
                email.set("<your-email>")
            }
        }
            scm {
                url.set("https://github.com/<your-github-repo>/mpp-sample-lib")
            }
        }
    }
}

// Signing artifacts. Signing.* extra properties values will be used
signing {
    sign(publishing.publications)
}
drieks commented 1 year ago

Hi @fab1an, thank you for the link. The publish task is working (https://github.com/drieks/antlr-kotlin/actions/runs/4536723459/jobs/8409480096), but some validations are not working:

Missing: no javadoc jar found in folder '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-jvm/1.0.0'

failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-jvm/1.0.0/antlr-kotlin-runtime-jvm-1.0.0.pom.asc' does not exist for 'antlr-kotlin-runtime-jvm-1.0.0.pom'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-jvm/1.0.0/antlr-kotlin-runtime-jvm-1.0.0.jar.asc' does not exist for 'antlr-kotlin-runtime-jvm-1.0.0.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-jvm/1.0.0/antlr-kotlin-runtime-jvm-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-runtime-jvm-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-jvm/1.0.0/antlr-kotlin-runtime-jvm-1.0.0.module.asc' does not exist for 'antlr-kotlin-runtime-jvm-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-gradle-plugin/1.0.0/antlr-kotlin-gradle-plugin-1.0.0.module.asc' does not exist for 'antlr-kotlin-gradle-plugin-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-gradle-plugin/1.0.0/antlr-kotlin-gradle-plugin-1.0.0-javadoc.jar.asc' does not exist for 'antlr-kotlin-gradle-plugin-1.0.0-javadoc.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-gradle-plugin/1.0.0/antlr-kotlin-gradle-plugin-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-gradle-plugin-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-gradle-plugin/1.0.0/antlr-kotlin-gradle-plugin-1.0.0.pom.asc' does not exist for 'antlr-kotlin-gradle-plugin-1.0.0.pom'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-gradle-plugin/1.0.0/antlr-kotlin-gradle-plugin-1.0.0.jar.asc' does not exist for 'antlr-kotlin-gradle-plugin-1.0.0.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-windows/1.0.0/antlr-kotlin-runtime-windows-1.0.0.klib.asc' does not exist for 'antlr-kotlin-runtime-windows-1.0.0.klib'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-windows/1.0.0/antlr-kotlin-runtime-windows-1.0.0.pom.asc' does not exist for 'antlr-kotlin-runtime-windows-1.0.0.pom'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-windows/1.0.0/antlr-kotlin-runtime-windows-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-runtime-windows-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-windows/1.0.0/antlr-kotlin-runtime-windows-1.0.0.module.asc' does not exist for 'antlr-kotlin-runtime-windows-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-linux/1.0.0/antlr-kotlin-runtime-linux-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-runtime-linux-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-linux/1.0.0/antlr-kotlin-runtime-linux-1.0.0.pom.asc' does not exist for 'antlr-kotlin-runtime-linux-1.0.0.pom'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-linux/1.0.0/antlr-kotlin-runtime-linux-1.0.0.klib.asc' does not exist for 'antlr-kotlin-runtime-linux-1.0.0.klib'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-linux/1.0.0/antlr-kotlin-runtime-linux-1.0.0.module.asc' does not exist for 'antlr-kotlin-runtime-linux-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-target/1.0.0/antlr-kotlin-target-1.0.0.pom.asc' does not exist for 'antlr-kotlin-target-1.0.0.pom'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-target/1.0.0/antlr-kotlin-target-1.0.0.jar.asc' does not exist for 'antlr-kotlin-target-1.0.0.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-target/1.0.0/antlr-kotlin-target-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-target-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-target/1.0.0/antlr-kotlin-target-1.0.0.module.asc' does not exist for 'antlr-kotlin-target-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-target/1.0.0/antlr-kotlin-target-1.0.0-javadoc.jar.asc' does not exist for 'antlr-kotlin-target-1.0.0-javadoc.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime/1.0.0/antlr-kotlin-runtime-1.0.0.pom.asc' does not exist for 'antlr-kotlin-runtime-1.0.0.pom'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime/1.0.0/antlr-kotlin-runtime-1.0.0-kotlin-tooling-metadata.json.asc' does not exist for 'antlr-kotlin-runtime-1.0.0-kotlin-tooling-metadata.json'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime/1.0.0/antlr-kotlin-runtime-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-runtime-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime/1.0.0/antlr-kotlin-runtime-1.0.0.jar.asc' does not exist for 'antlr-kotlin-runtime-1.0.0.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime/1.0.0/antlr-kotlin-runtime-1.0.0.module.asc' does not exist for 'antlr-kotlin-runtime-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-js/1.0.0/antlr-kotlin-runtime-js-1.0.0.klib.asc' does not exist for 'antlr-kotlin-runtime-js-1.0.0.klib'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-js/1.0.0/antlr-kotlin-runtime-js-1.0.0-sources.jar.asc' does not exist for 'antlr-kotlin-runtime-js-1.0.0-sources.jar'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-js/1.0.0/antlr-kotlin-runtime-js-1.0.0.module.asc' does not exist for 'antlr-kotlin-runtime-js-1.0.0.module'.
failureMessage | Missing Signature: '/io/github/drieks/antlr-kotlin/antlr-kotlin-runtime-js/1.0.0/antlr-kotlin-runtime-js-1.0.0.pom.asc' does not exist for 'antlr-kotlin-runtime-js-1.0.0.pom'.
ftomassetti commented 1 year ago

In a library we publish on Maven Central we do this:

    publications {
        kolasu_core(MavenPublication) {
            from components.java
            artifactId "kolasu-" + project.name
            artifact sourcesJar // you may also want to have this
            artifact javadocJar // these are the javadoc           

Those tasks are defined like this:

    task javadocJar(type: Jar, dependsOn: ":${name}:dokkaJavadoc") {
        archiveClassifier = 'javadoc'
        from "$buildDir/dokka/javadoc"
    }

    task sourcesJar(type: Jar) {
        archiveClassifier = 'sources'
        // See https://discuss.gradle.org/t/why-subproject-sourceset-dirs-project-sourceset-dirs/7376/5
        // Without the closure, parent sources are used for children too
        from { sourceSets.main.allSource }
    }

    tasks.withType(DokkaTask).configureEach {
        dokkaSourceSets {
            named("main") {
                includeNonPublic = true
                moduleName = "kolasu-" + moduleName.get()
                includes.from("README.md")
            }
        }
    }    

In your plugins list you ned:

    id("signing")
    id("org.jetbrains.dokka") version "${dokka_version}"