Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some javadoc / website doc to known maven properties #1597

Closed
wants to merge 12 commits into from

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Jul 5, 2024

Follow-up to #1595

This PR adds an annotation, a class in the API to contain all config properties, and add a doc generation for those.

@gnodet
Copy link
Contributor Author

gnodet commented Jul 5, 2024

Missing:

@gnodet
Copy link
Contributor Author

gnodet commented Jul 5, 2024

@michael-o Defining maven.user.home = ${user.home}/.maven should move the repository, toolchains and other config bits to a different place in the user home directory (maybe some are missing) .

@michael-o
Copy link
Member

@michael-o Defining maven.user.home = ${user.home}/.maven should move the repository, toolchains and other config bits to a different place in the user home directory (maybe some are missing) .

maven.user.home implies that there might be other properties with maven.user. prefix. I doubt that we should do that. I think that maven.userdir should be better.

Both refer to it as config dir:

# Maven user properties
#

maven.user.home = ${user.home}/.m2
Copy link
Member

@michael-o michael-o Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on my previous comment: maven.user.conf? Akin to maven.conf?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wouldn't be consistent with the global props. All of those XML files are config files, at the end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, as that IS "maven user home", so "user home" plus something, local repo is not config, is it?

Copy link
Member

@cstamas cstamas Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, that is where mvnd daemons logs, where indexer put some files, resolver put file locks, and so on... it is IMHO really "maven user home".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, as that IS "maven user home", so "user home" plus something, local repo is not config, is it?

It is not, and this is the reason why it has its own property to be relocated. For technical reasons we can only assume the user home to be writable, but that can be a problem if it is NFS mounted or similar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus, that is where mvnd daemons logs, where indexer put some files, resolver put file locks, and so on... it is IMHO really "maven user home".

Then we need maven.user.workdir or similar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cstamas The problem you describe has been solved by Windows with APPDATA\{Roaming,Local,LocalLow} the the conf files will roam, but the generated stuff will be in Local, if not even LocalLow, thus never be network mounted.

@gnodet
Copy link
Contributor Author

gnodet commented Jul 5, 2024

@michael-o I don't have a strong opinion on the naming, but I'd really like them to be consistent.
The properties file does not contain all of them, so maybe looking at the new Constants class would be better.
And I agree we don't always have the 3 conf levels clearly explicited. The naming is not always homogeneous (I've renamed a few ones that were introduced in 4.x, so no real breakage).
To rename old ones (such as maven.conf -> maven.global.conf), we need to keep the previous one and make it an alias somehow. This is doable.

So if we can come up with clear rules, that would be the best imho.

@michael-o
Copy link
Member

@michael-o I don't have a strong opinion on the naming, but I'd really like them to be consistent. The properties file does not contain all of them, so maybe looking at the new Constants class would be better. And I agree we don't always have the 3 conf levels clearly explicited. The naming is not always homogeneous (I've renamed a few ones that were introduced in 4.x, so no real breakage). To rename old ones (such as maven.conf -> maven.global.conf), we need to keep the previous one and make it an alias somehow. This is doable.

So if we can come up with clear rules, that would be the best imho.

We should strive for repeatable consistency.

@cstamas
Copy link
Member

cstamas commented Jul 5, 2024

I would perform these renames... these "options" were hidden (like maven.buildNumber, am sure, was used by me only, as it was nor even documented). So no harm, but we have 3.x to 4.x change as well, so I'd do all to make those "pretty clear", and many of those do need rename as were mostly ad-hoc named as 4.x was done....

@michael-o
Copy link
Member

I would perform these renames... these "options" were hidden (like maven.buildNumber, am sure, was used by me only, as it was nor even documented). So no harm, but we have 3.x to 4.x change as well, so I'd do all to make those "pretty clear", and many of those do need rename as were mostly ad-hoc named as 4.x was done....

Which exactly do you mean?

@gnodet gnodet added this to the 4.0.0-beta-4 milestone Jul 6, 2024
@gnodet
Copy link
Contributor Author

gnodet commented Jul 6, 2024

