[MNG-7652] switch to Modello Velocity (#944)

This commit is contained in:
Hervé Boutemy 2023-01-03 22:08:35 +01:00 committed by GitHub
parent a00a44f75b
commit a7399a4d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 251 additions and 675 deletions

View File

@ -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>

View File

@ -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};

View File

@ -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>

View File

@ -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};

View File

@ -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>

View File

@ -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};

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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:

View File

@ -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>

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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:

View File

@ -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>

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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};

View File

@ -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}}

14
pom.xml
View File

@ -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>