Remove "-all" suffix in name of JAR, when it is published by maven-publish gradle plugin
Asked Answered
A

1

7

maven-publish plugin posts JAR with name in format of "project-1.0-all.jar"

I used Maven, everything was OK. Now I've migrated to Gradle with maven-publish plugin.

Here is my publishing Gradle build-script section

    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("[email protected]")
                            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) }
            }
        }
    }

Here's my full build-script.

Expected:

JAR with name by format "project-1.0.jar" is published.

Actual:

JAR with name by format "project-1.0-all.jar is published.

Aglaia answered 14/1, 2019 at 17:31 Comment(0)
C
5

To change the JAR classifier for the published artifact, replace

artifact(this@run["shadowJar"])

with

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

This should remove the all suffix that is set as a classifier by the Shadow plugin.

Carlyn answered 14/1, 2019 at 17:59 Comment(1)
In Gradle: shadowJar { archiveBaseName.set('baseName') classifier = null }Outcurve

© 2022 - 2024 — McMap. All rights reserved.