Repository: GradleUp/shadow (kotlin)

Issue:
"-all" classifier dropped from published jar
When publishing a Maven artifact using Shadow 8.1.1, the "-all" classifier is dropped from the jar file. 

This happens for both local publishing and to remote repositories, too. 
  
### Shadow Version
8.1.1

### Gradle Version
8.1

### Expected Behavior
Building using Shadow 8.1.0
  ```
    rm -rf build && rm -rf ${local-maven-repo} && gw publishToMavenLocal
  ```
produces the following artifacts:
  ```
    /Users/hexagonsun/.m2/repository/net/hexagon/sun/foo$find .
    .
    ./dev-local
    ./dev-local/foo-dev-local.pom
    ./dev-local/foo-dev-local-all.jar
    ./maven-metadata-local.xml
  ```
### Actual Behavior
Building with Shadow 8.1.1
  ```
    rm -rf build && rm -rf ${local-maven-repo} && gw publishToMavenLocal
  ```
produces the following artifacts:
  ```
    /Users/hexagonsun/.m2/repository/net/hexagon/sun/foo$find .
    .
    ./dev-local
    ./dev-local/foo-dev-local.pom
    ./dev-local/foo-dev-local.jar
    ./maven-metadata-local.xml
  ```
Note that the jar is lacking the `-all` qualifier.

In both cases, i.e. with Shadow 8.1.0 as well as the new 8.1.1, the shadow-jar of the application's `build` directory correctly contains the `-all` classifier:
  ```
    /Users/hexagonsun/dev/foo/build$find . -iname "*.jar"
    ./libs/foo-dev-local-all.jar
  ```

### Gradle Build Script(s)
```
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
    val kotlinVersion = "1.8.20"

    application
    `maven-publish`
    kotlin("jvm") version kotlinVersion
    id("com.github.johnrengelman.shadow") version "8.1.1"
}

group = "net.hexagon.sun.foo"
version = "dev-local"

repositories {
    val mavenCentralProxyUrl: String by properties
    maven { url = uri(mavenCentralProxyUrl) }
}

dependencies {
    implementation(kotlin("stdlib"))
}

application {
    mainClass.set("net.hexagon.sun.foo.ApplicationKt")
}

tasks {
    withType<ShadowJar> {
        archiveClassifier.set("all")
    }
}

publishing {
    publications {
        create<MavenPublication>("shadow") {
            project.shadow.component(this)
        }
    }
}

```

Note that the line `archiveClassifier.set("all")` is not relevant: the same problem occurs when it is missing.

### Content of Shadow JAR (`jar tf <jar file>` - post link to GIST if too long)

I don't think this is relevant, since the content is fine. Let me know if I should supply it.
The behavior can be reproduced using a default `Application.kt` file.
```
package net.hexagon.sun.foo

fun main() {
}
```

