11

We have a Kotlin multi-platform library project with a build script which builds for various platforms, i.e. common, JS & JVM, using the "old-style" sub-project structure and processes. Under this system, the artifacts produced can be successfully uploaded to our Sonatype Nexus repo (the root build.gradle is included below (1)).

We are now trying to convert to the "new-style" Kotlin multi-platform approach/structure (Building Multiplatform Projects with Gradle), but we are getting the following error when we try to upload the artifacts to the repo (the modified root build.gradle included below (2)):

BUILD FAILED in 0s
8 actionable tasks: 1 executed, 7 up-to-date
A POM cannot have multiple artifacts with the same type and classifier. Already have MavenArtifact objjson-metadata:jar.asc:asc:null, trying to add MavenArtifact objjson-metadata:jar.asc:asc:null.
10:36:52: Task execution finished 'uploadArchives'.

Does anyone know why we get this error?

The settings for each artifact created during the build seem to need to be updated in the script, but we are not sure how to do that.

Thanks in advance!

(1) Original ("old-style" multi-platform) root build.gradle:

buildscript {
    ext.kotlinVersion = '1.2.61'

    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
    }
}

plugins {
    id 'io.codearte.nexus-staging' version '0.11.0'
}

allprojects {
    group 'nz.salect.objJSON'
    version '0.24-SNAPSHOT'
}

ext {
    libraries = [
            kotlin_stdlib                 : "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
            kotlin_stdlib_common          : "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
            kotlin_stdlib_js              : "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",

            kotlin_reflect_lib            : "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",

            kotlin_test                   : "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
            kotlin_test_common            : "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
            kotlin_test_js                : "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
            kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion",

            kotlin_test_junit             : "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion",
    ]
}

subprojects {
    repositories {
        jcenter()
        mavenCentral()
    }

    //Nexus/Maven upload settings
    apply plugin: 'com.bmuschko.nexus'

    modifyPom {
        project {
            name 'objJSON'
            description 'A JSON serialization library fully implemented in Kotlin.'
            url 'https://bitbucket.org/objdict/objjson'
            inceptionYear '2016'

            scm {
                url 'https://bitbucket.org/objdict/objjson'
                connection 'scm:https://bitbucket.org/objdict/objjson.git'
                developerConnection 'scm:git://bitbucket.org/objdict/objjson.git'
            }

            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }

            developers {
                developer {
                    id 'xxx'
                    name 'xxx'
                    email 'xxx'
                }
            }
        }
    }

    extraArchive {
        sources = true
        tests = true
        javadoc = true
    }

    nexus {
        sign = true
        repositoryUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
        snapshotRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
    }
    //End Nexus/Maven upload settings
}


nexusStaging {
    packageGroup = "nz.salect"
}

(2) Updated ("new-style" multi-platform) root build.gradle:

buildscript {
    ext.kotlinVersion = "1.3.11"

    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    }

    dependencies {
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
        classpath("com.bmuschko:gradle-nexus-plugin:2.3.1")
    }
}

plugins {
    // from the multiplatform reference file
    id "kotlin-multiplatform" version "1.3.11"

    id "maven-publish"
    id "io.codearte.nexus-staging" version "0.11.0"
    //Nexus/Maven upload settings
    //id "bmuschko.nexus"
}
    //Nexus/Maven upload settings
    apply plugin: "com.bmuschko.nexus"


//ext { - all moved to buildSrc
//    libraries = [
//            kotlin_stdlib: "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
//            kotlin_stdlib_common: "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
//            kotlin_stdlib_js: "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion",
//
//            kotlin_reflect_lib: "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion",
//
//            kotlin_test: "org.jetbrains.kotlin:kotlin-test:$kotlinVersion",
//            kotlin_test_common: "org.jetbrains.kotlin:kotlin-test-common:$kotlinVersion",
//            kotlin_test_js: "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion",
//            kotlin_test_annotations_common: "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlinVersion",
//
//            kotlin_test_junit: "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion",
//    ]
//}

allprojects {
    group "nz.salect.objJSON"
    version Share.version

    repositories {
        jcenter()
        mavenCentral()
    }

    modifyPom {
        project {
            name "objJSON"
            description "A JSON serialization library fully implemented in Kotlin."
            url "https://bitbucket.org/objdict/objjson"
            inceptionYear "2016"

            scm {
                url "https://bitbucket.org/objdict/objjson"
                connection "scm:https://bitbucket.org/objdict/objjson.git"
                developerConnection "scm:git://bitbucket.org/objdict/objjson.git"
            }

            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "repo"
                }
            }

            developers {
                developer {
                    id "xxx"
                    name "xxx"
                    email "xxx"
                }
            }
        }
    }

    extraArchive {
        sources = true
        tests = true
        javadoc = true
    }

    nexus {
        sign = true
        repositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
        snapshotRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
    }
    //End Nexus/Maven upload settings
}

nexusStaging {
    packageGroup = "nz.salect"
}

repositories {
    mavenCentral()
}


kotlin {
    targets {
        fromPreset(presets.jvm, "jvm") {
            mavenPublication {
                artifactId = "objjson-jvm"
            }
        }
        fromPreset(presets.js, "js") {
            mavenPublication {
                artifactId = "objjson-js"
            }
        }
        // For ARM, preset should be changed to presets.iosArm32 or presets.iosArm64
        // For Linux, preset should be changed to e.g. presets.linuxX64
        // For MacOS, preset should be changed to e.g. presets.macosX64
        //fromPreset(presets.mingwX64, "mingw")
    }
    sourceSets {
        commonMain {
            dependencies {
                implementation("$Libraries.kotlin_stdlib_common")
                implementation("$Libraries.kotlin_reflect_lib")
            }
        }
        commonTest {
            dependencies {
                implementation("$Libraries.kotlin_test_common")
                implementation("$Libraries.kotlin_test_annotations_common")
            }
        }
        jvmMain {
            dependencies {
                implementation("$Libraries.kotlin_stdlib")
                implementation("$Libraries.kotlin_reflect_lib")
            }
        }
        jvmTest {
            dependencies {
                implementation("$Libraries.kotlin_test")
                implementation("$Libraries.kotlin_test_junit")
            }
        }
        jsMain {
            dependencies {
                implementation("$Libraries.kotlin_stdlib_js")
            }
        }
        jsTest {
            dependencies {
                implementation("$Libraries.kotlin_test_js")
            }
        }
        mingwMain {
        }
        mingwTest {
        }
    }
}
gloc.mike
  • 344
  • 1
  • 9

0 Answers0