maven icon indicating copy to clipboard operation
maven copied to clipboard

Accept the ? optional-profile prefix on Maven 3.10

Open slachiewicz opened this issue 1 month ago • 2 comments

Maven 4 treats -P ?id as an optional profile (MNG-7051): activate it if it exists, skip it otherwise. Maven 3.9 and 3.10 read ?id as a profile literally named ?id, warn that it does not exist, and leave the real profile off. A build that passes -P ?run-its to both versions, for example a CI matrix running Maven 3 and 4 side by side, silently skips the profile on Maven 3 while still succeeding. #11098 reported the warning; its last comment describes this 3/4 mismatch.

Proposal for 3.10.x: accept ? after the existing +, - and ! prefixes in -P, in the same order as Maven 4, and activate or deactivate the plain id. A missing optional profile would still log the existing warning, since Maven 3 does not fail on missing profiles.

slachiewicz avatar Oct 13 '26 15:10 slachiewicz

I agree, this would be something like support for --raw-streams CLI option in Maven 3.9+, that is in fact no-op, but allows one to write command lines that would work as wanted across 3.9-4.1 line. This is a similar "no op" implementation, to just strip off leading ?, if present.

cstamas avatar Oct 14 '26 08:10 cstamas

Hi, this looks like a well-scoped CLI parity fix between Maven 3.10 and Maven 4 (-P ?id optional profiles). I checked Maven 4 ProfileActivation optional handling and the 3.10 -P parsing difference you describe.

Is this still available to work on for the maven-3.10.x branch? If yes, I plan to look at where + - ! prefixes are handled for -P and add ? in the same order as Maven 4, keeping the existing warning for missing profiles. Thanks!

Piyush00715 avatar Oct 15 '26 22:10 Piyush00715