Skip to content

Commit f0dabe2

Browse files
committed
Add KDoc for ShadowJar
1 parent 54a3904 commit f0dabe2

File tree

1 file changed

+71
-1
lines changed
  • src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks

1 file changed

+71
-1
lines changed

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.kt

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,23 @@ public abstract class ShadowJar :
102102
}
103103
}
104104

105+
/**
106+
* [ResourceTransformer]s to be applied in the shadow steps.
107+
*/
105108
@get:Nested
106109
public open val transformers: SetProperty<ResourceTransformer> = objectFactory.setProperty()
107110

111+
/**
112+
* [Relocator]s to be applied in the shadow steps.
113+
*/
108114
@get:Nested
109115
public open val relocators: SetProperty<Relocator> = objectFactory.setProperty()
110116

117+
/**
118+
* The configurations to include dependencies from.
119+
*
120+
* Defaults to a set that contains `runtimeClasspath` or `runtime` configuration.
121+
*/
111122
@get:Classpath
112123
@get:Optional
113124
public open val configurations: SetProperty<Configuration> = objectFactory.setProperty()
@@ -116,6 +127,9 @@ public abstract class ShadowJar :
116127
public open val dependencyFilter: Property<DependencyFilter> =
117128
objectFactory.property(DefaultDependencyFilter(project))
118129

130+
/**
131+
* Final dependencies to be shadowed.
132+
*/
119133
@get:Classpath
120134
public open val includedDependencies: ConfigurableFileCollection = objectFactory.fileCollection {
121135
dependencyFilter.zip(configurations) { df, cs -> df.resolve(cs) }
@@ -132,7 +146,7 @@ public abstract class ShadowJar :
132146
/**
133147
* Prefix to use for relocated packages.
134148
*
135-
* Defaults to [ShadowBasePlugin.SHADOW].
149+
* Defaults to `shadow`.
136150
*/
137151
@get:Input
138152
public open val relocationPrefix: Property<String> = objectFactory.property(ShadowBasePlugin.SHADOW)
@@ -146,33 +160,54 @@ public abstract class ShadowJar :
146160
@Input // Trigger task executions after excludes changed.
147161
override fun getExcludes(): MutableSet<String> = super.getExcludes()
148162

163+
/**
164+
* Enable [minimizeJar], this equals to `minimizeJar.set(true)`.
165+
*/
149166
override fun minimize() {
150167
minimizeJar.set(true)
151168
}
152169

170+
/**
171+
* Enable [minimizeJar] and execute the [action] with the [DependencyFilter] for minimize.
172+
*/
153173
override fun minimize(action: Action<DependencyFilter>?) {
154174
minimize()
155175
action?.execute(dependencyFilterForMinimize)
156176
}
157177

178+
/**
179+
* Extra dependency operations to be applied in the shadow steps.
180+
*/
158181
override fun dependencies(action: Action<DependencyFilter>?) {
159182
action?.execute(dependencyFilter.get())
160183
}
161184

185+
/**
186+
* Merge Java services files.
187+
*/
162188
override fun mergeServiceFiles() {
163189
transform(ServiceFileTransformer::class.java, null)
164190
}
165191

192+
/**
193+
* Merge Java services files with [rootPath].
194+
*/
166195
override fun mergeServiceFiles(rootPath: String) {
167196
transform(ServiceFileTransformer::class.java) {
168197
it.path = rootPath
169198
}
170199
}
171200

201+
/**
202+
* Merge Java services files with [action].
203+
*/
172204
override fun mergeServiceFiles(action: Action<ServiceFileTransformer>?) {
173205
transform(ServiceFileTransformer::class.java, action)
174206
}
175207

208+
/**
209+
* Merge Groovy extension modules (`META-INF/**/org.codehaus.groovy.runtime.ExtensionModule`).
210+
*/
176211
override fun mergeGroovyExtensionModules() {
177212
transform(GroovyExtensionModuleTransformer::class.java, null)
178213
}
@@ -193,6 +228,9 @@ public abstract class ShadowJar :
193228
}
194229
}
195230

231+
/**
232+
* Relocate classes matching [pattern] to [destination] using [SimpleRelocator].
233+
*/
196234
override fun relocate(
197235
pattern: String,
198236
destination: String,
@@ -202,35 +240,67 @@ public abstract class ShadowJar :
202240
addRelocator(relocator, action)
203241
}
204242

243+
/**
244+
* Relocate classes using a [Relocator].
245+
*/
205246
override fun <R : Relocator> relocate(clazz: Class<R>, action: Action<R>?) {
206247
val relocator = clazz.getDeclaredConstructor().newInstance()
207248
addRelocator(relocator, action)
208249
}
209250

251+
/**
252+
* Relocate classes using a [Relocator].
253+
*/
210254
override fun <R : Relocator> relocate(relocator: R, action: Action<R>?) {
211255
addRelocator(relocator, action)
212256
}
213257

258+
/**
259+
* Relocate classes using a [Relocator].
260+
*
261+
* This is a convenience method for [relocate] with a reified type parameter for Kotlin.
262+
*/
214263
public inline fun <reified R : Relocator> relocate() {
215264
relocate(R::class.java, null)
216265
}
217266

267+
/**
268+
* Relocate classes using a [Relocator].
269+
*
270+
* This is a convenience method for [relocate] with a reified type parameter for Kotlin.
271+
*/
218272
public inline fun <reified R : Relocator> relocate(action: Action<R>?) {
219273
relocate(R::class.java, action)
220274
}
221275

276+
/**
277+
* Transform resources using a [ResourceTransformer].
278+
*/
222279
override fun <T : ResourceTransformer> transform(clazz: Class<T>, action: Action<T>?) {
223280
addTransform(clazz.create(objectFactory), action)
224281
}
225282

283+
/**
284+
* Transform resources using a [ResourceTransformer].
285+
*/
226286
override fun <T : ResourceTransformer> transform(transformer: T, action: Action<T>?) {
227287
addTransform(transformer, action)
228288
}
229289

290+
/**
291+
* Transform resources using a [ResourceTransformer].
292+
*
293+
* This is a convenience method for [transform] with a reified type parameter for Kotlin.
294+
*/
230295
public inline fun <reified T : ResourceTransformer> transform() {
231296
transform(T::class.java, null)
232297
}
233298

299+
/**
300+
* Transform resources using a [ResourceTransformer].
301+
*
302+
* This is a convenience method for [transform] with a reified type parameter for Kotlin.
303+
*/
234304
public inline fun <reified T : ResourceTransformer> transform(action: Action<T>?) {
235305
transform(T::class.java, action)
236306
}

0 commit comments

Comments
 (0)