Skip to content

Commit bcc11a0

Browse files
AlexanderAshitkinaashitki
andauthored
Cache documentation improvements (#40)
Co-authored-by: aashitki <alex.ashitkin@db.com>
1 parent b68f141 commit bcc11a0

File tree

7 files changed

+294
-268
lines changed

7 files changed

+294
-268
lines changed

src/site/markdown/getting-started.md.vm

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,67 @@
1818
Getting Started
1919
---------------
2020

21-
To on-board incremental Maven you need to complete several steps:
21+
To onboard the build-cache extension you need to complete several steps:
2222

2323
* Declare caching extension in your project (either in `pom.xml` or `.mvn/extensions.xml`)
24-
* Add `maven-build-cache-config.xml` cache config in `.mvn/` (optional) to customize default behavior
25-
* Validate build results and iteratively, adjust config to properly reflect project specifics
24+
* Add `maven-build-cache-config.xml` cache config in `.mvn/` (optional) to customize the default behavior
25+
* Validate build results and iteratively adjust config to reflect project specifics properly
2626
* Setup remote cache (optional)
2727

2828
#[[###]]# Declaring build cache extension
2929

3030
```xml
31+
3132
<extension>
3233
<groupId>org.apache.maven.extensions</groupId>
3334
<artifactId>maven-build-cache-extension</artifactId>
3435
<version>${project.version}</version>
3536
</extension>
3637
```
3738

38-
either in `pom.xml`'s `<project>/<build>/<extensions>` or in `.mvn/extensions.xml`'s `<extensions>`
39+
either in `pom.xml`'s `<project>/<build>/<extensions>` or in `.mvn/extensions.xml`'s `<extensions>`. Using core
40+
extension model (`.mvn/extensions.xml` file) is preferable as it allows better access to maven APIs and could allow
41+
more sophisticated optimizations in the future.
3942

4043
#[[###]]# Adding build cache config
4144

4245
Copy template config [`maven-build-cache-config.xml`](../resources/maven-build-cache-config.xml)
4346
to [`.mvn/`](https://maven.apache.org/configure.html) directory of your project.
44-
To get overall understanding of build cache machinery, it is recommended to review the config and read comments. In typical
45-
scenario you need to:
47+
To understand the caching machinery, review the config and read the comments. In a typical scenario, you need to:
4648

47-
* Exclude unstable, temporary files or environment specific files
48-
* Add plugins reconciliation rules – add critical plugins parameters to reconciliation
49-
* Configure precise source code files selectors. Though source code locations discovered automatically from project and plugins config,
50-
there might be edge cases.
51-
* Add remote cache location (if remote cache is used)
49+
* Exclude unstable, temporary files or environment-specific files
50+
* Add critical plugins parameters to runtime reconciliation
51+
* Configure precise source code file selectors. Though source code locations are discovered automatically from project
52+
and
53+
plugin configs, there might be edge cases.
54+
* Configure remote cache (if using the remote cache)
5255

5356
#[[###]]# Adjusting build cache config
5457

55-
Having extension run usual command, like `mvn package`. Verify the caching engine is activated:
58+
After configuring the extension, run a usual command, for example, `mvn package`, and verify the caching engine is
59+
activated:
5660

57-
* Check log output - there should be cache related output or initialization error message:
61+
* Check log output - there should be the cache-related output or initialization error message:
5862
```
5963
[INFO] Loading cache configuration from <project dir>/.mvn/maven-build-cache-config.xml
6064
```
6165
* Navigate to your local repo directory - there should be a sibling directory `build-cache` next to the usual
6266
local `repository`.
63-
* Find `buildinfo.xml` in the cache repository for typical module and review it. Ensure that
64-
* expected source code files are present in the build info
65-
* Review all plugings used in the build and add their critical parameters to reconciliation
67+
* Find `buildinfo.xml` in the cache repository for a typical module and review it. Ensure that
68+
* Expected source code files are present in the build info
69+
* Review all plugins used in the build and add their critical parameters to the reconciliation
6670

67-
It is recommended to find the best working trade-off between fairness and cache efficiency. Adding unnecessary rules and
71+
Try to find the best working trade-off between fairness and cache efficiency. Adding unnecessary rules and
6872
checks could reduce both performance and cache efficiency (hit rate).
6973

7074
#[[###]]# Adding caching CI and remote cache
7175

72-
To leverage remote cache feature there should a shared storage provide. Any technology supported
73-
by [Maven Resolver](https://maven.apache.org/resolver/) will suffice. In simplest form it could be a http web server which
74-
supports get/put operations ([Nginx OSS](http://nginx.org/en/) with fs module or any other equivalent).
75-
See [Remote cache setup](remote-cache.html) for detailed description of cache setup.
76+
To leverage the remote cache feature need to provide shared storage. Any technology supported
77+
by [Maven Resolver](https://maven.apache.org/resolver/) will suffice. In the simplest form, it could be any HTTP web
78+
server
79+
supporting get/put operations. Working examples:
80+
81+
* Artifactory (generic repository)
82+
* [Nginx OSS](http://nginx.org/en/) with fs module
83+
84+
See [Remote cache setup](remote-cache.html) for a detailed description of the remote cache setup

src/site/markdown/how-to.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
## Overview
1919

20-
Cache configuration provides you additional control over incremental Maven behavior. Follow it step by step to
21-
understand how it works and figure out your optimal config
20+
Cache configuration provides you additional control over the build-cache extension behavior. Follow it step-by-step to
21+
understand how it works, and figure out an optimal config
2222

2323
### Minimal config
2424

25-
Absolutely minimal config
25+
Minimal config
2626

2727
```xml
2828
<?xml version="1.0" encoding="UTF-8" ?>
@@ -58,7 +58,7 @@ Just add `<remote>` section under `<configuration>`
5858

5959
### Adding more file types to input
6060

61-
Add all the project specific source code files in `<glob>`. Scala in this case:
61+
Add all the project-specific source code files in `<glob>`. Scala, in this case:
6262

6363
```xml
6464
<input>
@@ -70,8 +70,7 @@ Add all the project specific source code files in `<glob>`. Scala in this case:
7070

7171
### Adding source directory for bespoke project layouts
7272

73-
In most of the cases incremental Maven will recognize directories automatically by build introspection. If not, you can
74-
add additional directories with `<include>`. Also you can filter out undesirable dirs and files by using exclude tag
73+
In most cases, the build-cache extension automatically recognizes directories by introspecting the build. When it is not enough, adding additional directories with `<include>` is possible. Also, you can filter out undesirable dirs and files by using exclude tag.
7574

7675
```xml
7776
<input>
@@ -87,7 +86,7 @@ add additional directories with `<include>`. Also you can filter out undesirable
8786
</input>
8887
```
8988

90-
### Plugin property is env specific and yields different cache key in different environments
89+
### Plugin property is environment-specific and yields different cache keys in different environments
9190

9291
Consider to exclude env specific properties:
9392

@@ -108,11 +107,11 @@ Consider to exclude env specific properties:
108107
</input>
109108
```
110109

111-
Implications - builds with different `argLine` will have identical key. Validate that is semantically valid.
110+
Implications - builds with different `argLine` will have an identical key. Validate that it is acceptable in terms of artifact equivalency.
112111

113-
### Plugin property points to directory where only subset of files is relevant
112+
### Plugin property points to a directory where only a subset of files is relevant
114113

115-
If plugin configuration property points to `somedir` it will be scanned with default glob. You can tweak it with custom
114+
If the plugin configuration property points to `somedir`, it will be scanned with the default glob. You can tweak it with custom
116115
processing rule
117116

118117
```xml
@@ -133,9 +132,9 @@ processing rule
133132
</input>
134133
```
135134

136-
### Local repository is not updated because `install` is cached
135+
### Local repository is not updated because the `install` phase is cached
137136

138-
Add `executionControl/runAlways` section
137+
Add `executionControl/runAlways` section:
139138

140139
```xml
141140
<executionControl>
@@ -161,10 +160,10 @@ Add `executionControl/runAlways` section
161160
</executionControl>
162161
```
163162

164-
### I occasionally cached build with `-DskipTests=true` and tests do not run now
163+
### I occasionally cached build with `-DskipTests=true`, and tests do not run now
165164

166-
If you add command line flags to your build, they do not participate in effective pom - Maven defers final value
167-
resolution to plugin runtime. To invalidate build if filed value is different in runtime, add reconciliation section
165+
If you add command line flags to your build, they do not participate in effective pom - Maven defers the final value
166+
resolution to plugin runtime. To invalidate the build if the filed value is different in runtime, add a reconciliation section
168167
to `executionControl`:
169168

170169
```xml
@@ -194,27 +193,24 @@ to `executionControl`:
194193
</cache>
195194
```
196195

197-
Please notice `skipValue` attribute. It denotes value which forces skipped execution.
198-
Read `propertyName="skipTests" skipValue="true"` as if property skipTests has value true, plugin will skip execution If
199-
you declare such value incremental Maven will reuse appropriate full-build though technically they are different, but
200-
because full-build is better it is safe to reuse
196+
Please notice the `skipValue` attribute. It captures the value that makes the plugin skip execution. Think of `skipProperty` as follows: if the build started with `-DskipTests=true`, restoring results from a build with completed tests is safe because the local run does not require completed tests. The same logic applies to any other plugin, not just Surefire.
201197

202198
### How to renormalize line endings in working copy after committing .gitattributes (git 2.16+)
203199

204-
Ensure you've committed (and ideally pushed everything) - no changes in working copy. After that:
200+
Ensure you've committed (and ideally pushed everything) - no changes in the working copy. After that:
205201

206202
```shell
207-
# Rewrite objects and update index
203+
# Rewrite objects and update the index
208204
git add --renormalize .
209205
# Commit changes
210-
git commit -m "Normalizing line endings"
211-
# Remove working copy paths from git cache
206+
git commit -m "Normalizing line endings."
207+
# Remove working copy paths from the git cache
212208
git rm --cached -r .
213209
# Refresh with new line endings
214210
git reset --hard
215211
```
216212

217-
### I want to cache interim build and override it later with final version
213+
### I want to cache the interim build and override it later with the final version
218214

219-
Solution: set `-Dmaven.build.cache.remote.save.final=true` to nodes which produce final builds. Such builds will not be overridden
215+
Solution: set `-Dmaven.build.cache.remote.save.final=true` to nodes that produce final builds. Such builds will not be overridden
220216
and eventually will replace all interim builds

0 commit comments

Comments
 (0)