What about:

  • maven.home
  • maven.global.conf = ${maven.home}/conf (we deprecate maven.conf and use it as an alias to maven.global.conf)
  • maven.user.conf = ${user.home}/.m2
  • maven.project.conf = ${session.rootDirectory}/.mvn
  • maven.global.toolchains = ${maven.global.conf}/toolchains.xml
  • maven.user.toolchains = ${maven.user.conf}/toolchains.xml (we don't have project toolchains)
  • maven.global.extensions = ${maven.global.conf}/extensions.xml
  • maven.user.extensions = ${maven.user.conf}/extensions.xml
  • maven.project.extensions = ${maven.project.conf}/extensions

@gnodet gnodet modified the milestones: 4.0.0-beta-4, 4.0.0 Jul 6, 2024
@cstamas
Copy link
Member

cstamas commented Jul 9, 2024

One question: before it was "maven system home" and "maven user home"... why "global" now? IMHO is not global for sure, especially as you can have multiple maven versions in multiple terminals (like with sdkman) and as single user. So "global" is kinda misleading to me. I like more "maven system..."

@cstamas
Copy link
Member

cstamas commented Jul 9, 2024

But overall, this PR is something that was missing a LOT, this is very cool!

@cstamas
Copy link
Member

cstamas commented Jul 9, 2024

Also one nit: @since is missing from output, but as I see constants are lacking them (hence generated doco is missing them as well).

@michael-o
Copy link
Member

One question: before it was "maven system home" and "maven user home"... why "global" now? IMHO is not global for sure, especially as you can have multiple maven versions in multiple terminals (like with sdkman) and as single user. So "global" is kinda misleading to me. I like more "maven system..."

Regarding this: we have discussed this notion last year with @rfscholte and came up with https://cwiki.apache.org/confluence/display/MAVEN/Commandline+inheritance. Globals to the installation. We don't have inter-Maven config like other applications have.

@cstamas
Copy link
Member

cstamas commented Jul 9, 2024

This is all about "precedence". Take for example settings:

  • installation provides one (default system settings)
  • user may provide one (default user settings)

but both can be overridden, so you could have "inter-maven" settings like "workstation specific" (for example all uers of given workstation access network in same way, so HTTP proxy as example) + "user specific" (users use user specific credentials).

IMHO, this is more about specificity and/or precedence... so "user" MAY override things from "system", the final settings is built by "layering" in proper order.

Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet another stupid comment to pick up @cstamas' concerns: Since the user home contains handwritten conf and generated stuff, wouldn't it rather wise to introduce a new property, say maven.user.work which will point by default to maven.user.home, but can be remounted to host all the stuff like local repo, wrapper, indexes, etc? Those who do not want to have something like this on a network mount.

@@ -29,14 +29,14 @@ under the License.
|
| -s /path/to/user/settings.xml
|
| 2. Global Level. This settings.xml file provides configuration for all Maven
| 2. System Level. This settings.xml file provides configuration for all Maven
Copy link
Member

@michael-o michael-o Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider this a wrong as "global". See https://cwiki.apache.org/confluence/display/MAVEN/Commandline+inheritance. It should be "installation" level.

Copy link
Member

@cstamas cstamas Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what if I have defined on workstation MAVEN_ARGS=-gs=/etc/maven/settings.xml? Is that still "installation" level? Moreover. what if that env variable is defined in /etc/profile.d ?

Copy link
Member

@michael-o michael-o Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that is an override. It will then instruct the currently running Maven installation use that settings file. It could be in the profile or just in the current shell session, but there is no explicit system wide settings for all Maven installations by default. This is what I mean.

Copy link
Member

@cstamas cstamas Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that differently. We have "system" and "user" settings, and the utter difference between the two is precedence. Whatever they come from, or are they "default" or "override", their precedence is all that matters.

Copy link
Member

@cstamas cstamas Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very much alike how we build "effective POM/models", Maven does not care from where the bits come (is current POM in local repo, or in reactor, is parent POM resolved from remote...), what Maven cares is HOW the final result is assembled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FQN is "Maven System Level". We discussed here in context of Maven. So "Maven User Level" and "Maven System Level".

As in 'Maven System' and not Maven in the entire system (OS, etc)?

Copy link
Member

@michael-o michael-o Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnodet What I like is you are picking up the idea of https://github.com/apache/tomcat/blob/main/conf/catalina.properties#L33.

Honestly, I cannot decipher it: ${cli:it:-${cli:gt:-${maven.install.conf}/toolchains.xml}} Takes too much brain muscles from first glance.

I wonder why those XML files cannot be optional by default and Maven would simply iterate over

?${maven.install.extensions} \
                   ?${maven.project.extensions} \
                   ?${maven.user.extensions}

At the end we define the semantics how a property is interpreted. Git or Subversion do search for a user and global config and it is not a failure if both isn't there. Same here. We could log the absence at debug level. WDYT?
This would make the ? redudant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with removing the ? and assuming all those files are optional.

But that does not address CLI parameters. Right now, they are supported by dedicated code in MavenCli. The code would check if -t is set, and set the user toolchain file accordingly, else compute the default. It's one OR is the other, not both. So we need a way to have default values in the syntax, that's what the following would do:

maven.user.toolchains.default = ${maven.user.conf}/toolchains.xml}
maven.user.toolchains         = ${cli:t:-${maven.user.toolchains.default}}
maven.toolchains = ${maven.install.toolchains} \
                   ${maven.project.toolchains} \
                   ${maven.user.toolchains}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we may still need the ?. Currently, if you specify -t foo.xml, maven will fail if foo.xml file does not exist. Whereas default files can be safely ignored if they don't exist. So we need to be able to know if a file was explicitely specified or just defaulted imho. So maybe:

