@@ -25,30 +25,16 @@ remote, but also to store the artifacts locally installed (locally built and
25
25
installed, to be more precise). Both of these artifacts were stored in bulk
26
26
in the local repository.
27
27
28
+ ## Implementations
29
+
28
30
Local repository implementations implement the ` LocalRepositoryManager ` (LRM)
29
31
interface, and Resolver out of the box provides two implementations for it:
30
- "simple" and "enhanced".
31
-
32
- ## Simple LRM
32
+ "enhanced" used at runtime and "simple" meant to be used in tests and alike
33
+ scenarios (is not meant for production use).
33
34
34
- Simple is a fully functional LRM implementation, but is used
35
- mainly in tests, it is not recommended in production environments.
36
-
37
- To manually instantiate a simple LRM, one needs to invoke following code:
35
+ ### Enhanced LRM
38
36
39
- ``` java
40
- LocalRepositoryManager simple = new SimpleLocalRepositoryManagerFactory ()
41
- .newInstance( session, new LocalRepository ( baseDir ) );
42
- ```
43
-
44
- Note: This code snippet above instantiates a component, that is not
45
- recommended way to use it, as it should be rather injected whenever possible.
46
- This example above is merely a showcase how to obtain LRM implementation
47
- in unit tests.
48
-
49
- ## Enhanced LRM
50
-
51
- Enhanced LRM on the other hand is enhanced with several extra
37
+ Enhanced LRM is enhanced with several extra
52
38
features, one most notable is scoping cached content by its origin and context:
53
39
if you downloaded an artifact A1 from repository R1
54
40
and later initiate build that requires same artifact A1, but repository R1
@@ -58,7 +44,7 @@ Those two, originating from two different repositories may not be the same thing
58
44
This is meant to protect users from "bad practice" (artifact coordinates are
59
45
unique in ideal world).
60
46
61
- ### Split Local Repository
47
+ #### Split Local Repository
62
48
63
49
Latest addition to the enhanced LRM is * split* feature. By default, split
64
50
feature is ** not enabled** , enhanced LRM behaves as it behaved in all
@@ -75,7 +61,7 @@ The split feature is implemented by the `LocalPathPrefixComposer` interface,
75
61
that adds different "prefixes" for the locally stored artifacts, based on
76
62
their context.
77
63
78
- #### Note About Release And Snapshot Differentiation
64
+ ##### Note About Release And Snapshot Differentiation
79
65
80
66
The prefix composer is able to differentiate between release and snapshot
81
67
versioned artifacts, and this is clear-cut: Maven Artifacts are either
@@ -99,7 +85,7 @@ The GAV level metadata gets differentiated based on version it carries, so
99
85
they may end up in releases or snapshots, depending on their value of
100
86
` metadata/version ` field.
101
87
102
- #### Use Cases
88
+ ##### Use Cases
103
89
104
90
Most direct use case is simpler local repository eviction. One can delete all
105
91
locally built artifacts without deleting the cached ones, hence, no
@@ -139,7 +125,7 @@ $ mvn ... -Daether.enhancedLocalRepository.split \
139
125
For complete reference of enhanced LRM configuration possibilities, refer to
140
126
[ configuration page] ( configuration.html ) .
141
127
142
- #### Split Repository Considerations
128
+ ##### Split Repository Considerations
143
129
144
130
** Word of warning** : on every change of "split" parameters, user must be aware
145
131
of the consequences. For example, if one change all aspects of split
@@ -149,7 +135,7 @@ is unchanged! Simply put, as all prefixes will be "new", the composed paths will
149
135
point to potentially non-existing locations, hence, resolver will consider
150
136
it as a "new" local repository in every aspect.
151
137
152
- #### Implementing Custom Split Strategy
138
+ ##### Implementing Custom Split Strategy
153
139
154
140
To implement custom split strategy, one needs to create a component of
155
141
type ` LocalPathPrefixComposerFactory ` and override the default component
@@ -160,3 +146,37 @@ class that provides all the defaults.
160
146
The factory should create a stateless instance of a composer
161
147
configured from passed in session, that will be used with the enhanced LRM
162
148
throughout the session.
149
+
150
+ ### Simple LRM
151
+
152
+ Simple is a fully functional LRM implementation, but is used
153
+ mainly in tests, it is not recommended in production environments.
154
+
155
+ To manually instantiate a simple LRM, one needs to invoke following code:
156
+
157
+ ``` java
158
+ LocalRepositoryManager simple = new SimpleLocalRepositoryManagerFactory ()
159
+ .newInstance( session, new LocalRepository ( baseDir ) );
160
+ ```
161
+
162
+ Note: This code snippet above instantiates a component, that is not
163
+ recommended way to use it, as it should be rather injected whenever possible.
164
+ This example above is merely a showcase how to obtain LRM implementation
165
+ in unit tests.
166
+
167
+ ## Shared Access to Local Repository
168
+
169
+ In case of shared (multi-threaded, multi-process or even multi host) access
170
+ to local repository, coordination is a must, as local repository is hosted
171
+ on file system, and each thread may read and write concurrently into it,
172
+ causing other threads or processes to get incomplete or partially written data.
173
+
174
+ Hence, since Resolver 1.7.x version, there is a pluggable API called "Named Locks"
175
+ available, providing out of the box lock implementations for cases like:
176
+
177
+ * multi-threaded, in JVM locking (the default)
178
+ * multi-process locking using file system advisory locking
179
+ * multi-host locking using Hazelcast or Redisson (needs Hazelcast or Redisson cluster)
180
+
181
+ For details see [ Named Locks module] ( maven-resolver-named-locks/ ) .
182
+
0 commit comments