Hello,

After meeting Hervé at an event, I tried using Maven 4 on $COMPANY's
projects.
I have a script to build about 140 projects, including libraries and
applications and two Maven plugins.
I encountered one bug, and I think I can make a few suggestions to improve
the UX.
The mail is quite long and about several topics, I can break it to
different topics if you prefer.

1- the Bug
Summary: can't combine ! and ? for profiles.

Related to https://issues.apache.org/jira/browse/MNG-7051

Detailed description:
My build script sets a bunch of profiles and applies them blindly to all
projects.
The profiles have various purposes, like building a front app and embed it
in an artifact, run code gen plugins etc.
With Maven 3, for projects that don't have this profile, I just get a
warning. Maven 4 is more strict and fails. I can mark the profile as
optional with -P?xxx  and that's fine.
The issue arises with profiles that are activeByDefault. I can not combine
? and ! to ask Maven 4 to disable the profile if it exists, and ignore it
if it doesn't exist.

2- UX improvements
a- When a profile doesn't exist, I get the following error:

[ERROR] The requested profiles [foo] could not be activated or deactivated
because they do not exist. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the
'-e' switch
[ERROR] Re-run Maven using the '-X' switch to enable verbose output
[ERROR]
[ERROR] For more information about the errors and possible solutions,
please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MissingProfilesException

- the link is dead
- the message could be improved to make the existence of '?' more
discoverable.
e.g:

[ERROR] The requested profiles [foo] could not be activated or deactivated
because they do not exist. If this is expected, mark the profile as
optional with '?'


b- the following message is not actionable

[INFO] Artifact com.sun.activation:all:pom:1.2.2 is present in the local
repository, but cached from a remote repository ID that is unavailable in
current build context, verifying that is downloadable from [central (
https://repo.maven.apache.org/maven2, default, releases)]

Maybe more information about how this situation can arise, and the issue it
causes. I have no precise suggestion here.


c- this should be DEBUG
I get what it is about, but as I user this is not a useful information
about my build:

[INFO] Loaded 22245 auto-discovered prefixes for remote repository central
(prefixes-central.txt)

d- Missing an explanation of the why
Could be inline if short enough or a link to doc

[WARNING] Unable to find the root directory. Create a .mvn directory in the
root directory or add the root="true" attribute on the root project's model
to identify it.

e- error reporting contains a lot of duplicate information between root and
modules. Maybe they can be grouped by category.
E.g.
[WARNING] 3 problems were encountered while building the effective model
for 'com.acme:the-module:jar:latest-SNAPSHOT' (use -e to see details)
[WARNING] Ignored POM import for:
commons-logging:commons-logging:jar:1.3.5@compile as already imported
commons-logging:commons-logging:jar:99-empty@compile. Add the conflicting
managed dependency directly to the dependencyManagement section of the POM.
[WARNING] Ignored POM import for:
org.assertj:assertj-core:jar:3.27.6@compile as already imported
org.assertj:assertj-core:jar:3.27.7@compile. Add the conflicting managed
dependency directly to the dependencyManagement section of the POM.
[WARNING] Ignored POM import for:
org.eclipse.angus:jakarta.mail:jar:2.0.3@compile as already imported
org.eclipse.angus:jakarta.mail:jar:2.0.5@compile. Add the conflicting
managed dependency directly to the dependencyManagement section of the POM.
[WARNING]
[WARNING] 3 problems were encountered while building the effective model
for 'com.acme:the-root:pom:latest-SNAPSHOT' (use -e to see details)
[WARNING] Ignored POM import for:
commons-logging:commons-logging:jar:1.3.5@compile as already imported
commons-logging:commons-logging:jar:99-empty@compile. Add the conflicting
managed dependency directly to the dependencyManagement section of the POM.
[WARNING] Ignored POM import for:
org.assertj:assertj-core:jar:3.27.6@compile as already imported
org.assertj:assertj-core:jar:3.27.7@compile. Add the conflicting managed
dependency directly to the dependencyManagement section of the POM.
[WARNING] Ignored POM import for:
org.eclipse.angus:jakarta.mail:jar:2.0.3@compile as already imported
org.eclipse.angus:jakarta.mail:jar:2.0.5@compile. Add the conflicting
managed dependency directly to the dependencyManagement section of the POM.
[WARNING]
[WARNING] Total model problems reported: 6

Deduplication could help readability, in particular as in my case the
problem in 'the-module' are inherited from 'the-root' and should be fixed
there.
E.g. we could have something like
[WARNING] 3 problems were encountered while building the effective model
for 'com.acme:the-root:pom:latest-SNAPSHOT' (use -e to see details)
[WARNING] Also impacts: ['com.acme:the-module:jar:latest-SNAPSHOT']
[WARNING] Ignored POM import for:
commons-logging:commons-logging:jar:1.3.5@compile as already imported
commons-logging:commons-logging:jar:99-empty@compile. Add the conflicting
managed dependency directly to the dependencyManagement section of the POM.
[WARNING] Ignored POM import for:
org.assertj:assertj-core:jar:3.27.6@compile as already imported
org.assertj:assertj-core:jar:3.27.7@compile. Add the conflicting managed
dependency directly to the dependencyManagement section of the POM.
[WARNING] Ignored POM import for:
org.eclipse.angus:jakarta.mail:jar:2.0.3@compile as already imported
org.eclipse.angus:jakarta.mail:jar:2.0.5@compile. Add the conflicting
managed dependency directly to the dependencyManagement section of the POM.
[WARNING]
[WARNING] Total model problems reported: 3

Thanks.

Reply via email to