【问题标题】:Remove "-all" suffix in name of JAR, when it is published by maven-publish gradle plugin删除 JAR 名称中的“-all”后缀,当它由 maven-publish gradle 插件发布时
【发布时间】:2019-01-14 17:31:21
【问题描述】:

maven-publish 插件以“project-1.0-all.jar”格式发布名称的 JAR

我使用了 Maven,一切正常。现在我已经使用 maven-publish 插件迁移到 Gradle。

这是我的publishing Gradle 构建脚本部分

    publishing {
        publications {
            create<MavenPublication>("mavenJava") {
                artifact(this@run["shadowJar"])
                pom {

                    artifactId = project.name
                    groupId = project.group.toString()
                    packaging = "jar"

                    name.set(project.name)
                    description.set(project.description)
                    url.set("https://gitlab.com/otherwise.su/config")
                    inceptionYear.set("2018")
                    licenses {
                        license {
                            comments.set("Open-source license")
                            distribution.set("repo")
                            name.set("Лицензия")
                            url.set("https://gitlab.com/otherwise.su/config/blob/master/LICENSE.md")
                        }
                    }
                    developers {
                        developer {
                            email.set("postovalovya@gmail.com")
                            id.set("CMDR_Tvis")
                            name.set("Commander Tvis")
                            roles.set(listOf("architect", "developer"))
                            timezone.set("Russian Federation/Novosibirsk")
                            url.set("https://gitlab.com/CMDR_Tvis")
                        }
                    }

                }
            }
        }
        repositories {
            maven("https://gitlab.com/api/v4/projects/10077943/packages/maven") {
                credentials(HttpHeaderCredentials::class) {
                    name = "Job-Token"
                    value = System.getenv("CI_JOB_TOKEN")
                }
                authentication { register("header", HttpHeaderAuthentication::class) }
            }
        }
    }

这是我完整的build-script

预期:

名称格式为“project-1.0.jar”的 JAR 已发布。

实际:

名称格式为“project-1.0-all.jar”的 JAR 已发布。

【问题讨论】:

    标签: maven gradle kotlin maven-publish


    【解决方案1】:

    要更改已发布工件的 JAR 分类器,请替换

    artifact(this@run["shadowJar"])
    

    artifact(this@run["shadowJar"]) {
        classifier = null
    }
    

    这应该删除由 Shadow 插件设置为分类器的 all 后缀。

    【讨论】:

      猜你喜欢
      • 2021-12-25
      • 2019-06-08
      • 2021-08-04
      • 2015-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-31
      相关资源
      最近更新 更多