Skip to content

Commit 72e905d

Browse files
committed
[MNG-7914] Use a single place to document all maven properties
1 parent b3e373f commit 72e905d

File tree

16 files changed

+1033
-139
lines changed

16 files changed

+1033
-139
lines changed

apache-maven/src/assembly/maven/conf/maven.properties

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@
22
# Maven user properties
33
#
44

5+
maven.installation.conf = ${maven.home}/conf
6+
maven.user.conf = ${user.home}/.m2
7+
maven.project.conf = ${session.rootDirectory}/.mvn
8+
59
# Comma-separated list of files to include.
610
# Each item may be enclosed in quotes to gracefully include spaces. Items are trimmed before being loaded.
711
# If the first character of an item is a question mark, the load will silently fail if the file does not exist.
8-
${includes} = "?${user.home}/.m2/maven.properties", \
9-
"?${session.rootDirectory}/.mvn/maven.properties"
12+
${includes} = "?${maven.user.conf}/maven.properties", \
13+
"?${maven.project.conf}/maven.properties"
1014

15+
#
16+
# Settings
17+
#
18+
# Define the default three levels for settings.
19+
# The '-is' flag will override the 'maven.installation.settings' property.
20+
# The '-ps' flag will override the 'maven.project.settings' property.
21+
# The '-s' flag will override the 'maven.user.settings' property.
22+
maven.installation.settings = ${maven.installation.conf}/settings.xml
23+
maven.project.settings = ${maven.project.conf}/settings.xml
24+
maven.user.settings = ${maven.user.conf}/settings.xml
25+
26+
#
27+
# Toolchains
28+
#
29+
# Define the default three levels for toolchains.
30+
# The '-it' flag will override the 'maven.installation.toolchains' property.
31+
# The '-t' flag will override the 'maven.user.toolchains' property.
32+
maven.installation.toolchains = ${maven.installation.conf}/toolchains.xml
33+
maven.user.toolchains = ${maven.user.conf}/toolchains.xml
34+
35+
#
36+
# Extensions
37+
#
38+
maven.installation.extensions = ${maven.installation.conf}/extensions.xml
39+
maven.project.extensions = ${maven.project.conf}/extensions.xml
40+
maven.user.extensions = ${maven.user.conf}/extensions.xml
Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
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 installation settings.
70+
*
71+
* @since 4.0.0
72+
*/
73+
@Config(defaultValue = "${maven.installation.conf}/settings.xml")
74+
public static final String MAVEN_INSTALLATION_SETTINGS = "maven.installation.settings";
75+
76+
/**
77+
* Maven user settings.
78+
*
79+
* @since 4.0.0
80+
*/
81+
@Config(defaultValue = "${maven.user.conf}/settings.xml")
82+
public static final String MAVEN_USER_SETTINGS = "maven.user.settings";
83+
84+
/**
85+
* Maven project settings.
86+
*
87+
* @since 4.0.0
88+
*/
89+
@Config(defaultValue = "${maven.project.conf}/settings.xml")
90+
public static final String MAVEN_PROJECT_SETTINGS = "maven.project.settings";
91+
92+
/**
93+
* Maven installation extensions.
94+
*
95+
* @since 4.0.0
96+
*/
97+
@Config(defaultValue = "${maven.installation.conf}/extensions.xml")
98+
public static final String MAVEN_INSTALLATION_EXTENSIONS = "maven.installation.extensions";
99+
100+
/**
101+
* Maven user extensions.
102+
*
103+
* @since 4.0.0
104+
*/
105+
@Config(defaultValue = "${maven.user.conf}/extensions.xml")
106+
public static final String MAVEN_USER_EXTENSIONS = "maven.user.extensions";
107+
108+
/**
109+
* Maven project extensions.
110+
*
111+
* @since 4.0.0
112+
*/
113+
@Config(defaultValue = "${maven.project.conf}/extensions.xml")
114+
public static final String MAVEN_PROJECT_EXTENSIONS = "maven.project.extensions";
115+
116+
/**
117+
* Maven installation toolchains.
118+
*
119+
* @since 4.0.0
120+
*/
121+
@Config(defaultValue = "${maven.installation.conf}/toolchains.xml")
122+
public static final String MAVEN_INSTALLATION_TOOLCHAINS = "maven.installation.toolchains";
123+
124+
/**
125+
* Maven user toolchains.
126+
*
127+
* @since 4.0.0
128+
*/
129+
@Config(defaultValue = "${maven.user.home}/toolchains.xml")
130+
public static final String MAVEN_USER_TOOLCHAINS = "maven.user.toolchains";
131+
132+
/**
133+
* Extensions class path.
134+
*/
135+
@Config
136+
public static final String MAVEN_EXT_CLASS_PATH = "maven.ext.class.path";
137+
138+
/**
139+
* Maven output color mode.
140+
* Allowed values are <code>auto</code>, <code>always</code>, <code>never</code>.
141+
*
142+
* @since 4.0.0
143+
*/
144+
@Config(defaultValue = "auto")
145+
public static final String MAVEN_STYLE_COLOR_PROPERTY = "maven.style.color";
146+
147+
/**
148+
* Build timestamp format.
149+
*
150+
* @since 3.0.0
151+
*/
152+
@Config(source = Config.Source.MODEL, defaultValue = "yyyy-MM-dd'T'HH:mm:ssXXX")
153+
public static final String MAVEN_BUILD_TIMESTAMP_FORMAT = "maven.build.timestamp.format";
154+
155+
/**
156+
* User controlled relocations.
157+
* This property is a comma separated list of entries with the syntax <code>GAV&gt;GAV</code>.
158+
* The first <code>GAV</code> can contain <code>*</code> for any elem (so <code>*:*:*</code> would mean ALL, something
159+
* you don't want). The second <code>GAV</code> is either fully specified, or also can contain <code>*</code>,
160+
* then it behaves as "ordinary relocation": the coordinate is preserved from relocated artifact.
161+
* Finally, if right hand <code>GAV</code> is absent (line looks like <code>GAV&gt;</code>), the left hand matching
162+
* <code>GAV</code> is banned fully (from resolving).
163+
* <p>
164+
* Note: the <code>&gt;</code> means project level, while <code>&gt;&gt;</code> means global (whole session level,
165+
* so even plugins will get relocated artifacts) relocation.
166+
* </p>
167+
* <p>
168+
* For example,
169+
* <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>
170+
* means: 3 entries, ban <code>org.foo group</code> (exactly, so <code>org.foo.bar</code> is allowed),
171+
* relocate <code>org.here</code> to <code>org.there</code> and finally globally relocate (see <code>&gt;&gt;</code> above)
172+
* <code>javax.inject:javax.inject:1</code> to <code>jakarta.inject:jakarta.inject:1.0.5</code>.
173+
* </p>
174+
*
175+
* @since 4.0.0
176+
*/
177+
@Config
178+
public static final String MAVEN_RELOCATIONS_ENTRIES = "maven.relocations.entries";
179+
180+
/**
181+
* User property for version filters expression, a semicolon separated list of filters to apply. By default, no version
182+
* filter is applied (like in Maven 3).
183+
* <p>
184+
* Supported filters:
185+
* <ul>
186+
* <li>"h" or "h(num)" - highest version or top list of highest ones filter</li>
187+
* <li>"l" or "l(num)" - lowest version or bottom list of lowest ones filter</li>
188+
* <li>"s" - contextual snapshot filter</li>
189+
* <li>"e(G:A:V)" - predicate filter (leaves out G:A:V from range, if hit, V can be range)</li>
190+
* </ul>
191+
* Example filter expression: <code>"h(5);s;e(org.foo:bar:1)</code> will cause: ranges are filtered for "top 5" (instead
192+
* full range), snapshots are banned if root project is not a snapshot, and if range for <code>org.foo:bar</code> is
193+
* being processed, version 1 is omitted.
194+
* </p>
195+
*
196+
* @since 4.0.0
197+
*/
198+
@Config
199+
public static final String MAVEN_VERSION_FILTERS = "maven.versionFilters";
200+
201+
/**
202+
* User property for chained LRM: list of "tail" local repository paths (separated by comma), to be used with
203+
* {@code org.eclipse.aether.util.repository.ChainedLocalRepositoryManager}.
204+
* Default value: <code>null</code>, no chained LRM is used.
205+
*
206+
* @since 3.9.0
207+
*/
208+
@Config
209+
public static final String MAVEN_REPO_LOCAL_TAIL = "maven.repo.local.tail";
210+
211+
/**
212+
* User property for reverse dependency tree. If enabled, Maven will record ".tracking" directory into local
213+
* repository with "reverse dependency tree", essentially explaining WHY given artifact is present in local
214+
* repository.
215+
* Default: <code>false</code>, will not record anything.
216+
*
217+
* @since 3.9.0
218+
*/
219+
@Config(defaultValue = "false")
220+
public static final String MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE = "maven.repo.local.recordReverseTree";
221+
222+
/**
223+
* User property for selecting dependency manager behaviour regarding transitive dependencies and dependency
224+
* management entries in their POMs. Maven 3 targeted full backward compatibility with Maven2, hence it ignored
225+
* dependency management entries in transitive dependency POMs. Maven 4 enables "transitivity" by default, hence
226+
* unlike Maven2, obeys dependency management entries deep in dependency graph as well.
227+
* <p>
228+
* Default: <code>"true"</code>.
229+
* </p>
230+
*
231+
* @since 4.0.0
232+
*/
233+
@Config(defaultValue = "true")
234+
public static final String MAVEN_RESOLVER_DEPENDENCY_MANAGER_TRANSITIVITY =
235+
"maven.resolver.dependencyManagerTransitivity";
236+
237+
/**
238+
* Resolver transport to use.
239+
* Can be <code>default</code>, <code>wagon</code>, <code>apache</code>, <code>jdk</code> or <code>auto</code>.
240+
*
241+
* @since 4.0.0
242+
*/
243+
@Config(defaultValue = "default")
244+
public static final String MAVEN_RESOLVER_TRANSPORT = "maven.resolver.transport";
245+
246+
/**
247+
* Plugin validation level.
248+
*
249+
* @since 3.9.2
250+
*/
251+
@Config(defaultValue = "inline")
252+
public static final String MAVEN_PLUGIN_VALIDATION = "maven.plugin.validation";
253+
254+
/**
255+
* Plugin validation exclusions.
256+
*
257+
* @since 3.9.6
258+
*/
259+
@Config
260+
public static final String MAVEN_PLUGIN_VALIDATION_EXCLUDES = "maven.plugin.validation.excludes";
261+
262+
/**
263+
* ProjectBuilder parallelism.
264+
*
265+
* @since 4.0.0
266+
*/
267+
@Config(type = "java.lang.Integer", defaultValue = "cores/2 + 1")
268+
public static final String MAVEN_PROJECT_BUILDER_PARALLELISM = "maven.projectBuilder.parallelism";
269+
270+
private Constants() {}
271+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.annotations;
20+
21+
import java.lang.annotation.Documented;
22+
import java.lang.annotation.ElementType;
23+
import java.lang.annotation.Retention;
24+
import java.lang.annotation.RetentionPolicy;
25+
import java.lang.annotation.Target;
26+
27+
@Experimental
28+
@Documented
29+
@Retention(RetentionPolicy.CLASS)
30+
@Target(ElementType.FIELD)
31+
public @interface Config {
32+
33+
Source source() default Source.USER_PROPERTIES;
34+
35+
String type() default "java.lang.String";
36+
37+
String defaultValue() default "";
38+
39+
boolean readOnly() default false;
40+
41+
enum Source {
42+
USER_PROPERTIES,
43+
MODEL
44+
}
45+
}

maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/MavenBuildTimestamp.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
import java.util.Map;
2626
import java.util.Properties;
2727

28+
import org.apache.maven.api.Constants;
29+
2830
/**
2931
* MavenBuildTimestamp
3032
*/
3133
public class MavenBuildTimestamp {
3234
// ISO 8601-compliant timestamp for machine readability
3335
public static final String DEFAULT_BUILD_TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX";
3436

35-
public static final String BUILD_TIMESTAMP_FORMAT_PROPERTY = "maven.build.timestamp.format";
36-
3737
private final String formattedTimestamp;
3838

3939
public MavenBuildTimestamp() {
@@ -45,7 +45,7 @@ public MavenBuildTimestamp(Instant time) {
4545
}
4646

4747
public MavenBuildTimestamp(Instant time, Map<String, String> properties) {
48-
this(time, properties != null ? properties.get(BUILD_TIMESTAMP_FORMAT_PROPERTY) : null);
48+
this(time, properties != null ? properties.get(Constants.MAVEN_BUILD_TIMESTAMP_FORMAT) : null);
4949
}
5050

5151
/**
@@ -55,7 +55,7 @@ public MavenBuildTimestamp(Instant time, Map<String, String> properties) {
5555
*/
5656
@Deprecated
5757
public MavenBuildTimestamp(Instant time, Properties properties) {
58-
this(time, properties != null ? properties.getProperty(BUILD_TIMESTAMP_FORMAT_PROPERTY) : null);
58+
this(time, properties != null ? properties.getProperty(Constants.MAVEN_BUILD_TIMESTAMP_FORMAT) : null);
5959
}
6060

6161
public MavenBuildTimestamp(Instant time, String timestampFormat) {

0 commit comments

Comments
 (0)