maven.user.toolchains         = ${cli:t:-?${maven.user.toolchains.default}}

Note that we could use cli.t instead of cli:t, this may be less confusing:

maven.user.toolchains         = ${cli.t:-?${maven.user.toolchains.default}}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem is that project settings are validated differently than user or install settings... If we have a single list, it will be hard to keep that information. I think this is the only case where those xml files (toolchains, settings, extensions) are loaded differently.

Another problem which is not currently addressed, is the merge of extensions.xml, but that's a different topic...

* @since 3.0.0
*/
@Config(source = Config.Source.MODEL, defaultValue = "yyyy-MM-dd'T'HH:mm:ss'Z'")
public static final String MAVEN_BUILD_TIMESTAMP_FORMAT = "maven.build.timestamp.format";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the problems with this is that the timezone (offset) is missing here. It should be either mentioned or we should switch to yyyy-MM-dd'T'HH:mm:ssXXX which will produce the same output as with Etc/UTC.

type = type.substring(javaLangPackage.length());
}
}
return nvl(type, "n/a");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"N/A"

* Enhancement of the standard <code>Properties</code>
* managing the maintain of comments, etc.
*/
public class Properties extends AbstractMap<String, String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maven this class should be called MavenProperties to avoid confusion?

*
* @param str the <code>String</code> to unescape, may be null
* @return the processed string
* @throws IllegalArgumentException if the Writer is <code>null</code>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which writer?

inUnicode = false;
hadSlash = false;
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Unable to parse unicode value: " + unicode, nfe);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this require documentation?


public static final String INCLUDES_PROPERTY = "${includes}"; // mandatory includes

public static final String OPTIONALS_PROPERTY = "${optionals}"; // optionals include
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can make optionals more succint with ${includes?} like we have in here: https://maven.apache.org/plugins/maven-assembly-plugin/faq.html#dashClassifier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the property key, you want to rename and use ${includes?} = ${user.home}/.m2/maven.properties ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as an idea. Maybe it is a bad one. I am open to ideas. Comments should read "mandatory includes"/"optional includes", but the property names aren't consistent in this regard.

Copy link
Contributor Author

@gnodet gnodet Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibility is to have a single list, and if the first character is a ?, then make it optional.

${includes} = ?${user.home}/.m2/maven.properties, \
              ?${session.rootDirectory}/.mvn/maven.properties

We have this syntax for profiles.


| No | Key | Type | Description | Default Value | Since | Source |
| --- | --- | --- | --- | --- | --- | --- |
| 1. | `maven.build.timestamp.format` | `String` | Build timestamp format. | `yyyy-MM-dd'T'HH:mm:ss'Z'` | 3.0.0 | Model properties |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the desc should contain the time zone information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is generated from the defaultValue above.

@cstamas
Copy link
Member

cstamas commented Jul 9, 2024

Which exactly do you mean?

I meant this one

Object bn = ConfigUtils.getObject(session, null, "maven.buildNumber");

But is not present in this PR yet. Essentially, I find this property badly named, that's all. As many other, but renaming these is IMHO out of scope for this PR.

@michael-o
Copy link
Member

This is all about "precedence". Take for example settings:

* installation provides one (default system settings)

* user may provide one (default user settings)

but both can be overridden, so you could have "inter-maven" settings like "workstation specific" (for example all uers of given workstation access network in same way, so HTTP proxy as example) + "user specific" (users use user specific credentials).

IMHO, this is more about specificity and/or precedence... so "user" MAY override things from "system", the final settings is built by "layering" in proper order.

This I don't understand. While the user settings can be shared between Maven versions, there is no global settings which is sourced by every Maven installation like mavenrc.

@michael-o
Copy link
Member

Which exactly do you mean?

I meant this one

Object bn = ConfigUtils.getObject(session, null, "maven.buildNumber");

But is not present in this PR yet. Essentially, I find this property badly named, that's all. As many other, but renaming these is IMHO out of scope for this PR.

Is there even proper docs for this property?

@cstamas
Copy link
Member

cstamas commented Jul 9, 2024

Is there even proper docs for this property?

See https://issues.apache.org/jira/browse/MNG-8054

# The '-is' flag will override the 'maven.install.settings' property.
# The '-ps' flag will override the 'maven.project.settings' property.
# The '-s' flag will override the 'maven.user.settings' property.
maven.install.settings = ${maven.install.conf}/settings.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention: This must not be confused with the Maven Install Plugin, hence: maven.installation.<prop>

@gnodet
Copy link
Contributor Author

gnodet commented Jul 10, 2024

Closing this PR in favour of #1595

@gnodet gnodet closed this Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants