Kotlin多平台图书馆项目上传问题-POM多个工件

时间:2019-01-22 23:56:18

标签: gradle kotlin nexus sonatype multiplatform

我们有一个Kotlin多平台库项目,该项目带有一个构建脚本,该脚本使用“旧式”子项目的结构和流程为各种平台(即JS,JVM)进行构建。在此系统下,产生的工件可以成功上传到我们的Sonatype Nexus存储库(根build.gradle包含在下面的(1)中)。

我们现在正尝试转换为“新型”的Kotlin多平台方法/结构(Building Multiplatform Projects with Gradle),但是当我们尝试将工件上传到仓库时会遇到以下错误(修改后的root build.gradle包含在下面的(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'.

有人知道我们为什么会收到此错误吗?

在构建过程中创建的每个工件的设置似乎都需要在脚本中进行更新,但是我们不确定该怎么做。

谢谢!

(1)原始(“旧式”多平台)根目录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)更新了(“新型”多平台)根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 {
        }
    }
}

0 个答案:

没有答案