From a7399a4d527736c33cdf2e416b5c095e6f1f125e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20Boutemy?= <hboutemy@apache.org>
Date: Tue, 3 Jan 2023 22:08:35 +0100
Subject: [PATCH] [MNG-7652] switch to Modello Velocity (#944)

---
 api/maven-api-model/pom.xml                   |  30 ++--
 api/maven-api-model/src/main/mdo/model.vm     |   4 +-
 api/maven-api-settings/pom.xml                |  30 ++--
 api/maven-api-settings/src/main/mdo/model.vm  |   4 +-
 api/maven-api-toolchain/pom.xml               |  30 ++--
 api/maven-api-toolchain/src/main/mdo/model.vm |   4 +-
 api/modello-plugin-velocity/pom.xml           |  92 ------------
 .../modello/plugin/velocity/Helper.java       | 130 -----------------
 .../plugin/velocity/ModelloVelocityMojo.java  |  80 -----------
 .../plugin/velocity/VelocityGenerator.java    | 136 ------------------
 .../resources/META-INF/plexus/components.xml  |  31 ----
 api/pom.xml                                   |  22 ++-
 maven-compat/pom.xml                          |  10 ++
 maven-compat/src/main/mdo/profiles.mdo        |   4 +-
 maven-embedder/pom.xml                        |  10 ++
 maven-model/pom.xml                           |  92 +++++-------
 maven-model/src/main/mdo/merger.vm            |   4 +-
 maven-model/src/main/mdo/model-v3.vm          |   4 +-
 maven-model/src/main/mdo/reader-ex.vm         |   4 +-
 maven-model/src/main/mdo/reader.vm            |   4 +-
 maven-model/src/main/mdo/transformer.vm       |   4 +-
 maven-model/src/main/mdo/writer-ex.vm         |   4 +-
 maven-model/src/main/mdo/writer.vm            |   4 +-
 maven-model/src/site/apt/index.apt            |   2 +-
 maven-plugin-api/pom.xml                      |  38 ++---
 maven-plugin-api/src/main/mdo/merger.vm       |   4 +-
 maven-plugin-api/src/main/mdo/model.vm        |   4 +-
 maven-plugin-api/src/main/mdo/reader.vm       |   4 +-
 maven-plugin-api/src/main/mdo/writer.vm       |   4 +-
 maven-repository-metadata/pom.xml             |  10 ++
 maven-repository-metadata/src/site/site.xml   |   2 +-
 maven-settings/pom.xml                        |  17 +--
 maven-settings/src/main/mdo/merger.vm         |   4 +-
 maven-settings/src/main/mdo/model-v3.vm       |   4 +-
 maven-settings/src/main/mdo/reader.vm         |   4 +-
 maven-settings/src/main/mdo/writer.vm         |   4 +-
 maven-settings/src/site/apt/index.apt         |   2 +-
 maven-toolchain-model/pom.xml                 |  17 +--
 maven-toolchain-model/src/main/mdo/merger.vm  |   4 +-
 .../src/main/mdo/model-v3.vm                  |   4 +-
 maven-toolchain-model/src/main/mdo/reader.vm  |   4 +-
 maven-toolchain-model/src/main/mdo/writer.vm  |   4 +-
 maven-toolchain-model/src/site/apt/index.apt  |  39 +++++
 pom.xml                                       |  14 +-
 44 files changed, 251 insertions(+), 675 deletions(-)
 delete mode 100644 api/modello-plugin-velocity/pom.xml
 delete mode 100644 api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/Helper.java
 delete mode 100644 api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/ModelloVelocityMojo.java
 delete mode 100644 api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/VelocityGenerator.java
 delete mode 100644 api/modello-plugin-velocity/src/main/resources/META-INF/plexus/components.xml
 create mode 100644 maven-toolchain-model/src/site/apt/index.apt

diff --git a/api/maven-api-model/pom.xml b/api/maven-api-model/pom.xml
index e141aac08b..87d80b4cb1 100644
--- a/api/maven-api-model/pom.xml
+++ b/api/maven-api-model/pom.xml
@@ -63,26 +63,26 @@ under the License.
         </executions>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
-        <configuration>
-          <version>4.2.0</version>
-          <models>
-            <model>src/main/mdo/maven.mdo</model>
-          </models>
-          <templates>
-            <template>src/main/mdo/model.vm</template>
-          </templates>
-          <params>
-            <param>packageModelV4=org.apache.maven.api.model</param>
-          </params>
-        </configuration>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
         <executions>
           <execution>
-            <id>modello</id>
+            <id>velocity</id>
             <goals>
               <goal>velocity</goal>
             </goals>
+            <configuration>
+              <version>4.2.0</version>
+              <models>
+                <model>src/main/mdo/maven.mdo</model>
+              </models>
+              <templates>
+                <template>src/main/mdo/model.vm</template>
+              </templates>
+              <params>
+                <param>packageModelV4=org.apache.maven.api.model</param>
+              </params>
+            </configuration>
           </execution>
         </executions>
       </plugin>
diff --git a/api/maven-api-model/src/main/mdo/model.vm b/api/maven-api-model/src/main/mdo/model.vm
index 027f41150a..664064531c 100644
--- a/api/maven-api-model/src/main/mdo/model.vm
+++ b/api/maven-api-model/src/main/mdo/model.vm
@@ -31,7 +31,7 @@
     #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -85,7 +85,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/api/maven-api-settings/pom.xml b/api/maven-api-settings/pom.xml
index 843274f0ed..ae75044a5d 100644
--- a/api/maven-api-settings/pom.xml
+++ b/api/maven-api-settings/pom.xml
@@ -63,26 +63,26 @@ under the License.
         </executions>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
-        <configuration>
-          <version>2.0.0</version>
-          <models>
-            <model>src/main/mdo/settings.mdo</model>
-          </models>
-          <templates>
-            <template>src/main/mdo/model.vm</template>
-          </templates>
-          <params>
-            <param>packageModelV4=org.apache.maven.api.settings</param>
-          </params>
-        </configuration>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
         <executions>
           <execution>
-            <id>modello</id>
+            <id>velocity</id>
             <goals>
               <goal>velocity</goal>
             </goals>
+            <configuration>
+              <version>2.0.0</version>
+              <models>
+                <model>src/main/mdo/settings.mdo</model>
+              </models>
+              <templates>
+                <template>src/main/mdo/model.vm</template>
+              </templates>
+              <params>
+                <param>packageModelV4=org.apache.maven.api.settings</param>
+              </params>
+            </configuration>
           </execution>
         </executions>
       </plugin>
diff --git a/api/maven-api-settings/src/main/mdo/model.vm b/api/maven-api-settings/src/main/mdo/model.vm
index 027f41150a..664064531c 100644
--- a/api/maven-api-settings/src/main/mdo/model.vm
+++ b/api/maven-api-settings/src/main/mdo/model.vm
@@ -31,7 +31,7 @@
     #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -85,7 +85,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/api/maven-api-toolchain/pom.xml b/api/maven-api-toolchain/pom.xml
index 20024cb8a4..ea734f5dc1 100644
--- a/api/maven-api-toolchain/pom.xml
+++ b/api/maven-api-toolchain/pom.xml
@@ -62,26 +62,26 @@ under the License.
         </executions>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
-        <configuration>
-          <version>1.1.0</version>
-          <models>
-            <model>src/main/mdo/toolchains.mdo</model>
-          </models>
-          <templates>
-            <template>src/main/mdo/model.vm</template>
-          </templates>
-          <params>
-            <param>packageModelV4=org.apache.maven.api.toolchain</param>
-          </params>
-        </configuration>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
         <executions>
           <execution>
-            <id>modello</id>
+            <id>velocity</id>
             <goals>
               <goal>velocity</goal>
             </goals>
+            <configuration>
+              <version>1.1.0</version>
+              <models>
+                <model>src/main/mdo/toolchains.mdo</model>
+              </models>
+              <templates>
+                <template>src/main/mdo/model.vm</template>
+              </templates>
+              <params>
+                <param>packageModelV4=org.apache.maven.api.toolchain</param>
+              </params>
+            </configuration>
           </execution>
         </executions>
       </plugin>
diff --git a/api/maven-api-toolchain/src/main/mdo/model.vm b/api/maven-api-toolchain/src/main/mdo/model.vm
index 027f41150a..664064531c 100644
--- a/api/maven-api-toolchain/src/main/mdo/model.vm
+++ b/api/maven-api-toolchain/src/main/mdo/model.vm
@@ -31,7 +31,7 @@
     #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -85,7 +85,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/api/modello-plugin-velocity/pom.xml b/api/modello-plugin-velocity/pom.xml
deleted file mode 100644
index d363ee1e4b..0000000000
--- a/api/modello-plugin-velocity/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements. See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership. The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License. You may obtain a copy of the License at
-
-  http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied. See the License for the
-  specific language governing permissions and limitations
-  under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.maven</groupId>
-    <artifactId>maven-api</artifactId>
-    <version>4.0.0-alpha-4-SNAPSHOT</version>
-  </parent>
-
-  <artifactId>modello-plugin-velocity</artifactId>
-  <packaging>maven-plugin</packaging>
-  <name>Modello Velocity Plugin</name>
-  <description>Modello Velocity Plugin generates custom templates.</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>3.4.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.plugin-tools</groupId>
-      <artifactId>maven-plugin-annotations</artifactId>
-      <version>3.6.4</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>3.8.6</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>*</groupId>
-          <artifactId>*</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
-      <version>3.8.6</version>
-      <scope>provided</scope>
-      <exclusions>
-        <exclusion>
-          <groupId>*</groupId>
-          <artifactId>*</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.modello</groupId>
-      <artifactId>modello-maven-plugin</artifactId>
-      <version>2.0.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.velocity</groupId>
-      <artifactId>velocity-engine-core</artifactId>
-      <version>2.3</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.modello</groupId>
-      <artifactId>modello-core</artifactId>
-      <version>2.0.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.modello</groupId>
-      <artifactId>modello-plugin-xml</artifactId>
-      <version>2.0.0</version>
-    </dependency>
-  </dependencies>
-
-</project>
diff --git a/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/Helper.java b/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/Helper.java
deleted file mode 100644
index 39e04e59b9..0000000000
--- a/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/Helper.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.codehaus.modello.plugin.velocity;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.codehaus.modello.ModelloRuntimeException;
-import org.codehaus.modello.model.ModelAssociation;
-import org.codehaus.modello.model.ModelClass;
-import org.codehaus.modello.model.ModelField;
-import org.codehaus.modello.model.Version;
-import org.codehaus.modello.plugin.AbstractModelloGenerator;
-import org.codehaus.modello.plugins.xml.metadata.XmlAssociationMetadata;
-import org.codehaus.modello.plugins.xml.metadata.XmlClassMetadata;
-import org.codehaus.modello.plugins.xml.metadata.XmlFieldMetadata;
-import org.codehaus.plexus.util.StringUtils;
-
-@SuppressWarnings("unused")
-public class Helper {
-    private final Version version;
-
-    public Helper(Version version) {
-        this.version = version;
-    }
-
-    public String capitalise(String str) {
-        return StringUtils.isEmpty(str) ? str : Character.toTitleCase(str.charAt(0)) + str.substring(1);
-    }
-
-    public String uncapitalise(String str) {
-        return StringUtils.isEmpty(str) ? str : Character.toLowerCase(str.charAt(0)) + str.substring(1);
-    }
-
-    public String singular(String str) {
-        return AbstractModelloGenerator.singular(str);
-    }
-
-    public List<ModelClass> ancestors(ModelClass clazz) {
-        List<ModelClass> ancestors = new ArrayList<>();
-        for (ModelClass cl = clazz;
-                cl != null;
-                cl = cl.getSuperClass() != null ? cl.getModel().getClass(cl.getSuperClass(), version) : null) {
-            ancestors.add(0, cl);
-        }
-        return ancestors;
-    }
-
-    public XmlClassMetadata xmlClassMetadata(ModelClass clazz) {
-        return (XmlClassMetadata) clazz.getMetadata(XmlClassMetadata.ID);
-    }
-
-    public XmlFieldMetadata xmlFieldMetadata(ModelField field) {
-        return (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID);
-    }
-
-    public XmlAssociationMetadata xmAssociationMetadata(ModelField field) {
-        return (XmlAssociationMetadata) ((ModelAssociation) field).getAssociationMetadata(XmlAssociationMetadata.ID);
-    }
-
-    public boolean isFlatItems(ModelField field) {
-        return field instanceof ModelAssociation && xmAssociationMetadata(field).isFlatItems();
-    }
-
-    public List<ModelField> xmlFields(ModelClass modelClass) {
-        List<ModelClass> classes = new ArrayList<>();
-        // get the full inheritance
-        while (modelClass != null) {
-            classes.add(modelClass);
-            String superClass = modelClass.getSuperClass();
-            if (superClass != null) {
-                // superClass can be located outside (not generated by modello)
-                modelClass = modelClass.getModel().getClass(superClass, version, true);
-            } else {
-                modelClass = null;
-            }
-        }
-        List<ModelField> fields = new ArrayList<>();
-        for (int i = classes.size() - 1; i >= 0; i--) {
-            modelClass = classes.get(i);
-            Iterator<ModelField> parentIter = fields.iterator();
-            fields = new ArrayList<>();
-            for (ModelField field : modelClass.getFields(version)) {
-                XmlFieldMetadata xmlFieldMetadata = (XmlFieldMetadata) field.getMetadata(XmlFieldMetadata.ID);
-                if (xmlFieldMetadata.isTransient()) {
-                    // just ignore xml.transient fields
-                    continue;
-                }
-                if (xmlFieldMetadata.getInsertParentFieldsUpTo() != null) {
-                    // insert fields from parent up to the specified field
-                    boolean found = false;
-                    while (!found && parentIter.hasNext()) {
-                        ModelField parentField = parentIter.next();
-                        fields.add(parentField);
-                        found = parentField.getName().equals(xmlFieldMetadata.getInsertParentFieldsUpTo());
-                    }
-                    if (!found) {
-                        // interParentFieldsUpTo not found
-                        throw new ModelloRuntimeException("parent field not found: class "
-                                + modelClass.getName() + " xml.insertParentFieldUpTo='"
-                                + xmlFieldMetadata.getInsertParentFieldsUpTo() + "'");
-                    }
-                }
-                fields.add(field);
-            }
-            // add every remaining fields from parent class
-            while (parentIter.hasNext()) {
-                fields.add(parentIter.next());
-            }
-        }
-        return fields;
-    }
-}
diff --git a/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/ModelloVelocityMojo.java b/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/ModelloVelocityMojo.java
deleted file mode 100644
index 2298252fe3..0000000000
--- a/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/ModelloVelocityMojo.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.codehaus.modello.plugin.velocity;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.stream.Collectors;
-
-import org.apache.maven.plugins.annotations.LifecyclePhase;
-import org.apache.maven.plugins.annotations.Mojo;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.codehaus.modello.maven.AbstractModelloGeneratorMojo;
-
-/**
- * Creates an XML schema from the model.
- *
- * @author <a href="mailto:brett@codehaus.org">Brett Porter</a>
- */
-@Mojo(name = "velocity", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
-public class ModelloVelocityMojo extends AbstractModelloGeneratorMojo {
-    /**
-     * The output directory of the generated XML Schema.
-     */
-    @Parameter(defaultValue = "${project.build.directory}/generated-sources/modello", required = true)
-    private File outputDirectory;
-
-    @Parameter
-    private List<String> templates;
-
-    @Parameter
-    private List<String> params;
-
-    protected String getGeneratorType() {
-        return "velocity";
-    }
-
-    protected void customizeParameters(Properties parameters) {
-        super.customizeParameters(parameters);
-        Map<String, String> params = this.params != null
-                ? this.params.stream()
-                        .collect(Collectors.toMap(
-                                s -> s.substring(0, s.indexOf('=')), s -> s.substring(s.indexOf('=') + 1)))
-                : Collections.emptyMap();
-        parameters.put("basedir", Objects.requireNonNull(getBasedir(), "basedir is null"));
-        parameters.put(VelocityGenerator.VELOCITY_TEMPLATES, String.join(",", templates));
-        parameters.put(VelocityGenerator.VELOCITY_PARAMETERS, params);
-    }
-
-    protected boolean producesCompilableResult() {
-        return true;
-    }
-
-    public File getOutputDirectory() {
-        return outputDirectory;
-    }
-
-    public void setOutputDirectory(File outputDirectory) {
-        this.outputDirectory = outputDirectory;
-    }
-}
diff --git a/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/VelocityGenerator.java b/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/VelocityGenerator.java
deleted file mode 100644
index 132a77a3ba..0000000000
--- a/api/modello-plugin-velocity/src/main/java/org/codehaus/modello/plugin/velocity/VelocityGenerator.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.codehaus.modello.plugin.velocity;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.runtime.RuntimeInstance;
-import org.codehaus.modello.ModelloException;
-import org.codehaus.modello.ModelloParameterConstants;
-import org.codehaus.modello.model.Model;
-import org.codehaus.modello.model.Version;
-import org.codehaus.modello.plugin.AbstractModelloGenerator;
-import org.codehaus.plexus.util.io.CachingWriter;
-
-public class VelocityGenerator extends AbstractModelloGenerator {
-    public static final String VELOCITY_TEMPLATES = "modello.velocity.template";
-
-    public static final String VELOCITY_PARAMETERS = "modello.velocity.parameters";
-
-    @Override
-    public void generate(Model model, Properties parameters) throws ModelloException {
-        try {
-            Map<String, String> params = (Map) Objects.requireNonNull(parameters.get(VELOCITY_PARAMETERS));
-            String templates = getParameter(parameters, VELOCITY_TEMPLATES);
-            String output = getParameter(parameters, ModelloParameterConstants.OUTPUT_DIRECTORY);
-
-            Properties props = new Properties();
-            props.put("resource.loader.file.path", getParameter(parameters, "basedir"));
-            RuntimeInstance velocity = new RuntimeInstance();
-            velocity.init(props);
-
-            VelocityContext context = new VelocityContext();
-            for (Map.Entry<Object, Object> prop : parameters.entrySet()) {
-                context.put(prop.getKey().toString(), prop.getValue());
-            }
-            for (Map.Entry<String, String> prop : params.entrySet()) {
-                context.put(prop.getKey(), prop.getValue());
-            }
-            Version version = new Version(getParameter(parameters, ModelloParameterConstants.VERSION));
-            context.put("version", version);
-            context.put("model", model);
-            context.put("Helper", new Helper(version));
-
-            for (String templatePath : templates.split(",")) {
-                Template template = velocity.getTemplate(templatePath);
-
-                try (Writer w = new RedirectingWriter(Paths.get(output))) {
-                    template.merge(context, w);
-                }
-            }
-        } catch (Exception e) {
-            throw new ModelloException("Unable to run velocity template", e);
-        }
-    }
-
-    static class RedirectingWriter extends Writer {
-        Path dir;
-        StringBuilder sb = new StringBuilder();
-        Writer current;
-
-        RedirectingWriter(Path dir) {
-            this.dir = dir;
-        }
-
-        @Override
-        public void write(char[] cbuf, int off, int len) throws IOException {
-            for (int i = 0; i < len; i++) {
-                if (cbuf[off + i] == '\n') {
-                    if (sb.length() > 0 && sb.charAt(sb.length() - 1) == '\r') {
-                        sb.setLength(sb.length() - 1);
-                    }
-                    writeLine(sb.toString());
-                    sb.setLength(0);
-                } else {
-                    sb.append(cbuf[off + i]);
-                }
-            }
-        }
-
-        protected void writeLine(String line) throws IOException {
-            if (line.startsWith("#MODELLO-VELOCITY#REDIRECT ")) {
-                String file = line.substring("#MODELLO-VELOCITY#REDIRECT ".length());
-                if (current != null) {
-                    current.close();
-                }
-                Path out = dir.resolve(file);
-                Files.createDirectories(out.getParent());
-                current = new CachingWriter(out, StandardCharsets.UTF_8);
-            } else if (current != null) {
-                current.write(line);
-                current.write("\n");
-            }
-        }
-
-        @Override
-        public void flush() throws IOException {
-            if (current != null) {
-                current.flush();
-            }
-        }
-
-        @Override
-        public void close() throws IOException {
-            if (current != null) {
-                current.close();
-                current = null;
-            }
-        }
-    }
-}
diff --git a/api/modello-plugin-velocity/src/main/resources/META-INF/plexus/components.xml b/api/modello-plugin-velocity/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index ed745b2fc4..0000000000
--- a/api/modello-plugin-velocity/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<component-set>
-  <components>
-    <component>
-      <role>org.codehaus.modello.plugin.ModelloGenerator</role>
-      <role-hint>velocity</role-hint>
-      <implementation>org.codehaus.modello.plugin.velocity.VelocityGenerator</implementation>
-      <instantiation-strategy>per-lookup</instantiation-strategy>
-    </component>
-  </components>
-</component-set>
diff --git a/api/pom.xml b/api/pom.xml
index d425fee166..e4076ff799 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -32,7 +32,6 @@
   <description>A new immutable API for Maven 4 to better manage what plugins and extensions can influence.</description>
 
   <modules>
-    <module>modello-plugin-velocity</module>
     <module>maven-api-meta</module>
     <module>maven-api-xml</module>
     <module>maven-api-model</module>
@@ -45,6 +44,27 @@
     <project.directory>api</project.directory>
   </properties>
 
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.codehaus.modello</groupId>
+          <artifactId>modello-maven-plugin</artifactId>
+          <executions>
+            <execution>
+              <id>modello-site-docs</id>
+              <goals>
+                <goal>xdoc</goal>
+                <goal>xsd</goal>
+              </goals>
+              <phase>none</phase>
+            </execution>
+          </executions>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
   <profiles>
     <profile>
       <id>reporting</id>
diff --git a/maven-compat/pom.xml b/maven-compat/pom.xml
index c983778c98..3e29cd07e4 100644
--- a/maven-compat/pom.xml
+++ b/maven-compat/pom.xml
@@ -144,6 +144,16 @@ under the License.
             <model>src/main/mdo/paramdoc.mdo</model>
           </models>
         </configuration>
+        <executions>
+          <execution>
+            <id>modello</id>
+            <goals>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xpp3-writer</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
   </build>
diff --git a/maven-compat/src/main/mdo/profiles.mdo b/maven-compat/src/main/mdo/profiles.mdo
index e3e102991f..2843e806e1 100644
--- a/maven-compat/src/main/mdo/profiles.mdo
+++ b/maven-compat/src/main/mdo/profiles.mdo
@@ -24,8 +24,8 @@ under the License.
   <id>profiles</id>
   <name>Profiles</name>
   <description><![CDATA[
-    Project-local overrides to the build process based on detected or user-provided environmental parameters.
-    This is the model specification for ${basedir}/profiles.xml.
+    <b>Deprecated in Maven 2</b> Project-local overrides to the build process based on detected or user-provided environmental parameters.
+    This is the model specification for <code>${basedir}/profiles.xml</code>.
   ]]></description>
   <defaults>
     <default>
diff --git a/maven-embedder/pom.xml b/maven-embedder/pom.xml
index a6aaee43ef..1a768672a7 100644
--- a/maven-embedder/pom.xml
+++ b/maven-embedder/pom.xml
@@ -186,6 +186,16 @@ under the License.
             <model>src/main/mdo/core-extensions.mdo</model>
           </models>
         </configuration>
+        <executions>
+          <execution>
+            <id>modello</id>
+            <goals>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xpp3-writer</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
   </build>
diff --git a/maven-model/pom.xml b/maven-model/pom.xml
index 7b7bf13791..8fbd8317be 100644
--- a/maven-model/pom.xml
+++ b/maven-model/pom.xml
@@ -49,10 +49,9 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
-        <version>3.2.0</version>
         <executions>
           <execution>
-            <id>copy-model</id>
+            <id>copy-maven.mdo</id>
             <goals>
               <goal>copy</goal>
             </goals>
@@ -72,59 +71,6 @@ under the License.
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
-        <executions>
-          <execution>
-            <id>velocity-v3</id>
-            <goals>
-              <goal>velocity</goal>
-            </goals>
-            <phase>generate-sources</phase>
-            <configuration>
-              <version>4.1.0</version>
-              <models>
-                <model>target/mdo/maven.mdo</model>
-              </models>
-              <templates>
-                <template>src/main/mdo/model-v3.vm</template>
-              </templates>
-              <params>
-                <param>packageModelV3=org.apache.maven.model</param>
-                <param>packageModelV4=org.apache.maven.api.model</param>
-                <param>packageToolV4=org.apache.maven.model.v4</param>
-              </params>
-            </configuration>
-          </execution>
-          <execution>
-            <id>velocity-v4</id>
-            <goals>
-              <goal>velocity</goal>
-            </goals>
-            <phase>generate-sources</phase>
-            <configuration>
-              <version>4.2.0</version>
-              <models>
-                <model>target/mdo/maven.mdo</model>
-              </models>
-              <templates>
-                <template>src/main/mdo/merger.vm</template>
-                <template>src/main/mdo/transformer.vm</template>
-                <template>src/main/mdo/reader.vm</template>
-                <template>src/main/mdo/reader-ex.vm</template>
-                <template>src/main/mdo/writer.vm</template>
-                <template>src/main/mdo/writer-ex.vm</template>
-              </templates>
-              <params>
-                <param>packageModelV3=org.apache.maven.model</param>
-                <param>packageModelV4=org.apache.maven.api.model</param>
-                <param>packageToolV4=org.apache.maven.model.v4</param>
-              </params>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
@@ -133,6 +79,11 @@ under the License.
           <models>
             <model>target/mdo/maven.mdo</model>
           </models>
+          <params>
+            <param>packageModelV3=org.apache.maven.model</param>
+            <param>packageModelV4=org.apache.maven.api.model</param>
+            <param>packageToolV4=org.apache.maven.model.v4</param>
+          </params>
         </configuration>
         <executions>
           <execution>
@@ -144,8 +95,35 @@ under the License.
             <phase>pre-site</phase>
           </execution>
           <execution>
-            <id>modello</id>
-            <phase>none</phase>
+            <id>model-v3</id>
+            <goals>
+              <goal>velocity</goal>
+            </goals>
+            <phase>generate-sources</phase>
+            <configuration>
+              <version>4.1.0</version>
+              <templates>
+                <template>src/main/mdo/model-v3.vm</template>
+              </templates>
+            </configuration>
+          </execution>
+          <execution>
+            <id>model-v4</id>
+            <goals>
+              <goal>velocity</goal>
+            </goals>
+            <phase>generate-sources</phase>
+            <configuration>
+              <version>4.2.0</version>
+              <templates>
+                <template>src/main/mdo/merger.vm</template>
+                <template>src/main/mdo/transformer.vm</template>
+                <template>src/main/mdo/reader.vm</template>
+                <template>src/main/mdo/reader-ex.vm</template>
+                <template>src/main/mdo/writer.vm</template>
+                <template>src/main/mdo/writer-ex.vm</template>
+              </templates>
+            </configuration>
           </execution>
         </executions>
       </plugin>
diff --git a/maven-model/src/main/mdo/merger.vm b/maven-model/src/main/mdo/merger.vm
index 29a1ab8189..2cf9da482e 100644
--- a/maven-model/src/main/mdo/merger.vm
+++ b/maven-model/src/main/mdo/merger.vm
@@ -23,9 +23,9 @@
 #
 #set ( $root = $model.getClass( $model.getRoot($version), $version ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/main/mdo/model-v3.vm b/maven-model/src/main/mdo/model-v3.vm
index 3090dd852f..c12c5f0e62 100644
--- a/maven-model/src/main/mdo/model-v3.vm
+++ b/maven-model/src/main/mdo/model-v3.vm
@@ -33,7 +33,7 @@
     #set ( $dummy = $allFields.addAll( $cl.allFields ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -83,7 +83,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/main/mdo/reader-ex.vm b/maven-model/src/main/mdo/reader-ex.vm
index b01e45ce98..f084b41471 100644
--- a/maven-model/src/main/mdo/reader-ex.vm
+++ b/maven-model/src/main/mdo/reader-ex.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/main/mdo/reader.vm b/maven-model/src/main/mdo/reader.vm
index 52c5e56679..8c47409d4c 100644
--- a/maven-model/src/main/mdo/reader.vm
+++ b/maven-model/src/main/mdo/reader.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/main/mdo/transformer.vm b/maven-model/src/main/mdo/transformer.vm
index 1cc6af745b..25a7fe5733 100644
--- a/maven-model/src/main/mdo/transformer.vm
+++ b/maven-model/src/main/mdo/transformer.vm
@@ -21,9 +21,9 @@
 #set ( $package = "${packageToolV4}" )
 #set ( $className = "${model.name}Transformer" )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/main/mdo/writer-ex.vm b/maven-model/src/main/mdo/writer-ex.vm
index 8aa197910c..7eb0e38fad 100644
--- a/maven-model/src/main/mdo/writer-ex.vm
+++ b/maven-model/src/main/mdo/writer-ex.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/main/mdo/writer.vm b/maven-model/src/main/mdo/writer.vm
index 885d1c0219..7b2c805d36 100644
--- a/maven-model/src/main/mdo/writer.vm
+++ b/maven-model/src/main/mdo/writer.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-model/src/site/apt/index.apt b/maven-model/src/site/apt/index.apt
index f4fa802366..680358f0e0 100644
--- a/maven-model/src/site/apt/index.apt
+++ b/maven-model/src/site/apt/index.apt
@@ -28,7 +28,7 @@
 Maven Model
 
  This is strictly the model for Maven POM (Project Object Model) in <<<org.apache.maven.model>>> package,
- delegating content to {{{../maven-api/maven-api-model/index.html}Maven 4 API immutable model}}. All the effective model
+ delegating content to {{{../api/maven-api-model/index.html}Maven 4 API immutable model}}. All the effective model
  building logic from multiple POMs and building context is done in {{{../maven-model-builder/}Maven Model Builder}}.
 
  The following are generated from this model:
diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml
index 3735068b86..1294bcb7c7 100644
--- a/maven-plugin-api/pom.xml
+++ b/maven-plugin-api/pom.xml
@@ -59,33 +59,12 @@ under the License.
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
-        <version>2.0.0</version>
         <configuration>
           <models>
             <model>src/main/mdo/lifecycle.mdo</model>
           </models>
           <version>1.0.0</version>
         </configuration>
-        <executions>
-          <execution>
-            <id>modello</id>
-            <phase>none</phase>
-          </execution>
-          <execution>
-            <id>modello-site-docs</id>
-            <phase>pre-site</phase>
-            <configuration>
-              <models>
-                <model>src/main/mdo/plugin.mdo</model>
-              </models>
-              <version>1.1.0</version>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
         <executions>
           <execution>
             <id>velocity</id>
@@ -94,10 +73,6 @@ under the License.
             </goals>
             <phase>generate-sources</phase>
             <configuration>
-              <version>1.0.0</version>
-              <models>
-                <model>src/main/mdo/lifecycle.mdo</model>
-              </models>
               <templates>
                 <template>src/main/mdo/model.vm</template>
                 <template>src/main/mdo/reader.vm</template>
@@ -110,6 +85,19 @@ under the License.
               </params>
             </configuration>
           </execution>
+          <execution>
+            <id>modello-site-docs2</id>
+            <goals>
+              <goal>xdoc</goal>
+            </goals>
+            <phase>pre-site</phase>
+            <configuration>
+              <models>
+                <model>src/main/mdo/plugin.mdo</model>
+              </models>
+              <version>1.1.0</version>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>
diff --git a/maven-plugin-api/src/main/mdo/merger.vm b/maven-plugin-api/src/main/mdo/merger.vm
index 614c0bcf68..98b04d4627 100644
--- a/maven-plugin-api/src/main/mdo/merger.vm
+++ b/maven-plugin-api/src/main/mdo/merger.vm
@@ -23,9 +23,9 @@
 #
 #set ( $root = $model.getClass( $model.getRoot($version), $version ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-plugin-api/src/main/mdo/model.vm b/maven-plugin-api/src/main/mdo/model.vm
index db968d14b0..61d77726b7 100644
--- a/maven-plugin-api/src/main/mdo/model.vm
+++ b/maven-plugin-api/src/main/mdo/model.vm
@@ -31,7 +31,7 @@
     #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -81,7 +81,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-plugin-api/src/main/mdo/reader.vm b/maven-plugin-api/src/main/mdo/reader.vm
index 3f1fc63e7c..54b3882bbf 100644
--- a/maven-plugin-api/src/main/mdo/reader.vm
+++ b/maven-plugin-api/src/main/mdo/reader.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-plugin-api/src/main/mdo/writer.vm b/maven-plugin-api/src/main/mdo/writer.vm
index 7e9adef610..7c2f46e364 100644
--- a/maven-plugin-api/src/main/mdo/writer.vm
+++ b/maven-plugin-api/src/main/mdo/writer.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-repository-metadata/pom.xml b/maven-repository-metadata/pom.xml
index 8ebec9710e..26d7749cb4 100644
--- a/maven-repository-metadata/pom.xml
+++ b/maven-repository-metadata/pom.xml
@@ -54,6 +54,16 @@ under the License.
             <model>src/main/mdo/metadata.mdo</model>
           </models>
         </configuration>
+        <executions>
+          <execution>
+            <id>modello</id>
+            <goals>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+              <goal>xpp3-writer</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
   </build>
diff --git a/maven-repository-metadata/src/site/site.xml b/maven-repository-metadata/src/site/site.xml
index be08a3317f..8ffe43d07c 100644
--- a/maven-repository-metadata/src/site/site.xml
+++ b/maven-repository-metadata/src/site/site.xml
@@ -28,7 +28,7 @@ under the License.
     <menu name="Overview">
       <item name="Introduction" href="index.html"/>
       <item name="Javadocs" href="apidocs/index.html"/>
-      <!--item name="Source Xref" href="xref/index.html"/-->
+      <item name="Source Xref" href="xref/index.html"/>
       <!--item name="FAQ" href="faq.html"/-->
     </menu>
 
diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml
index 8b77d69b7c..ee70516934 100644
--- a/maven-settings/pom.xml
+++ b/maven-settings/pom.xml
@@ -53,10 +53,9 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
-        <version>3.2.0</version>
         <executions>
           <execution>
-            <id>copy-model</id>
+            <id>copy-settings.mdo</id>
             <goals>
               <goal>copy</goal>
             </goals>
@@ -77,8 +76,14 @@ under the License.
         </executions>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
+        <configuration>
+          <version>2.0.0</version>
+          <models>
+            <model>target/mdo/settings.mdo</model>
+          </models>
+        </configuration>
         <executions>
           <execution>
             <id>velocity</id>
@@ -87,10 +92,6 @@ under the License.
             </goals>
             <phase>generate-sources</phase>
             <configuration>
-              <version>4.0.0</version>
-              <models>
-                <model>target/mdo/settings.mdo</model>
-              </models>
               <templates>
                 <template>src/main/mdo/model-v3.vm</template>
                 <template>src/main/mdo/merger.vm</template>
diff --git a/maven-settings/src/main/mdo/merger.vm b/maven-settings/src/main/mdo/merger.vm
index 70b1d4620b..57d4fab0c9 100644
--- a/maven-settings/src/main/mdo/merger.vm
+++ b/maven-settings/src/main/mdo/merger.vm
@@ -23,9 +23,9 @@
 #
 #set ( $root = $model.getClass( $model.getRoot($version), $version ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-settings/src/main/mdo/model-v3.vm b/maven-settings/src/main/mdo/model-v3.vm
index 0271ae33bc..9e06cff9ba 100644
--- a/maven-settings/src/main/mdo/model-v3.vm
+++ b/maven-settings/src/main/mdo/model-v3.vm
@@ -33,7 +33,7 @@
     #set ( $dummy = $allFields.addAll( $cl.allFields ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -82,7 +82,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-settings/src/main/mdo/reader.vm b/maven-settings/src/main/mdo/reader.vm
index 79d9248ef9..02e9199ba8 100644
--- a/maven-settings/src/main/mdo/reader.vm
+++ b/maven-settings/src/main/mdo/reader.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-settings/src/main/mdo/writer.vm b/maven-settings/src/main/mdo/writer.vm
index 885d1c0219..7b2c805d36 100644
--- a/maven-settings/src/main/mdo/writer.vm
+++ b/maven-settings/src/main/mdo/writer.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-settings/src/site/apt/index.apt b/maven-settings/src/site/apt/index.apt
index bcedeedd23..95193e910a 100644
--- a/maven-settings/src/site/apt/index.apt
+++ b/maven-settings/src/site/apt/index.apt
@@ -26,7 +26,7 @@
 Maven Settings Model
 
  This is the model for Maven settings in <<<org.apache.maven.settings>>> package,
- delegating content to {{{../maven-api/maven-api-settings/index.html}Maven 4 API immutable settings}}. All the effective model
+ delegating content to {{{../api/maven-api-settings/index.html}Maven 4 API immutable settings}}. All the effective model
  building logic from multiple settings files is done in {{{../maven-settings-builder/}Maven Settings Builder}}.
 
  The following are generated from this model:
diff --git a/maven-toolchain-model/pom.xml b/maven-toolchain-model/pom.xml
index 9a72225a17..01ecb03cb0 100644
--- a/maven-toolchain-model/pom.xml
+++ b/maven-toolchain-model/pom.xml
@@ -52,10 +52,9 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
-        <version>3.2.0</version>
         <executions>
           <execution>
-            <id>copy-model</id>
+            <id>copy-toolchains.mdo</id>
             <goals>
               <goal>copy</goal>
             </goals>
@@ -76,8 +75,14 @@ under the License.
         </executions>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven</groupId>
-        <artifactId>modello-plugin-velocity</artifactId>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
+        <configuration>
+          <version>1.1.0</version>
+          <models>
+            <model>target/mdo/toolchains.mdo</model>
+          </models>
+        </configuration>
         <executions>
           <execution>
             <id>velocity</id>
@@ -86,10 +91,6 @@ under the License.
             </goals>
             <phase>generate-sources</phase>
             <configuration>
-              <version>4.0.0</version>
-              <models>
-                <model>target/mdo/toolchains.mdo</model>
-              </models>
               <templates>
                 <template>src/main/mdo/model-v3.vm</template>
                 <template>src/main/mdo/merger.vm</template>
diff --git a/maven-toolchain-model/src/main/mdo/merger.vm b/maven-toolchain-model/src/main/mdo/merger.vm
index 70b1d4620b..57d4fab0c9 100644
--- a/maven-toolchain-model/src/main/mdo/merger.vm
+++ b/maven-toolchain-model/src/main/mdo/merger.vm
@@ -23,9 +23,9 @@
 #
 #set ( $root = $model.getClass( $model.getRoot($version), $version ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-toolchain-model/src/main/mdo/model-v3.vm b/maven-toolchain-model/src/main/mdo/model-v3.vm
index 0271ae33bc..9e06cff9ba 100644
--- a/maven-toolchain-model/src/main/mdo/model-v3.vm
+++ b/maven-toolchain-model/src/main/mdo/model-v3.vm
@@ -33,7 +33,7 @@
     #set ( $dummy = $allFields.addAll( $cl.allFields ) )
   #end
   #set ( $className = "${class.name}" )
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
   #if ( $class.name != "InputLocation" && $class.name != "InputSource" )
     #set ( $types = { } )
     #set ( $imports = $class.getClass().forName("java.util.TreeSet").newInstance() )
@@ -82,7 +82,7 @@
       #end
     #end
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-toolchain-model/src/main/mdo/reader.vm b/maven-toolchain-model/src/main/mdo/reader.vm
index 79d9248ef9..02e9199ba8 100644
--- a/maven-toolchain-model/src/main/mdo/reader.vm
+++ b/maven-toolchain-model/src/main/mdo/reader.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-toolchain-model/src/main/mdo/writer.vm b/maven-toolchain-model/src/main/mdo/writer.vm
index 885d1c0219..7b2c805d36 100644
--- a/maven-toolchain-model/src/main/mdo/writer.vm
+++ b/maven-toolchain-model/src/main/mdo/writer.vm
@@ -27,9 +27,9 @@
 #set ( $rootUcapName = $Helper.capitalise( $root.name ) )
 #set ( $rootLcapName = $Helper.uncapitalise( $root.name ) )
 #
-#MODELLO-VELOCITY#REDIRECT ${package.replace('.','/')}/${className}.java
+#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java
 // =================== DO NOT EDIT THIS FILE ====================
-//   Generated by Maven, any modifications will be overwritten.
+//   ${generatedBy}
 // ==============================================================
 package ${package};
 
diff --git a/maven-toolchain-model/src/site/apt/index.apt b/maven-toolchain-model/src/site/apt/index.apt
new file mode 100644
index 0000000000..81e22f7ce4
--- /dev/null
+++ b/maven-toolchain-model/src/site/apt/index.apt
@@ -0,0 +1,39 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements.  See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership.  The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License.  You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied.  See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+ -----
+ Introduction
+ -----
+ Hervé Boutemy
+ -----
+ 2006-11-04
+ -----
+
+Maven Toolchain Model
+
+ This is the model for Maven toolchain in <<<org.apache.maven.toolchain>>> package,
+ delegating content to {{{../api/maven-api-toolchain/index.html}Maven 4 API immutable toolchain}}. All the effective model
+ building logic from multiple toolchains files is done in {{{../maven-toolchain-builder/}Maven Toolchain Builder}}.
+
+ The following are generated from this model:
+
+   * {{{./apidocs/index.html}Java sources}} with Reader and Writers for the Xpp3 XML parser, <<<ToAPiV3()>>> and <<<ToApiV4()>>> transformers, and <<<v4>>> package
+     for Merger and v4 Reader and Writers for the Xpp3 XML parser,
+
+   * A {{{./toolchains.html}Descriptor Reference}}
+
+   * An {{{https://maven.apache.org/xsd/toolchains-1.1.0.xsd}XSD}}
diff --git a/pom.xml b/pom.xml
index 7a4ecbd650..36820f12e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -492,11 +492,6 @@ under the License.
   <build>
     <pluginManagement>
       <plugins>
-        <plugin>
-          <groupId>org.apache.maven</groupId>
-          <artifactId>modello-plugin-velocity</artifactId>
-          <version>${project.version}</version>
-        </plugin>
         <plugin>
           <groupId>org.codehaus.plexus</groupId>
           <artifactId>plexus-component-metadata</artifactId>
@@ -530,6 +525,7 @@ under the License.
         <plugin>
           <groupId>org.codehaus.modello</groupId>
           <artifactId>modello-maven-plugin</artifactId>
+          <version>2.1.0</version>
           <executions>
             <execution>
               <id>modello-site-docs</id>
@@ -539,14 +535,6 @@ under the License.
               </goals>
               <phase>pre-site</phase>
             </execution>
-            <execution>
-              <id>modello</id>
-              <goals>
-                <goal>java</goal>
-                <goal>xpp3-reader</goal>
-                <goal>xpp3-writer</goal>
-              </goals>
-            </execution>
           </executions>
         </plugin>
         <plugin>