-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[MNG-7553] Introduce SettingsBuilder and ToolchainsBuilder services #819
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
Conversation
|
Can you elaborate on the change? When was it broken? |
When the v4 api was merged, a few services were migrated to the new API, but that was a mistake because they are in use by plugins. This is the case for the I need to investigate why the IT is failing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see two general issues/questions here:
- We have already briefly discussed the benefit/overrating of
Optional. Can you explain why it makes sense here? I meanX != nullis as good as here. - I have a general problem with the terms
XBuilderRequest/XBuilderResult/XBuilderException. I think this is incorrectly names since it implies that there is something with the builder and not the build itself. In other spots we use the termsXBuildingRequest/XBuildingResult/XBuildingException/XBuildingProblemor justBuild. @elharo Sample: https://github.com/apache/maven/blob/35b93b0a589752cc88105623a2ddf9e52b56c1ce/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingRequest.java
| */ | ||
| @Nonnull | ||
| Collection<ProjectBuilderProblem> getProblems(); | ||
| Collection<BuilderProblem> getProblems(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupid question: Is it really a problem with the builder or a problem with the build?
| * @throws SettingsBuilderException If the effective settings could not be built. | ||
| */ | ||
| @Nonnull | ||
| SettingsBuilderResult build( @Nonnull SettingsBuilderRequest request ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here.
| * @return The global settings path or {@code null} if none. | ||
| */ | ||
| @Nonnull | ||
| Optional<Path> getGlobalSettingsPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc does not match code
| * @return The global settings source or {@code null} if none. | ||
| */ | ||
| @Nonnull | ||
| Optional<Source> getGlobalSettingsSource(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc does not match code
| * @return The user settings path or {@code null} if none. | ||
| */ | ||
| @Nonnull | ||
| Optional<Path> getUserSettingsPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc does not match code
| * @return The user Toolchains path or {@code null} if none. | ||
| */ | ||
| @Nonnull | ||
| Optional<Path> getUserToolchainsPath(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc does not match code
| * @return The user Toolchains source or {@code null} if none. | ||
| */ | ||
| @Nonnull | ||
| Optional<Source> getUserToolchainsSource(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc does not match code
| .globalToolchainsSource( nonNull( globalToolchainsSource, "globalToolchainsSource can not be null" ) ) | ||
| .userToolchainsSource( nonNull( userToolchainsSource, "userToolchainsSource can not be null" ) ) | ||
| .build(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot
| .globalToolchainsPath( nonNull( globalToolchainsPath, "globalToolchainsPath can not be null" ) ) | ||
| .userToolchainsPath( nonNull( userToolchainsPath, "userToolchainsPath can not be null" ) ) | ||
| .build(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cannot
|
|
||
| @Override | ||
| public ProjectBuilderProblemSeverity getSeverity() | ||
| public BuilderProblemSeverity getSeverity() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't it BuilderProblem.Severity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason, I'll move it as an inner enum.
elharo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't read the whole thin yet, but I tend to agree that Optional is at best as bad as null, and sometimes worse.
|
|
||
| /** | ||
| * Gets the user properties to use for interpolation. The user properties have been configured directly by the user | ||
| * on his discretion, e.g. via the {@code -Dkey=value} parameter on the command line. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete "on his discretion"
, --> ;
|
|
||
| /** | ||
| * Gets the system properties to use for interpolation. The system properties are collected from the runtime | ||
| * environment like {@link System#getProperties()} and environment variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like --> such as
| @Nonnull | ||
| SessionData getData(); | ||
|
|
||
| /** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc additions to existing API are useful but can be included in a separate PR that is easier to approve.
| */ | ||
| @Experimental | ||
| public enum ProjectBuilderProblemSeverity | ||
| public enum BuilderProblemSeverity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename seems unnecessary
| * @param session The {@link Session}, must not be {@code null}. | ||
| * @param source The {@link ProjectBuilderSource}, must not be {@code null}. | ||
| * @throws ProjectBuilderException if the project cannot be created | ||
| * @param source The {@link Source}, must not be {@code null}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --> the
| * @param source The {@link ProjectBuilderSource}, must not be {@code null}. | ||
| * @throws ProjectBuilderException if the project cannot be created | ||
| * @param source The {@link Source}, must not be {@code null}. | ||
| * @throws ProjectBuilderException if the project can not be created |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert, cannot is one word
| import org.apache.maven.api.annotations.Nonnull; | ||
|
|
||
| /** | ||
| * Builds the effective settings from a user settings file and/or a global settings file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is "effective settings"? How does that differ from other settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "effective" here means an aggregation/merge of the global and user settings.
what is "effective settings"? How does that differ from other settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to put this in the docs, perhaps rewriting without the word effective
| * | ||
| * @param request The settings building request that holds the parameters, must not be {@code null}. | ||
| * @return The result of the settings building, never {@code null}. | ||
| * @throws SettingsBuilderException If the effective settings could not be built. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the effective settings could not be built
| /** | ||
| * Builds the effective settings of the specified settings files. | ||
| * | ||
| * @param request The settings building request that holds the parameters, must not be {@code null}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The --> the (per Oracle, API doc params do not begin with a capital letter
| { | ||
| /** | ||
| * @param message The message to give. | ||
| * @param e The {@link Exception}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't repeat type information in doc comments. It's redundant. Instead explain what this exception is
|
I'm going to split that PR in 2. This one will be kept for the modifications on the v4 api : the new services and the related discussions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean and simple, except for the comments of @elharo
I slightly disagree. The main differences are that when using an This also hurts code concision. A simple example found in the code: This could be rewritten as: This is actually related to the fact that the maven coding style is very sparse. I actually find that quite difficult to work with (even if I'm getting used to it). That may be due to the fact I'm working almost exclusively on a laptop, so the height of it is limited, and only seing 30-40 lines of code at the same time becomes a problem when nearly 50% of those don't really convey any semantic (being blank lines or braces usually). It means more time to scroll through the code back and forth to understand it. I don't like that. Streams are another way to get around empty lines, just because often, you simply don't need braces when using them, so you have 1 line instead of 3. So generally speaking, the more semantic carried by the code, the better. I agree to not overuse
I'm actually seeing the terms as a request to the X builder, the result returned by X builder, the exception thrown by X builder. We can't use quotes, but think about those as XBuilder's request, XBuilder's result, XBuilder's exception. I actually think those make more sense than what we have in other places. It's also easier to see the relationship between the service and its related request/result/exception. Another point that just came to my mind is that wording like |
This reasoning I can follow where
Let me crunch on this. @elharo What is your opinion on the style here? |
|
Resolve #8332 |
Adds
ToolchainsBuilderandSettingsBuilderservices.