Skip to content

Commit 8701796

Browse files
authored
Reformat and rearrange docs (#1402)
1 parent 3c6d506 commit 8701796

File tree

15 files changed

+456
-279
lines changed

15 files changed

+456
-279
lines changed

docs/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
# Introduction
77

88
Shadow is a Gradle plugin for combining a project's dependency classes and resources into a single
9-
output Jar.
10-
The combined Jar is often referred to a _fat-jar_ or _uber-jar_.
11-
Shadow utilizes [`JarInputStream`][JarInputStream] and [`JarOutputStream`][JarOutputStream] to efficiently process dependent libraries
12-
into the output jar without incurring the I/O overhead of expanding the jars to disk.
9+
output Jar. The combined Jar is often referred to a _fat-jar_ or _uber-jar_.
10+
Shadow utilizes [`JarInputStream`][JarInputStream] and [`JarOutputStream`][JarOutputStream] to efficiently process
11+
dependent libraries into the output jar without incurring the I/O overhead of expanding the jars to disk.
1312

1413
!!! warning "Plugin ID Change"
1514

docs/about/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# About This Project
22

3-
I (John Engelman) started this project in December 2012. We were working on converting from a monolithic application into the
4-
new hot jazz of "microservices" using Dropwizard.
3+
I (John Engelman) started this project in December 2012. We were working on converting from a monolithic application
4+
into the new hot jazz of "microservices" using Dropwizard.
55
I had also just started learning about Gradle and I knew that the incremental build system it provided would benefit
66
our development team greatly.
77
Unfortunately, the closest thing that Gradle had to Maven's Shade plugin was its ability to create application TARs and

docs/changes/README.md

Lines changed: 358 additions & 197 deletions
Large diffs are not rendered by default.

docs/configuration/README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
The [`ShadowJar`][ShadowJar] task type extends from Gradle's [`Jar`][Jar] type.
44
This means that all attributes and methods available on [`Jar`][Jar] are also available on [`ShadowJar`][ShadowJar].
55

6-
76
## Configuring Output Name
87

98
Shadow configures the default [`ShadowJar`][ShadowJar] task to set the output JAR's
@@ -17,7 +16,7 @@ Shadow configures the default [`ShadowJar`][ShadowJar] task to set the output JA
1716
- [`destinationDirectory`][destinationDirectory]
1817

1918
to the same default values as Gradle does for all [`Jar`][Jar] tasks. Additionally, it configures the
20-
[`archiveClassifier`][archiveClassifier] to be `all`. The listed ones are not full, you can view all the properties in
19+
[`archiveClassifier`][archiveClassifier] to be `all`. The listed ones are not full, you can view all the properties in
2120
[`Jar`][Jar]. The output shadowed JAR file will be named with the following format:
2221

2322
```
@@ -46,7 +45,6 @@ of the shadowed JAR file. e.g.
4645

4746
This will result in the output file being named `myApp-all.jar` instead of `myApp-1.0-all.jar`.
4847

49-
5048
## Configuring the Runtime Classpath
5149

5250
Each Java JAR file contains a manifest file that provides metadata about the contents of the JAR file itself.
@@ -61,10 +59,10 @@ Think of `configurations.shadow` as unmerged, runtime dependencies.
6159
The integration with the [`maven-publish`][maven-publish] plugin will automatically configure dependencies added
6260
to `configurations.shadow` as `RUNTIME` scope dependencies in the resulting POM file.
6361

64-
Additionally, Shadow automatically configures the manifest of the [`ShadowJar`][ShadowJar] task to contain a `Class-Path` entry
65-
in the JAR manifest.
66-
The value of the `Class-Path` entry is the name of all dependencies resolved in the `shadow` configuration
67-
for the project.
62+
Additionally, Shadow automatically configures the manifest of the [`ShadowJar`][ShadowJar] task to contain a
63+
`Class-Path` entry in the JAR manifest.
64+
The value of the `Class-Path` entry is the name of all dependencies resolved in the `shadow` configuration for the
65+
project.
6866

6967
=== "Kotlin"
7068

@@ -93,9 +91,10 @@ When deploying a shadowed JAR as an execution JAR, it is important to note that
9391

9492
## Configuring the JAR Manifest
9593

96-
Beyond the automatic configuration of the `Class-Path` entry, the [`ShadowJar`][ShadowJar] manifest is configured in a number of ways.
97-
First, the manifest for the [`ShadowJar`][ShadowJar] task is configured to __inherit__ from the manifest of the standard [`Jar`][Jar] task.
98-
This means that any configuration performed on the [`Jar`][Jar] task will propagate to the [`ShadowJar`][ShadowJar] tasks.
94+
Beyond the automatic configuration of the `Class-Path` entry, the [`ShadowJar`][ShadowJar] manifest is configured in a
95+
number of ways. First, the manifest for the [`ShadowJar`][ShadowJar] task is configured to __inherit__ from the
96+
manifest of the standard [`Jar`][Jar] task. This means that any configuration performed on the [`Jar`][Jar] task
97+
will propagate to the [`ShadowJar`][ShadowJar] tasks.
9998

10099
=== "Kotlin"
101100

@@ -123,8 +122,8 @@ Inspecting the `META-INF/MANIFEST.MF` entry in the JAR file will reveal the foll
123122
Class-Path: /libs/a.jar
124123
```
125124

126-
If it is desired to inherit a manifest from a JAR task other than the standard [`Jar`][Jar] task, the `inheritFrom` methods
127-
on the `shadowJar.manifest` object can be used to configure the upstream.
125+
If it is desired to inherit a manifest from a JAR task other than the standard [`Jar`][Jar] task, the `inheritFrom`
126+
methods on the `shadowJar.manifest` object can be used to configure the upstream.
128127

129128
=== "Kotlin"
130129

docs/configuration/dependencies/README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Configuring Shadowed Dependencies
22

3-
Shadow configures the default [`ShadowJar`][ShadowJar] task to merge all dependencies from the project's `runtimeClasspath` configuration
4-
into the final JAR. The configurations from which to source dependencies for the merging can be configured using the
5-
[`configurations`][ShadowJar.configurations] property of the [`ShadowJar`][ShadowJar] task type.
3+
Shadow configures the default [`ShadowJar`][ShadowJar] task to merge all dependencies from the project's
4+
`runtimeClasspath` configuration into the final JAR. The configurations from which to source dependencies for the
5+
merging can be configured using the [`configurations`][ShadowJar.configurations] property of the
6+
[`ShadowJar`][ShadowJar] task type.
67

78
=== "Kotlin"
89

@@ -20,14 +21,15 @@ into the final JAR. The configurations from which to source dependencies for the
2021
}
2122
```
2223

23-
The above code sample would configure the [`ShadowJar`][ShadowJar] task to merge dependencies from only the `compileClasspath` configuration.
24+
The above code sample would configure the [`ShadowJar`][ShadowJar] task to merge dependencies from only the
25+
`compileClasspath` configuration.
2426
This means any dependency declared in the `runtimeOnly` configuration would be **not** be included in the final JAR.
2527

2628
> Note the literal use of [`project.configurations`][Project.configurations] when setting the
27-
[`configurations`][ShadowJar.configurations] attribute of a [`ShadowJar`][ShadowJar] task.
28-
This is **required**. It may be tempting to specify `configurations = [configurations.compileClasspath]` but this will not
29-
have the intended effect, as `configurations.compile` will try to delegate to the
30-
[`configurations`][ShadowJar.configurations] property of the [`ShadowJar`][ShadowJar] task instead of the `project`
29+
> [`configurations`][ShadowJar.configurations] attribute of a [`ShadowJar`][ShadowJar] task.
30+
> This is **required**. It may be tempting to specify `configurations = [configurations.compileClasspath]` but this will
31+
> not have the intended effect, as `configurations.compile` will try to delegate to the
32+
> [`configurations`][ShadowJar.configurations] property of the [`ShadowJar`][ShadowJar] task instead of the `project`
3133
3234
## Embedding Jar Files Inside Your Shadow Jar
3335

@@ -134,8 +136,8 @@ Gradle's [`project.configurations`][Project.configurations] block.
134136
```
135137

136138
> While not being able to filter entire transitive dependency graphs might seem like an oversight, it is necessary
137-
because it would not be possible to intelligently determine the build author's intended results when there is a
138-
common dependency between two 1st level dependencies when one is excluded and the other is not.
139+
> because it would not be possible to intelligently determine the build author's intended results when there is a
140+
> common dependency between two 1st level dependencies when one is excluded and the other is not.
139141
140142
### Using Regex Patterns to Filter Dependencies
141143

docs/configuration/filtering/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ source set or _any_ of the dependencies to be merged.
2323
}
2424
```
2525

26-
27-
Excludes and includes can be combined just like a normal [`Jar`][Jar] task, with `excludes` taking precedence over `includes`.
28-
Additionally, ANT style patterns can be used to match multiple files.
26+
Excludes and includes can be combined just like a normal [`Jar`][Jar] task, with `excludes` taking precedence over
27+
`includes`. Additionally, ANT style patterns can be used to match multiple files.
2928

3029
=== "Kotlin"
3130

docs/configuration/merging/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ should process a particular entry and apply any modifications before writing the
4646
}
4747
```
4848

49-
Additionally, a [`ResourceTransformer`][ResourceTransformer] can accept a `Closure` to configure the provided `ResourceTransformer`.
49+
Additionally, a [`ResourceTransformer`][ResourceTransformer] can accept a `Closure` to configure the provided
50+
[`ResourceTransformer`][ResourceTransformer].
5051

5152
=== "Kotlin"
5253

@@ -320,7 +321,6 @@ this transformer.
320321
}
321322
```
322323

323-
324324
## Appending XML Files
325325

326326
XML files require a special transformer for merging. The [`XmlAppendingTransformer`][XmlAppendingTransformer]
@@ -357,11 +357,12 @@ It must be added using the [`transform`][ShadowJar.transform] methods.
357357
- `FAIL`: Throw a `DuplicateFileCopyingException` when subsequent items are to be created at the same path.
358358
- `INCLUDE`: Do not attempt to prevent duplicates.
359359
- `INHERIT`: Uses the same strategy as the parent copy specification.
360-
- `WARN`: Do not attempt to prevent duplicates, but log a warning message when multiple items are to be created at the same path.
360+
- `WARN`: Do not attempt to prevent duplicates, but log a warning message when multiple items are to be created at the
361+
same path.
361362

362363
see more details about them in [`DuplicatesStrategy`][DuplicatesStrategy].
363364

364-
`ShadowJar` recognizes `DuplicatesStrategy.INCLUDE` as the default, if you want to change the strategy, you can
365+
`ShadowJar` recognizes `DuplicatesStrategy.INCLUDE` as the default, if you want to change the strategy, you can
365366
override it like:
366367

367368
=== "Kotlin"
@@ -385,7 +386,8 @@ Different strategies will lead to different results for `foo/bar` files in the J
385386
- `EXCLUDE`: The **first** `foo/bar` file will be included in the final JAR.
386387
- `FAIL`: **Fail** the build with a `DuplicateFileCopyingException` if there are duplicated `foo/bar` files.
387388
- `INCLUDE`: The **last** `foo/bar` file will be included in the final JAR (the default behavior).
388-
- `INHERIT`: **Fail** the build with an exception like `Entry .* is a duplicate but no duplicate handling strategy has been set`.
389+
- `INHERIT`: **Fail** the build with an exception like
390+
`Entry .* is a duplicate but no duplicate handling strategy has been set`.
389391
- `WARN`: The **last** `foo/bar` file will be included in the final JAR, and a warning message will be logged.
390392

391393
**NOTE:** The `duplicatesStrategy` takes precedence over transforming and relocating. If you mix the usages of
@@ -412,7 +414,7 @@ Different strategies will lead to different results for `foo/bar` files in the J
412414
The [`ServiceFileTransformer`][ServiceFileTransformer] will not work as expected because the `duplicatesStrategy` will
413415
exclude the duplicated service files beforehand. However, this behavior might be what you expected for duplicated
414416
`foo/bar` files, preventing them from being included.
415-
Want `ResourceTransformer`s and `duplicatesStrategy` to work together? There is a way to achieve this, leave the
417+
Want `ResourceTransformer`s and `duplicatesStrategy` to work together? There is a way to achieve this, leave the
416418
`duplicatesStrategy` as `INCLUDE` and declare a custom [`ResourceTransformer`][ResourceTransformer] to handle the
417419
duplicated files.
418420

docs/configuration/minimizing/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Minimizing
22

3-
Shadow can automatically remove all classes of dependencies that are not used by the project, thereby minimizing the resulting shadowed JAR.
3+
Shadow can automatically remove all classes of dependencies that are not used by the project, thereby minimizing the
4+
resulting shadowed JAR.
45

56
=== "Kotlin"
67

@@ -43,7 +44,8 @@ a `dependency` is interpreted as a regular expression.
4344
}
4445
```
4546

46-
> Dependencies scoped as `api` will be automatically excluded from minimization and used as "entry points" on minimization.
47+
> Dependencies scoped as `api` will be automatically excluded from minimization and used as "entry points" on
48+
> minimization.
4749
4850
Similar to dependencies, projects can also be excluded.
4951

@@ -68,4 +70,4 @@ Similar to dependencies, projects can also be excluded.
6870
```
6971

7072
> When excluding a `project`, all dependencies of the excluded `project` are automatically
71-
excluded as well.
73+
> excluded as well.

docs/configuration/relocation/README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ In the resulting JAR, the class file is relocated from `junit/framework/TestCase
3232
`shadow/junit/TestCase.class`.
3333

3434
> Relocation operates at a package level.
35-
It is not necessary to specify any patterns for matching, it will operate simply on the prefix
36-
provided.
35+
> It is not necessary to specify any patterns for matching, it will operate simply on the prefix provided.
3736
3837
> Relocation will be applied globally to all instances of the matched prefix.
39-
That is, it does **not** scope to _only_ the dependencies being shadowed.
40-
Be specific as possible when configuring relocation as to avoid unintended relocations.
38+
> That is, it does **not** scope to _only_ the dependencies being shadowed.
39+
> Be specific as possible when configuring relocation as to avoid unintended relocations.
4140
4241
## Filtering Relocation
4342

4443
Specific classes or files can be `included`/`excluded` from the relocation operation if necessary. Use
45-
[Ant Path Matcher](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html)
44+
[Ant Path Matcher](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html)
4645
syntax to specify matching path for your files and directories.
4746

4847
=== "Kotlin"
@@ -71,8 +70,8 @@ syntax to specify matching path for your files and directories.
7170
}
7271
```
7372

74-
For a more advanced path matching you might want to use [Regular Expressions](https://regexr.com/) instead. Wrap the expression in `%regex[]` before
75-
passing it to `include`/`exclude`.
73+
For a more advanced path matching you might want to use [Regular Expressions](https://regexr.com/) instead. Wrap the
74+
expression in `%regex[]` before passing it to `include`/`exclude`.
7675

7776
=== "Kotlin"
7877

@@ -96,8 +95,8 @@ passing it to `include`/`exclude`.
9695

9796
## Automatically Relocating Dependencies
9897

99-
Shadow is shipped with a task that can be used to automatically configure all packages from all dependencies to be relocated.
100-
This feature was formally shipped into a 2nd plugin (`com.github.johnrengelman.plugin-shadow`) but has been
98+
Shadow is shipped with a task that can be used to automatically configure all packages from all dependencies to be
99+
relocated. This feature was formally shipped into a 2nd plugin (`com.github.johnrengelman.plugin-shadow`) but has been
101100
removed for clarity reasons in version 4.0.0.
102101

103102
To configure automatic dependency relocation, set `enableRelocation = true` and optionally specify a custom
@@ -124,13 +123,13 @@ To configure automatic dependency relocation, set `enableRelocation = true` and
124123
In versions before 8.1.0 it was necessary to configure a separate `ConfigureShadowRelocation` task for this.
125124

126125
> Configuring package auto relocation can add significant time to the shadow process as it will process all dependencies
127-
in the configurations declared to be shadowed. By default, this is the `runtime` or `runtimeClasspath` configurations.
128-
Be mindful that some Gradle plugins will automatically add dependencies to your class path. You may need to remove these
129-
dependencies if you do not intend to shadow them into your library.
126+
> in the configurations declared to be shadowed. By default, this is the `runtime` or `runtimeClasspath` configurations.
127+
> Be mindful that some Gradle plugins will automatically add dependencies to your class path. You may need to remove these
128+
> dependencies if you do not intend to shadow them into your library.
130129
131130
## Relocating Project Resources Only
132131

133-
If you want to relocate the resources of the project only and exclude all dependencies (related to a normal JAR but with
132+
If you want to relocate the resources of the project only and exclude all dependencies (related to a normal JAR but with
134133
relocating), you can try out the trick like:
135134

136135
=== "Kotlin"
@@ -153,5 +152,5 @@ relocating), you can try out the trick like:
153152
}
154153
```
155154

156-
This is useful in some cases like [#759](https://github.com/GradleUp/shadow/issues/759) mentioned. See
155+
This is useful in some cases like [#759](https://github.com/GradleUp/shadow/issues/759) mentioned. See
157156
[Configuring Shadowed Dependencies](../dependencies/README.md) for more information about `configurations`.

docs/configuration/reproducible-builds/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Reproducible Builds
22

3-
By default, JAR files generated by Gradle (with or without Shadow) for a single project with the same source code may not be identical to each other. Sometimes it's desirable to configure a project to consistently output a byte-for-byte identical JAR on every build. Gradle supports this with the following configuration, and Shadow will correctly respect these settings too:
3+
By default, JAR files generated by Gradle (with or without Shadow) for a single project with the same source code may
4+
not be identical to each other. Sometimes it's desirable to configure a project to consistently output a byte-for-byte
5+
identical JAR on every build. Gradle supports this with the following configuration, and Shadow will correctly respect
6+
these settings too:
47

58
=== "Kotlin"
69

@@ -20,6 +23,10 @@ By default, JAR files generated by Gradle (with or without Shadow) for a single
2023
}
2124
```
2225

23-
One effect that this configuration will have is that the timestamps of all files in the JAR will be reset to a single consistent value. If your code or any files being included into the JAR depend on the timestamps being set accurately within the JAR, then this may not be the correct choice for you.
26+
One effect that this configuration will have is that the timestamps of all files in the JAR will be reset to a single
27+
consistent value. If your code or any files being included into the JAR depend on the timestamps being set accurately
28+
within the JAR, then this may not be the correct choice for you.
2429

25-
See the [Reproducible archives section in Gradle's documentation](https://docs.gradle.org/4.9/userguide/working_with_files.html#sec:reproducible_archives) for more information.
30+
See
31+
the [Reproducible archives section in Gradle's documentation](https://docs.gradle.org/4.9/userguide/working_with_files.html#sec:reproducible_archives)
32+
for more information.

0 commit comments

Comments
 (0)