-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-head.md.vm
155 lines (99 loc) · 6.28 KB
/
index-head.md.vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#set($h2 = '##')
#set($h3 = '###')
#set($h4 = '####')
#set($h5 = '#####')
<span style="float:right;font-size-adjust:1.25">💡</span><h3>What</h3>
Switch Maven build directories to ramdisk/tmpfs (such that all generated files are in-memory).
<p> </p>
<span style="float:right;font-size-adjust:1.25">🔬</span><h3>Why</h3>
* Faster builds
* Save SSD/HDD from ephemeral churn
On local desktop (with projects on SATA3 SSD), I observe a 20-30% reduction in build time
(with/out
[parallel build](https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3)
settings).
<p> </p>
<span style="float:right;font-size-adjust:1.25">🔩</span><h3>How</h3>
Hooks into the build at various points, swapping `$escape.java("${")project.build.directory$escape.java("}")` (by default `./target`)
with a symbolic-link pointing to a directory in `tmpfs` (intentionally avoiding modification of build properties, implicit
default or otherwise.
This approach has the lightest touch, allowing presumptuous plugins and tests to continue in oblivion. However it does
requires running the plugin with extensions enabled or as a standalone extension.
If you're using feature-branching, or similar (effectively parallel builds of the same groupId:artifactId:version), then
you must explicitly state the branch identifier in the POM. Alternatively you may manage this by setting the `tmpfs` base
path as a property.
By way of example: a mapping into tmpfs has the form `/run/user/1000/maven/groupId/artifactId/version/HEAD` - parallel builds need
some unique combination of `tmpfs_root + groupId + artifactId + version + branchId` (note: the tmpfs root can be different per user).
<p> </p>
<span style="float:right;font-size-adjust:1.25">🔨</span><h3>Usage</h3>
As previously stated, this is both a plugin and a
[build extension](https://maven.apache.org/examples/maven-3-lifecycle-extensions.html#Use_your_extension_in_your_build.28s.29).
This provides opportunity for use without modifying checkouts or remembering to augment maven commands.
Review the dis/advantages of options, below and select the best fit for your use-case.
$h4 Usage Option 1: Maven distribution extension
Add the [uber jar](https://search.maven.org/remotecontent?filepath=io/earcam/maven/plugin/${project.artifactId}/${project.version}/${project.artifactId}-${project.version}-uber.jar) to `$escape.java("${")MAVEN_HOME$escape.java("}")/lib/ext`
* Advantages:
0. Ensure all Maven projects using this distribution are built in ram (exceptional cases can skipped with property)
0. No modification to checked out project
0. No augmentation of maven commands
* Disadvantages:
0. All the issues that come with [monkey-patching](https://en.wikipedia.org/wiki/Monkey_patch)
0. No version update reporting
0. No transparency (not so bad if you codify this monkey-patch via CD, eg. Dockerfile, Puppet, Ansible, etc)
$h4 Usage Option 2: Project core extension
Define [core extensions](https://maven.apache.org/ref/3.6.0/maven-embedder/core-extensions.html), by downloading
[extensions.xml](https://search.maven.org/remotecontent?filepath=io/earcam/maven/plugin/${project.artifactId}/${project.version}/${project.artifactId}-${project.version}-extensions.xml)
and saving as `$escape.java("${")project.baseDir$escape.java("}")/.mvn/extensions.xml` (or otherwise editing existing to include).
* Prerequisite: Maven >= 3.3.1
* Advantages:
0. Doesn't alter existing checked out files
0. Determined on a per-project basis
0. Safe; ignored if unsupported (eg. Windows)
* Disadvantages:
0. Not inherited (only applied to explicitly stated child modules)
0. Still modifies the checked out project (if not committed, which may not be possible)
0. Not sure this would covered by version update (reporting and automating update)
0. Not much transparency (given most IDEs and file browsers don't show `.hidden` directories by default)
$h4 Usage Option 3: POM build extension or plugin
The double-edged sword of explicit definition.
In the `<build>` section, include the following:
#snippet ( "/src/it/extension-single-property/pom.xml", "example-definition" )
Or:
#snippet ( "/src/it/plugin-with-extension-single/pom.xml", "example-plugin-with-extension" )
Note: `<extensions>true</extensions>` in the above is vital.
* Advantages:
0. Explicit definition (immediately obvious to developer)
0. Can be defined in a common parent and inherited
0. Safe; ignored if unsupported (eg. Windows)
0. Subject to version update reports
* Disadvantages:
0. Explicit definition (requires author to apply, or client modification of XML)
0. Might make non-Linux users more sad
<p> </p>
<span style="float:right;font-size-adjust:1.25">🗑</span><h3>Removing</h3>
If you decide to remove the plugin/extension, then you may be left with dead softlinks. The following
goal can be executed manually to remove softlinks (dead or alive):
mvn ramdisk:cleanup
Or (if not defined in the project's pom):
mvn ${project.groupId}:${project.artifactId}:${project.version}:cleanup
<p> </p>
<span style="float:right;font-size-adjust:1.25">🔧</span><h3>Properties</h3>
$h4 Skip execution
Set the property either cmdline `-D` or in the pom.xml's `<properties>`:
#snippet ( "/src/it/extension-single-skip/pom.xml", "example-skip-property" )
$h4 Force base path
Set the property either cmdline `-D` or in the pom.xml's `<properties>`:
#snippet ( "/src/it/extension-single-property/pom.xml", "example-property" )
<p> </p>
<span style="float:right;font-size-adjust:1.25">🐧</span><h3>Supported Operating Systems</h3>
Really only aimed at Linux/UNIX.
Mac OSX users can create a ramdisk and then set this `ram://` FS via the base path property
(then further could be achieve global application with an always active profile in `~/.m2/settings.xml')
Users of Windows could try with ubuntu-shell or consider something like [ImDisk](https://www.google.com/search?q=imdisk) (from a reputable source),
and then set the base path (see above).
<p> </p>
<span style="float:right;font-size-adjust:1.25">🥩</span><h3>Inspiration</h3>
<div>
<iframe width="560" height="315" src="https://www.youtube.com/embed/SY0nDM3NSd8?rel=0" frameborder="0" allow="autoplay; encrypted-media"></iframe>
</div>
<br/>