gnodet opened a new pull request, #13910:
URL: https://github.com/apache/maven/pull/13910

   ## What
   
   Folds all reactor-level build configuration into `settings.xml` itself, 
extending the model to v2.1.0. Instead of introducing a new file (see #13249), 
this approach lets every settings tier — project (`.mvn/settings.xml`), user 
(`~/.m2/settings.xml`), and installation — carry its own configuration, with 
the usual last-wins merge semantics.
   
   ### New settings sections (v2.1.0)
   
   | Section | Purpose | Tiers |
   |---|---|---|
   | `<options>` | Default CLI arguments (replaces `.mvn/maven.config`) | 
project only |
   | `<extensions>` | Core extensions (replaces `.mvn/extensions.xml`) | all |
   | `<aliases>` | Named command shortcuts | all |
   | `<phases>` | Custom lifecycle phase injections | project only |
   
   ---
   
   ## Examples
   
   ### CLI defaults — `<options>`
   
   Replace `.mvn/maven.config` with a schema-backed block:
   
   ```xml
   <settings xmlns="http://maven.apache.org/SETTINGS/2.1.0";>
   
     <!-- Inline, quote-aware: same tokenisation as a shell argument -->
     <options>-T4 --no-transfer-progress -Djava.version=21</options>
   
     <!-- OR structured: one <arg> per token — use when values contain spaces 
-->
     <options>
       <arg>-T4</arg>
       <arg>--no-transfer-progress</arg>
       <arg>-Dmy.message=hello world</arg>
     </options>
   
   </settings>
   ```
   
   Both inline text and structured `<arg>` children are supported inside 
`<options>`. The structured form preserves spaces inside tokens without 
quoting. The two forms are mutually exclusive.
   
   ---
   
   ### Core extensions — `<extensions>`
   
   Replace `.mvn/extensions.xml` with inline declarations:
   
   ```xml
   <settings xmlns="http://maven.apache.org/SETTINGS/2.1.0";>
   
     <extensions>
       <!-- Compact id form: groupId:artifactId:version -->
       <extension id="io.takari.maven:takari-smart-builder:0.6.1"/>
   
       <!-- Explicit attribute form, with optional classLoadingStrategy and 
configuration -->
       <extension groupId="com.example" artifactId="advanced-ext" version="2.0"
                  classLoadingStrategy="parent-first">
         <configuration>
           <myKey>myValue</myKey>
         </configuration>
       </extension>
     </extensions>
   
   </settings>
   ```
   
   When `<extensions>` is present in the project settings, `extensions.xml` is 
ignored (with a deprecation warning if both exist).
   
   ---
   
   ### Aliases — `<aliases>`
   
   Define short names that expand to a full argument list:
   
   ```xml
   <settings xmlns="http://maven.apache.org/SETTINGS/2.1.0";>
   
     <aliases>
       <!-- Inline form: whitespace-separated, shell quote-aware -->
       <alias name="ci">verify -Dmaven.test.skip=true</alias>
   
       <!-- Alias with a quoted value containing a space -->
       <alias name="msg">deploy -Dchangelist= -Dmessage="release build"</alias>
   
       <!-- Structured form: one <arg> per token — values may contain spaces -->
       <alias name="release">
         <arg>deploy</arg>
         <arg>-Prelease</arg>
         <arg>-Dchangelist=</arg>
       </alias>
     </aliases>
   
   </settings>
   ```
   
   Invoke them on the command line:
   
   ```
   mvn ci                    # expands to: mvn verify -Dmaven.test.skip=true
   mvn release               # expands to: mvn deploy -Prelease -Dchangelist=
   mvn --list-aliases        # prints all effective aliases and exits
   ```
   
   Aliases are merged across all tiers (last wins). Expansion is non-recursive.
   
   ---
   
   ### Custom lifecycle phases — `<phases>` _(project settings only)_
   
   Inject custom phases into Maven 4's hierarchical lifecycle DAG:
   
   ```xml
   <settings xmlns="http://maven.apache.org/SETTINGS/2.1.0";>
   
     <phases>
       <!-- Insert a custom phase precisely between unit-test and 
integration-test -->
       <phase name="pre-integration" parent="verify"
              after="unit-test" before="integration-test"/>
   
       <!-- Insert a mutation-testing phase after unit-test -->
       <phase name="mutation-test" parent="verify" after="unit-test"/>
     </phases>
   
   </settings>
   ```
   
   The `parent` attribute names the container phase in the lifecycle DAG; 
`after`/`before` anchor insertion among its children.
   
   ---
   
   ## Why
   
   Reactor-level config is currently scattered:
   
   | Concern | Today | This PR |
   |---|---|---|
   | Default CLI args | `.mvn/maven.config` (flat text, no structure) | 
`<options>` in settings |
   | Core extensions | `.mvn/extensions.xml` (separate file) | `<extensions>` 
in settings |
   | Command shortcuts | _(none — teams use Makefiles or shell aliases)_ | 
`<aliases>` in settings |
   | Custom lifecycle phases | _(requires a full extension)_ | `<phases>` in 
settings |
   
   Folding everything into settings means:
   - **Inheritance** — user and installation settings can contribute defaults
   - **Schema validation** — typos are caught at parse time, not silently 
ignored
   - **One file** — project `.mvn/settings.xml` is the single source of truth 
for reactor behaviour
   
   ---
   
   ## How
   
   ### Model: `settings.mdo` (maven-api-settings)
   
   Extended to v2.1.0 with new classes `SettingsExtension`, `Alias`, and 
`PhaseInjection`. All coordinate fields on `SettingsExtension` are XML 
attributes (compact syntax). The `<alias>` inline form uses 
`xml.content="true"` on the `content` field — the reader template now calls 
`parser.getElementText()` instead of parsing a child element, while the writer 
emits `serializer.writeCharacters()`. The `<options>` element uses 
`xml.format="mixed"` with `<arg>` children for structured form.
   
   ### CLI / invoker pipeline (maven-cli)
   
   `MavenParser` reads project `.mvn/settings.xml` early (before DI) and:
   1. Prepends `<options>` tokens to the CLI argument list
   2. Loads `<extensions>` as core extensions (falls back to `extensions.xml` 
when absent)
   3. Builds the alias map merged across all settings tiers
   
   `MavenInvoker.expandAliases()` performs alias expansion: each CLI argument 
is looked up in the merged alias map and replaced by its token list. 
`ArgumentTokenizer` handles shell-style quote parsing for the inline form.
   
   `--list-aliases` prints the effective alias table and exits.
   
   ### SPI: `LifecycleProcessor` (maven-api-spi)
   
   New `@Consumer` SPI interface:
   
   ```java
   Lifecycle process(Lifecycle lifecycle);
   ```
   
   Called for each lifecycle at session init; processors chain (output of one 
feeds the next). Implementations must be stateless.
   
   ### Phase injection: `SettingsLifecycleProcessor` + `PhaseEnrichedLifecycle`
   
   `SettingsLifecycleProcessor` reads `<phases>` from the invoker request and 
delegates to `PhaseEnrichedLifecycle`, which inserts phases into the lifecycle 
DAG. `DefaultLifecycles` and `BuildPlanExecutor` apply the processor chain at 
all lifecycle resolution sites.
   
   ### Backwards compatibility
   
   - No `<options>` → falls back to `.mvn/maven.config`
   - No `<extensions>` → falls back to `.mvn/extensions.xml`
   - Deprecation warning when legacy files coexist with the new sections
   - `DefaultSettingsValidator` warns and drops `<extensions>`/`<phases>` found 
in user or installation tiers
   
   ### Files changed
   
   | Area | Key files |
   |---|---|
   | Model | `settings.mdo` (v2.1.0): `SettingsExtension`, `Alias`, 
`PhaseInjection` |
   | Templates | `reader-stax.vm`, `writer-stax.vm`: `xml.content="true"` and 
`xml.format="mixed"` support |
   | SPI | `LifecycleProcessor.java` |
   | Parsing | `MavenParser` (early settings read, alias expansion, extension 
loading), `ArgumentTokenizer` |
   | Phase injection | `SettingsLifecycleProcessor`, `PhaseEnrichedLifecycle`, 
`DefaultLifecycles` |
   | Validation | `DefaultSettingsValidator` |
   | Tests | `ArgumentTokenizerTest`, `MavenInvokerAliasTest`, 
`MavenSettingsOptionsTest`, `SettingsLifecycleProcessorTest`, 
`PhaseEnrichedLifecycleTest` |
   
   ## Test plan
   
   - [x] Unit tests: `ArgumentTokenizerTest`, `MavenInvokerAliasTest` (9 
cases), `MavenSettingsOptionsTest`, `SettingsLifecycleProcessorTest`, 
`PhaseEnrichedLifecycleTest`
   - [x] Integration test
   - [ ] CI validation
   
   Supersedes: apache/maven#13249


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to