How to rename jar file that's being published using Gradle with maven-publish and shadow plugins?

1.3k Views Asked by At

Basically what I'm trying to do is publish a jar file to GitHub Packages with a certain name. What I have now is:

shadowJar {
    archiveFileName = "Some-Name-${parent.version}.${extension}"
}

publishing {

   ...

    publications {
        shadow(MavenPublication) { publication ->
            project.shadow.component(publication)
            artifactId = 'me.project'
            groupId = 'some-project'
            version = 1.1.0
            
        }
    }
}

But from this I get some-project-1.1.0-all.jar, I would like to get some-project-1.1.0.jar but cant seem to find the way how. Changing the archiveFileName in the shadowJar task doesn't seem to affect the publishing jar only the build jar.

1

There are 1 best solutions below

1
On BEST ANSWER

I believe you need to change the archiveClassifier of the shadowJar task. By default, this is configured as all.

Something like:

tasks.shadowJar {
    archiveClassifier = ""
}

The shadowJar task extends of the Jar task type. By default, with the Java plugin, archiveClassifier is configured as an empty String "". The Shadow plugin reconfigures its shadowJar task with all.