# Kotlin MPP and gradle - local maven publication does not work with .kts script

**URL:** <https://discuss.kotlinlang.org/t/kotlin-mpp-and-gradle-local-maven-publication-does-not-work-with-kts-script/28025>\
**Category:** Multiplatform\
**Created:** [January 26, 2024, 3:14pm UTC](https://discuss.kotlinlang.org/t/kotlin-mpp-and-gradle-local-maven-publication-does-not-work-with-kts-script/28025 "2024-01-26T15:14:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vk](https://avatars.discourse-cdn.com/v4/letter/v/cab0a1/32.png) [@vk](https://discuss.kotlinlang.org/u/vk)\
**Post date:** [January 26, 2024, 3:14pm UTC](https://discuss.kotlinlang.org/t/kotlin-mpp-and-gradle-local-maven-publication-does-not-work-with-kts-script/28025/1 "2024-01-26T15:14:27Z")

</div>

Another day - another glitch from gradle.

Can anybody explain please, why Kotlin MPP project setup with groovy script publishes artifacts to local maven repo, and almost identical .kts variant does not do it?

**Groovy:**

```auto
buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VER"
    }
}

plugins {
    id 'org.jetbrains.kotlin.multiplatform' version "$KOTLIN_VER"
    id 'maven-publish'
}

allprojects {
    version '0.0-SNAPSHOT'
    group 'com.gradleglicthes'

    repositories {
        mavenCentral()
        mavenLocal()
    }

}

subprojects {

    // maven publication
    apply plugin: 'maven-publish'
    apply plugin: 'org.jetbrains.kotlin.multiplatform'

    publishing {
        repositories {
            mavenLocal()
        }
    }

    kotlin {
        js {
            browser {
                testTask {
                    enabled = false
                }
            }
            binaries.executable()
        }.compilations.configureEach {
            kotlinOptions.noStdlib = "false"
            kotlinOptions.sourceMap = "true"
            kotlinOptions.sourceMapEmbedSources = "always"

            kotlinOptions.metaInfo = true
        }

        jvm().compilations.configureEach {
            kotlinOptions.jvmTarget = "1.8"
        }

        sourceSets {
            commonMain {
                dependencies {
                    implementation kotlin('stdlib')
                }
            }

            jvmMain {
                dependencies {
                    implementation kotlin('reflect')
                }
            }

            commonTest {
                dependencies {
                    implementation kotlin("test")
                }
            }
        }
    }
}

kotlin {
    jvm()
}

```

**Kotlin DSL:**

```auto
val kotlinVersion = extra["KOTLIN_VER"] as String

repositories {
    mavenCentral()
    mavenLocal()
}

plugins {
    kotlin("multiplatform") version "1.9.20"
    id("maven-publish")
}

group = "com.gradleglicthes"
version = "0.0-SNAPSHOT"

subprojects {
    repositories {
        mavenCentral()
        mavenLocal()
    }

    apply(plugin = "maven-publish")
    apply(plugin = "org.jetbrains.kotlin.multiplatform")

    publishing {
        repositories {
            mavenLocal()
        }
    }

    kotlin {
        js {
            browser {
                testTask {
                    enabled = false
                }
            }
            binaries.executable()
        }.compilations.configureEach {
            kotlinOptions.noStdlib = false
            kotlinOptions.sourceMap = true
            kotlinOptions.sourceMapEmbedSources = "always"

            kotlinOptions.metaInfo = true
        }

        jvm().compilations.configureEach {
            kotlinOptions.jvmTarget = "1.8"
        }

        sourceSets {
            commonMain {
                dependencies {
                    implementation(kotlin("stdlib"))
                }
            }

            jvmMain {
                dependencies {
                    implementation(kotlin("reflect"))
                }
            }

            commonTest {
                dependencies {
                    implementation(kotlin("test"))
                }
            }
        }
    }
}

kotlin {
    jvm()
}

```

Example with two project variants is attached:  
[MavenPublicationWithKts.zip](https://discuss.kotlinlang.org/uploads/short-url/cG0Nnm8lu2vIZIGnBbOlk2gIVtZ.zip) (5.4 KB)

The command I am running:  
`gradle clean build publishToMavenLocal`

And JetBrains ticket on this: [https://youtrack.jetbrains.com/issue/KT-65340/Kotlin-MPP.-Publishing-to-maven-local-repo-works-with-groovy-and-does-not-work-with-kts](https://youtrack.jetbrains.com/issue/KT-65340/Kotlin-MPP.-Publishing-to-maven-local-repo-works-with-groovy-and-does-not-work-with-kts)
