@@ -8,9 +8,9 @@ import com.github.jengelman.gradle.plugins.shadow.internal.DependencyFilter
8
8
import com.github.jengelman.gradle.plugins.shadow.internal.MinimizeDependencyFilter
9
9
import com.github.jengelman.gradle.plugins.shadow.internal.UnusedTracker
10
10
import com.github.jengelman.gradle.plugins.shadow.internal.ZipCompressor
11
- import com.github.jengelman.gradle.plugins.shadow.internal.conventionCompat
11
+ import com.github.jengelman.gradle.plugins.shadow.internal.fileCollection
12
12
import com.github.jengelman.gradle.plugins.shadow.internal.property
13
- import com.github.jengelman.gradle.plugins.shadow.internal.unsafeLazy
13
+ import com.github.jengelman.gradle.plugins.shadow.internal.setProperty
14
14
import com.github.jengelman.gradle.plugins.shadow.relocation.CacheableRelocator
15
15
import com.github.jengelman.gradle.plugins.shadow.relocation.Relocator
16
16
import com.github.jengelman.gradle.plugins.shadow.relocation.SimpleRelocator
@@ -20,6 +20,7 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.GroovyExtensionMo
20
20
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer
21
21
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer
22
22
import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer.Companion.create
23
+ import java.io.File
23
24
import java.util.jar.JarFile
24
25
import org.apache.tools.zip.ZipOutputStream
25
26
import org.gradle.api.Action
@@ -68,32 +69,37 @@ public abstract class ShadowJar :
68
69
@get:Internal
69
70
override val stats: ShadowStats = ShadowStats ()
70
71
72
+ /* *
73
+ * Minimize the jar by removing unused classes.
74
+ *
75
+ * Defaults to `false`.
76
+ */
77
+ @get:Input
78
+ public open val minimizeJar: Property <Boolean > = objectFactory.property(false )
79
+
71
80
@get:Classpath
72
- public open val toMinimize: ConfigurableFileCollection by unsafeLazy {
73
- objectFactory.fileCollection().apply {
74
- if (minimizeJar.get()) {
75
- conventionCompat(dependencyFilterForMinimize.resolve(configurations.get()) - apiJars)
76
- }
81
+ public open val toMinimize: ConfigurableFileCollection = objectFactory.fileCollection {
82
+ minimizeJar.map {
83
+ if (it) (dependencyFilterForMinimize.resolve(configurations.get()) - apiJars) else emptySet()
77
84
}
78
85
}
79
86
80
87
@get:Classpath
81
- public open val apiJars: ConfigurableFileCollection by unsafeLazy {
82
- objectFactory.fileCollection().apply {
83
- if (minimizeJar.get()) {
84
- conventionCompat(UnusedTracker .getApiJarsFromProject(project))
85
- }
88
+ public open val apiJars: ConfigurableFileCollection = objectFactory.fileCollection {
89
+ minimizeJar.map {
90
+ if (it) UnusedTracker .getApiJarsFromProject(project) else emptySet()
86
91
}
87
92
}
88
93
89
94
@get:InputFiles
90
95
@get:PathSensitive(PathSensitivity .RELATIVE )
91
- public open val sourceSetsClassesDirs: ConfigurableFileCollection by unsafeLazy {
92
- objectFactory.fileCollection().apply {
93
- if (minimizeJar.get()) {
94
- project.extensions.getByType(SourceSetContainer ::class .java).forEach { sourceSet ->
95
- from(sourceSet.output.classesDirs.filter { it.isDirectory })
96
- }
96
+ public open val sourceSetsClassesDirs: ConfigurableFileCollection = objectFactory.fileCollection {
97
+ minimizeJar.map {
98
+ if (it) {
99
+ project.extensions.getByType(SourceSetContainer ::class .java)
100
+ .map { sourceSet -> sourceSet.output.classesDirs.filter(File ::isDirectory) }
101
+ } else {
102
+ emptySet()
97
103
}
98
104
}
99
105
}
@@ -113,22 +119,23 @@ public abstract class ShadowJar :
113
119
}
114
120
115
121
@get:Nested
116
- public open val transformers: SetProperty <Transformer > = objectFactory.setProperty(Transformer :: class .java )
122
+ public open val transformers: SetProperty <Transformer > = objectFactory.setProperty()
117
123
118
124
@get:Nested
119
- public open val relocators: SetProperty <Relocator > = objectFactory.setProperty(Relocator :: class .java )
125
+ public open val relocators: SetProperty <Relocator > = objectFactory.setProperty()
120
126
121
127
@get:Classpath
122
128
@get:Optional
123
- public open val configurations: SetProperty <Configuration > = objectFactory.setProperty(Configuration :: class .java )
129
+ public open val configurations: SetProperty <Configuration > = objectFactory.setProperty()
124
130
125
131
@get:Internal
126
132
public open val dependencyFilter: Property <DependencyFilter > =
127
133
objectFactory.property(DefaultDependencyFilter (project))
128
134
129
135
@get:Classpath
130
- public open val includedDependencies: ConfigurableFileCollection = objectFactory.fileCollection()
131
- .conventionCompat(dependencyFilter.map { it.resolve(configurations.get()) })
136
+ public open val includedDependencies: ConfigurableFileCollection = objectFactory.fileCollection {
137
+ dependencyFilter.zip(configurations) { df, cs -> df.resolve(cs) }
138
+ }
132
139
133
140
/* *
134
141
* Enable relocation of packages in the jar.
@@ -146,14 +153,6 @@ public abstract class ShadowJar :
146
153
@get:Input
147
154
public open val relocationPrefix: Property <String > = objectFactory.property(ShadowBasePlugin .SHADOW )
148
155
149
- /* *
150
- * Minimize the jar by removing unused classes.
151
- *
152
- * Defaults to `false`.
153
- */
154
- @get:Input
155
- public open val minimizeJar: Property <Boolean > = objectFactory.property(false )
156
-
157
156
@Internal
158
157
override fun getManifest (): InheritManifest = super .manifest as InheritManifest
159
158
0 commit comments