|
1 | 1 | package com.github.jengelman.gradle.plugins.shadow.transformers
|
2 | 2 |
|
| 3 | +import com.github.jengelman.gradle.plugins.shadow.internal.mainClassAttributeKey |
3 | 4 | import com.github.jengelman.gradle.plugins.shadow.internal.mapProperty
|
4 | 5 | import com.github.jengelman.gradle.plugins.shadow.internal.property
|
5 | 6 | import com.github.jengelman.gradle.plugins.shadow.internal.zipEntry
|
6 | 7 | import java.io.IOException
|
7 |
| -import java.util.jar.Attributes |
| 8 | +import java.util.jar.Attributes as JarAttribute |
8 | 9 | import java.util.jar.JarFile
|
9 | 10 | import java.util.jar.Manifest
|
10 | 11 | import javax.inject.Inject
|
@@ -40,7 +41,7 @@ public open class ManifestResourceTransformer @Inject constructor(
|
40 | 41 |
|
41 | 42 | @get:Optional
|
42 | 43 | @get:Input
|
43 |
| - public open val manifestEntries: MapProperty<String, Attributes> = objectFactory.mapProperty() |
| 44 | + public open val manifestEntries: MapProperty<String, JarAttribute> = objectFactory.mapProperty() |
44 | 45 |
|
45 | 46 | override fun canTransformResource(element: FileTreeElement): Boolean {
|
46 | 47 | return JarFile.MANIFEST_NAME.equals(element.path, ignoreCase = true)
|
@@ -70,17 +71,17 @@ public open class ManifestResourceTransformer @Inject constructor(
|
70 | 71 |
|
71 | 72 | val attributes = manifest!!.mainAttributes
|
72 | 73 | mainClass.orNull?.let {
|
73 |
| - attributes[Attributes.Name.MAIN_CLASS] = it |
| 74 | + attributes[mainClassAttributeKey] = it |
74 | 75 | }
|
75 | 76 | manifestEntries.get().forEach { (key, value) ->
|
76 |
| - attributes[Attributes.Name(key)] = value |
| 77 | + attributes[JarAttribute.Name(key)] = value |
77 | 78 | }
|
78 | 79 |
|
79 | 80 | os.putNextEntry(zipEntry(JarFile.MANIFEST_NAME, preserveFileTimestamps))
|
80 | 81 | manifest!!.write(os)
|
81 | 82 | }
|
82 | 83 |
|
83 |
| - public open fun attributes(attributes: Map<String, Attributes>): ManifestResourceTransformer = apply { |
| 84 | + public open fun attributes(attributes: Map<String, JarAttribute>): ManifestResourceTransformer = apply { |
84 | 85 | manifestEntries.putAll(attributes)
|
85 | 86 | }
|
86 | 87 |
|
|
0 commit comments