Pull request description:
It seems that after [960617f](https://github.com/johnrengelman/shadow/commit/960617fc1689e60763e650492e3bf1df88d5a0fc), archive classifiers are dropped from the archive file name due to the addition of the artifact via `publication.artifact(File)`. According to the [Gradle docs](https://docs.gradle.org/current/javadoc/org/gradle/api/publish/maven/MavenPublication.html#artifact-java.lang.Object-)
> Extension and classifier values are interpolated from the file name.

but for some reason it is not happening in `ShadowExtension`.

This PR provides a workaround by explicitly adding the classifier using the option to pass a `Map` to `MavenPublication#artifact`:
> A Map that contains a 'source' entry that can be resolved as any of the other input types, including file. This map can contain a 'classifier' and an 'extension' entry to further configure the constructed artifact.

- Closes #860.
- Closes #945.

Patch:
diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md
index efaf578ac..29410d6a9 100644
--- a/src/docs/changes/README.md
+++ b/src/docs/changes/README.md
@@ -1,5 +1,18 @@
 # Change Log
 
+
+## [Unreleased]
+
+**Added**
+
+**Changed**
+
+**Fixed**
+
+- Explicitly add classifier to maven publication. ([#904](https://github.com/GradleUp/shadow/pull/904))
+
+
+
 ## [v8.3.0]
 
 **Changed**
@@ -364,4 +377,4 @@ Instead, use the `enableRelocation = true` and `relocationPrefix = "<new package
 [v8.3.0]: https://github.com/GradleUp/shadow/releases/tag/8.3.0
 [v8.1.1]: https://github.com/GradleUp/shadow/releases/tag/8.1.1
 [v8.1.0]: https://github.com/GradleUp/shadow/releases/tag/8.1.0
-[v8.0.0]: https://github.com/GradleUp/shadow/releases/tag/8.0.0
\ No newline at end of file
+[v8.0.0]: https://github.com/GradleUp/shadow/releases/tag/8.0.0
diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.groovy
index 865b3a3e1..03a575d54 100644
--- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.groovy
+++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.groovy
@@ -5,16 +5,20 @@ import org.gradle.api.Project
 import org.gradle.api.artifacts.ProjectDependency
 import org.gradle.api.artifacts.SelfResolvingDependency
 import org.gradle.api.file.RegularFile
+import org.gradle.api.provider.Property
 import org.gradle.api.provider.Provider
 import org.gradle.api.publish.maven.MavenPom
 import org.gradle.api.publish.maven.MavenPublication
 
 class ShadowExtension {
-    private final Provider<Provider<RegularFile>> archiveFile
+    private final Provider<Archive> archive
     private final Provider<List<Dep>> allDependencies
 
     ShadowExtension(Project project) {
-        archiveFile = project.provider { project.tasks.withType(ShadowJar).getByName("shadowJar").archiveFile }
+        archive = project.provider {
+            def archiveTask = project.tasks.withType(ShadowJar).getByName("shadowJar")
+            new Archive(archiveTask.archiveFile, archiveTask.archiveClassifier)
+        }
         allDependencies = project.provider {
             project.configurations.getByName("shadow").allDependencies.collect {
                 if ((it instanceof ProjectDependency) || !(it instanceof SelfResolvingDependency)) {
@@ -25,7 +29,10 @@ class ShadowExtension {
     }
 
     void component(MavenPublication publication) {
-        publication.artifact(archiveFile.get())
+        publication.artifact([
+                source    : archive.get().file,
+                classifier: archive.get().classifier.get()
+        ])
 
         // Don't inline this variable, it seems Groovy closure capturing is confused by the field instead of a local variable.
         final def allDeps = allDependencies
@@ -43,6 +50,16 @@ class ShadowExtension {
         }
     }
 
+    private class Archive {
+        Provider<RegularFile> file
+        Property<String> classifier
+
+        Archive(Provider<RegularFile> file, Property<String> classifier) {
+            this.file = file
+            this.classifier = classifier
+        }
+    }
+
     private class Dep {
         String group
         String name


Test patch:
diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy
index 3c18f81a7..7daefa46f 100644
--- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy
+++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy
@@ -78,6 +78,54 @@ class PublishingSpec extends PluginSpecification {
         assert dependency.version.text() == '1.0'
     }
 
+    def "publish shadow jar with maven-publish plugin using custom classifier and extension"() {
+        given:
+        repo.module('shadow', 'a', '1.0')
+                .insertFile('a.properties', 'a')
+                .insertFile('a2.properties', 'a2')
+                .publish()
+        repo.module('shadow', 'b', '1.0')
+                .insertFile('b.properties', 'b')
+                .publish()
+
+        settingsFile << "rootProject.name = 'maven'"
+        buildFile << """
+            apply plugin: 'maven-publish'
+
+            dependencies {
+               implementation 'shadow:a:1.0'
+               shadow 'shadow:b:1.0'
+            }
+            
+            shadowJar {
+               archiveClassifier = 'my-classifier'
+               archiveExtension = 'my-ext'
+               archiveBaseName = 'maven-all'
+            }
+            
+            publishing {
+               publications {
+                   shadow(MavenPublication) { publication ->
+                       project.shadow.component(publication)
+                       artifactId = 'maven-all'
+                   }
+               }
+               repositories {
+                   maven {
+                       url "${publishingRepo.uri}"
+                   }
+               }
+            }
+        """.stripIndent()
+
+        when:
+        run('publish')
+
+        then:
+        File publishedFile = publishingRepo.rootDir.file('shadow/maven-all/1.0/maven-all-1.0-my-classifier.my-ext').canonicalFile
+        assert publishedFile.exists()
+    }
+
     def "publish multiproject shadow jar with maven-publish plugin"() {
         given: