View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.api;
20  
21  import org.apache.maven.api.annotations.Config;
22  
23  /**
24   * Configuration constants.
25   */
26  public final class Constants {
27  
28      /**
29       * Maven home.
30       *
31       * @since 3.0.0
32       */
33      @Config(readOnly = true)
34      public static final String MAVEN_HOME = "maven.home";
35  
36      /**
37       * Maven installation configuration directory.
38       *
39       * @since 4.0.0
40       */
41      @Config(defaultValue = "${maven.home}/conf")
42      public static final String MAVEN_INSTALLATION_CONF = "maven.installation.conf";
43  
44      /**
45       * Maven user configuration directory.
46       *
47       * @since 4.0.0
48       */
49      @Config(defaultValue = "${user.home}/.m2")
50      public static final String MAVEN_USER_CONF = "maven.user.conf";
51  
52      /**
53       * Maven project configuration directory.
54       *
55       * @since 4.0.0
56       */
57      @Config(defaultValue = "${session.rootDirectory}/.mvn")
58      public static final String MAVEN_PROJECT_CONF = "maven.project.conf";
59  
60      /**
61       * Maven local repository.
62       *
63       * @since 3.0.0
64       */
65      @Config(defaultValue = "${maven.user.conf}/repository")
66      public static final String MAVEN_REPO_LOCAL = "maven.repo.local";
67  
68      /**
69       * Maven central repository URL.
70       * The property will have the value of the <code>MAVEN_REPO_CENTRAL</code>
71       * environment variable if it is defined.
72       *
73       * @since 4.0.0
74       */
75      @Config(defaultValue = "https://repo.maven.apache.org/maven2")
76      public static final String MAVEN_REPO_CENTRAL = "maven.repo.central";
77  
78      /**
79       * Maven installation settings.
80       *
81       * @since 4.0.0
82       */
83      @Config(defaultValue = "${maven.installation.conf}/settings.xml")
84      public static final String MAVEN_INSTALLATION_SETTINGS = "maven.installation.settings";
85  
86      /**
87       * Maven user settings.
88       *
89       * @since 4.0.0
90       */
91      @Config(defaultValue = "${maven.user.conf}/settings.xml")
92      public static final String MAVEN_USER_SETTINGS = "maven.user.settings";
93  
94      /**
95       * Maven project settings.
96       *
97       * @since 4.0.0
98       */
99      @Config(defaultValue = "${maven.project.conf}/settings.xml")
100     public static final String MAVEN_PROJECT_SETTINGS = "maven.project.settings";
101 
102     /**
103      * Maven installation extensions.
104      *
105      * @since 4.0.0
106      */
107     @Config(defaultValue = "${maven.installation.conf}/extensions.xml")
108     public static final String MAVEN_INSTALLATION_EXTENSIONS = "maven.installation.extensions";
109 
110     /**
111      * Maven user extensions.
112      *
113      * @since 4.0.0
114      */
115     @Config(defaultValue = "${maven.user.conf}/extensions.xml")
116     public static final String MAVEN_USER_EXTENSIONS = "maven.user.extensions";
117 
118     /**
119      * Maven project extensions.
120      *
121      * @since 4.0.0
122      */
123     @Config(defaultValue = "${maven.project.conf}/extensions.xml")
124     public static final String MAVEN_PROJECT_EXTENSIONS = "maven.project.extensions";
125 
126     /**
127      * Maven installation toolchains.
128      *
129      * @since 4.0.0
130      */
131     @Config(defaultValue = "${maven.installation.conf}/toolchains.xml")
132     public static final String MAVEN_INSTALLATION_TOOLCHAINS = "maven.installation.toolchains";
133 
134     /**
135      * Maven user toolchains.
136      *
137      * @since 4.0.0
138      */
139     @Config(defaultValue = "${maven.user.conf}/toolchains.xml")
140     public static final String MAVEN_USER_TOOLCHAINS = "maven.user.toolchains";
141 
142     /**
143      * Extensions class path.
144      */
145     @Config
146     public static final String MAVEN_EXT_CLASS_PATH = "maven.ext.class.path";
147 
148     @Config(defaultValue = "${maven.user.conf}/settings-security4.xml")
149     public static final String MAVEN_SETTINGS_SECURITY = "maven.settings.security";
150 
151     public static final String MAVEN_SETTINGS_SECURITY_FILE_NAME = "settings-security4.xml";
152 
153     public static final String MAVEN_STYLE_PREFIX = "maven.style.";
154 
155     // Style Names
156     public static final String MAVEN_STYLE_TRANSFER_NAME = "transfer";
157     public static final String MAVEN_STYLE_TRACE_NAME = "trace";
158     public static final String MAVEN_STYLE_DEBUG_NAME = "debug";
159     public static final String MAVEN_STYLE_INFO_NAME = "info";
160     public static final String MAVEN_STYLE_WARNING_NAME = "warning";
161     public static final String MAVEN_STYLE_ERROR_NAME = "error";
162     public static final String MAVEN_STYLE_SUCCESS_NAME = "success";
163     public static final String MAVEN_STYLE_FAILURE_NAME = "failure";
164     public static final String MAVEN_STYLE_STRONG_NAME = "strong";
165     public static final String MAVEN_STYLE_MOJO_NAME = "mojo";
166     public static final String MAVEN_STYLE_PROJECT_NAME = "project";
167 
168     // Default Values
169     public static final String MAVEN_STYLE_TRANSFER_DEFAULT = "f:bright-black";
170     public static final String MAVEN_STYLE_TRACE_DEFAULT = "bold,f:magenta";
171     public static final String MAVEN_STYLE_DEBUG_DEFAULT = "bold,f:cyan";
172     public static final String MAVEN_STYLE_INFO_DEFAULT = "bold,f:blue";
173     public static final String MAVEN_STYLE_WARNING_DEFAULT = "bold,f:yellow";
174     public static final String MAVEN_STYLE_ERROR_DEFAULT = "bold,f:red";
175     public static final String MAVEN_STYLE_SUCCESS_DEFAULT = "bold,f:green";
176     public static final String MAVEN_STYLE_FAILURE_DEFAULT = "bold,f:red";
177     public static final String MAVEN_STYLE_STRONG_DEFAULT = "bold";
178     public static final String MAVEN_STYLE_MOJO_DEFAULT = "f:green";
179     public static final String MAVEN_STYLE_PROJECT_DEFAULT = "f:cyan";
180 
181     /**
182      * Maven output color mode.
183      * Allowed values are <code>auto</code>, <code>always</code>, <code>never</code>.
184      *
185      * @since 4.0.0
186      */
187     @Config(defaultValue = "auto")
188     public static final String MAVEN_STYLE_COLOR_PROPERTY = MAVEN_STYLE_PREFIX + "color";
189 
190     /**
191      * Color style for transfer messages.
192      * @since 4.0.0
193      */
194     @Config(defaultValue = MAVEN_STYLE_TRANSFER_DEFAULT)
195     public static final String MAVEN_STYLE_TRANSFER = MAVEN_STYLE_PREFIX + MAVEN_STYLE_TRANSFER_NAME;
196 
197     /**
198      * Color style for trace messages.
199      * @since 4.0.0
200      */
201     @Config(defaultValue = MAVEN_STYLE_TRACE_DEFAULT)
202     public static final String MAVEN_STYLE_TRACE = MAVEN_STYLE_PREFIX + MAVEN_STYLE_TRACE_NAME;
203 
204     /**
205      * Color style for debug messages.
206      * @since 4.0.0
207      */
208     @Config(defaultValue = MAVEN_STYLE_DEBUG_DEFAULT)
209     public static final String MAVEN_STYLE_DEBUG = MAVEN_STYLE_PREFIX + MAVEN_STYLE_DEBUG_NAME;
210 
211     /**
212      * Color style for info messages.
213      * @since 4.0.0
214      */
215     @Config(defaultValue = MAVEN_STYLE_INFO_DEFAULT)
216     public static final String MAVEN_STYLE_INFO = MAVEN_STYLE_PREFIX + MAVEN_STYLE_INFO_NAME;
217 
218     /**
219      * Color style for warning messages.
220      * @since 4.0.0
221      */
222     @Config(defaultValue = MAVEN_STYLE_WARNING_DEFAULT)
223     public static final String MAVEN_STYLE_WARNING = MAVEN_STYLE_PREFIX + MAVEN_STYLE_WARNING_NAME;
224 
225     /**
226      * Color style for error messages.
227      * @since 4.0.0
228      */
229     @Config(defaultValue = MAVEN_STYLE_ERROR_DEFAULT)
230     public static final String MAVEN_STYLE_ERROR = MAVEN_STYLE_PREFIX + MAVEN_STYLE_ERROR_NAME;
231 
232     /**
233      * Color style for success messages.
234      * @since 4.0.0
235      */
236     @Config(defaultValue = MAVEN_STYLE_SUCCESS_DEFAULT)
237     public static final String MAVEN_STYLE_SUCCESS = MAVEN_STYLE_PREFIX + MAVEN_STYLE_SUCCESS_NAME;
238 
239     /**
240      * Color style for failure messages.
241      * @since 4.0.0
242      */
243     @Config(defaultValue = MAVEN_STYLE_FAILURE_DEFAULT)
244     public static final String MAVEN_STYLE_FAILURE = MAVEN_STYLE_PREFIX + MAVEN_STYLE_FAILURE_NAME;
245 
246     /**
247      * Color style for strong messages.
248      * @since 4.0.0
249      */
250     @Config(defaultValue = MAVEN_STYLE_STRONG_DEFAULT)
251     public static final String MAVEN_STYLE_STRONG = MAVEN_STYLE_PREFIX + MAVEN_STYLE_STRONG_NAME;
252 
253     /**
254      * Color style for mojo messages.
255      * @since 4.0.0
256      */
257     @Config(defaultValue = MAVEN_STYLE_MOJO_DEFAULT)
258     public static final String MAVEN_STYLE_MOJO = MAVEN_STYLE_PREFIX + MAVEN_STYLE_MOJO_NAME;
259 
260     /**
261      * Color style for project messages.
262      * @since 4.0.0
263      */
264     @Config(defaultValue = MAVEN_STYLE_PROJECT_DEFAULT)
265     public static final String MAVEN_STYLE_PROJECT = MAVEN_STYLE_PREFIX + MAVEN_STYLE_PROJECT_NAME;
266 
267     /**
268      * Build timestamp format.
269      *
270      * @since 3.0.0
271      */
272     @Config(source = Config.Source.MODEL, defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX")
273     public static final String MAVEN_BUILD_TIMESTAMP_FORMAT = "maven.build.timestamp.format";
274 
275     /**
276      * User controlled relocations.
277      * This property is a comma separated list of entries with the syntax <code>GAV&gt;GAV</code>.
278      * The first <code>GAV</code> can contain <code>*</code> for any elem (so <code>*:*:*</code> would mean ALL, something
279      * you don't want). The second <code>GAV</code> is either fully specified, or also can contain <code>*</code>,
280      * then it behaves as "ordinary relocation": the coordinate is preserved from relocated artifact.
281      * Finally, if right hand <code>GAV</code> is absent (line looks like <code>GAV&gt;</code>), the left hand matching
282      * <code>GAV</code> is banned fully (from resolving).
283      * <br/>
284      * Note: the <code>&gt;</code> means project level, while <code>&gt;&gt;</code> means global (whole session level,
285      * so even plugins will get relocated artifacts) relocation.
286      * <br/>
287      * For example,
288      * <pre>maven.relocations.entries = org.foo:*:*>, \\<br/>    org.here:*:*>org.there:*:*, \\<br/>    javax.inject:javax.inject:1>>jakarta.inject:jakarta.inject:1.0.5</pre>
289      * means: 3 entries, ban <code>org.foo group</code> (exactly, so <code>org.foo.bar</code> is allowed),
290      * relocate <code>org.here</code> to <code>org.there</code> and finally globally relocate (see <code>&gt;&gt;</code> above)
291      * <code>javax.inject:javax.inject:1</code> to <code>jakarta.inject:jakarta.inject:1.0.5</code>.
292      *
293      * @since 4.0.0
294      */
295     @Config
296     public static final String MAVEN_RELOCATIONS_ENTRIES = "maven.relocations.entries";
297 
298     /**
299      * User property for version filter expression used in session, applied to resolving ranges: a semicolon separated
300      * list of filters to apply. By default, no version filter is applied (like in Maven 3).
301      * <br/>
302      * Supported filters:
303      * <ul>
304      *     <li>"h" or "h(num)" - highest version or top list of highest ones filter</li>
305      *     <li>"l" or "l(num)" - lowest version or bottom list of lowest ones filter</li>
306      *     <li>"s" - contextual snapshot filter</li>
307      *     <li>"e(G:A:V)" - predicate filter (leaves out G:A:V from range, if hit, V can be range)</li>
308      * </ul>
309      * Example filter expression: <code>"h(5);s;e(org.foo:bar:1)</code> will cause: ranges are filtered for "top 5" (instead
310      * full range), snapshots are banned if root project is not a snapshot, and if range for <code>org.foo:bar</code> is
311      * being processed, version 1 is omitted. Value in this property builds
312      * <code>org.eclipse.aether.collection.VersionFilter</code> instance.
313      *
314      * @since 4.0.0
315      */
316     @Config
317     public static final String MAVEN_VERSION_FILTER = "maven.session.versionFilter";
318 
319     /**
320      * User property for chained LRM: the new "head" local repository to use, and "push" the existing into tail.
321      * Similar to <code>maven.repo.local.tail</code>, this property may contain comma separated list of paths to be
322      * used as local repositories (combine with chained local repository), but while latter is "appending" this
323      * one is "prepending".
324      *
325      * @since 4.0.0
326      */
327     @Config
328     public static final String MAVEN_REPO_LOCAL_HEAD = "maven.repo.local.head";
329 
330     /**
331      * User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with
332      * <code>org.eclipse.aether.util.repository.ChainedLocalRepositoryManager</code>.
333      * Default value: <code>null</code>, no chained LRM is used.
334      *
335      * @since 3.9.0
336      */
337     @Config
338     public static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail";
339 
340     /**
341      * User property for chained LRM: whether to ignore "availability check" in tail or not. Usually you do want
342      * to ignore it. This property is mapped onto corresponding Resolver 2.x property, is like a synonym for it.
343      * Default value: <code>true</code>.
344      *
345      * @since 3.9.0
346      * @see <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration: aether.chainedLocalRepository.ignoreTailAvailability</a>
347      */
348     @Config
349     public static final String MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY = "maven.repo.local.tail.ignoreAvailability";
350 
351     /**
352      * User property for reverse dependency tree. If enabled, Maven will record ".tracking" directory into local
353      * repository with "reverse dependency tree", essentially explaining WHY given artifact is present in local
354      * repository.
355      * Default: <code>false</code>, will not record anything.
356      *
357      * @since 3.9.0
358      */
359     @Config(defaultValue = "false")
360     public static final String MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE = "maven.repo.local.recordReverseTree";
361 
362     /**
363      * User property for selecting dependency manager behaviour regarding transitive dependencies and dependency
364      * management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored
365      * dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence
366      * unlike Maven2, obeys dependency management entries deep in dependency graph as well.
367      * <br/>
368      * Default: <code>"true"</code>.
369      *
370      * @since 4.0.0
371      */
372     @Config(defaultValue = "true")
373     public static final String MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY =
374             "maven.resolver.dependencyManagerTransitivity";
375 
376     /**
377      * Resolver transport to use.
378      * Can be <code>default</code>, <code>wagon</code>, <code>apache</code>, <code>jdk</code> or <code>auto</code>.
379      *
380      * @since 4.0.0
381      */
382     @Config(defaultValue = "default")
383     public static final String MAVEN_RESOLVER_TRANSPORT = "maven.resolver.transport";
384 
385     /**
386      * Plugin validation level.
387      *
388      * @since 3.9.2
389      */
390     @Config(defaultValue = "inline")
391     public static final String MAVEN_PLUGIN_VALIDATION = "maven.plugin.validation";
392 
393     /**
394      * Plugin validation exclusions.
395      *
396      * @since 3.9.6
397      */
398     @Config
399     public static final String MAVEN_PLUGIN_VALIDATION_EXCLUDES = "maven.plugin.validation.excludes";
400 
401     /**
402      * ProjectBuilder parallelism.
403      *
404      * @since 4.0.0
405      */
406     @Config(type = "java.lang.Integer", defaultValue = "cores/2 + 1")
407     public static final String MAVEN_MODEL_BUILDER_PARALLELISM = "maven.modelBuilder.parallelism";
408 
409     /**
410      * User property for enabling/disabling the consumer POM feature.
411      *
412      * @since 4.0.0
413      */
414     @Config(type = "java.lang.Boolean", defaultValue = "true")
415     public static final String MAVEN_CONSUMER_POM = "maven.consumer.pom";
416 
417     /**
418      * User property for disabling version resolver cache.
419      *
420      * @since 3.0.0
421      */
422     @Config(type = "java.lang.Boolean", defaultValue = "false")
423     public static final String MAVEN_VERSION_RESOLVER_NO_CACHE = "maven.versionResolver.noCache";
424 
425     /**
426      * User property for overriding calculated "build number" for snapshot deploys. Caution: this property should
427      * be RARELY used (if used at all). It may help in special cases like "aligning" a reactor build subprojects
428      * build numbers to perform a "snapshot lock down". Value given here must be <code>maxRemoteBuildNumber + 1</code>
429      * or greater, otherwise build will fail. How the number to be obtained is left to user (ie by inspecting
430      * snapshot repository metadata or alike).
431      *
432      * Note: this feature is present in Maven 3.9.7 but with different key: <code>maven.buildNumber</code>. In Maven 4
433      * as part of cleanup effort this key was renamed to properly reflect its purpose.
434      *
435      * @since 4.0.0
436      */
437     @Config(type = "java.lang.Integer")
438     public static final String MAVEN_DEPLOY_SNAPSHOT_BUILD_NUMBER = "maven.deploy.snapshot.buildNumber";
439 
440     /**
441      * User property used to store the build timestamp.
442      *
443      * @since 4.0.0
444      */
445     @Config(type = "java.time.Instant")
446     public static final String MAVEN_START_INSTANT = "maven.startInstant";
447 
448     private Constants() {}
449 }