diff --git a/api/maven-api-model/pom.xml b/api/maven-api-model/pom.xml index 87d80b4cb1fa..042569852474 100644 --- a/api/maven-api-model/pom.xml +++ b/api/maven-api-model/pom.xml @@ -41,27 +41,6 @@ under the License. - - org.codehaus.mojo - build-helper-maven-plugin - 3.2.0 - - - attach-mdo - - attach-artifact - - - - - src/main/mdo/maven.mdo - mdo - - - - - - org.codehaus.modello modello-maven-plugin @@ -73,14 +52,16 @@ under the License. 4.2.0 + ${project.basedir}/../../src/mdo src/main/mdo/maven.mdo - + packageModelV4=org.apache.maven.api.model + isMavenModel=true diff --git a/api/maven-api-model/src/main/mdo/model.vm b/api/maven-api-model/src/main/mdo/model.vm deleted file mode 100644 index 664064531c64..000000000000 --- a/api/maven-api-model/src/main/mdo/model.vm +++ /dev/null @@ -1,558 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageModelV4}" ) -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#foreach ( $class in $model.allClasses ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #set ( $inheritedFields = [] ) - #foreach ( $cl in $ancestors ) - #if ( $cl != $class ) - #set ( $dummy = $inheritedFields.addAll( $cl.getFields($version) ) ) - #end - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - #set ( $className = "${class.name}" ) -#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() ) - #set ( $dummy = $imports.add( "java.io.Serializable" ) ) - #set ( $dummy = $imports.add( "java.util.Collections" ) ) - #set ( $dummy = $imports.add( "java.util.HashMap" ) ) - #set ( $dummy = $imports.add( "java.util.Map" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Experimental" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Generated" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Immutable" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Nonnull" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.NotThreadSafe" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.ThreadSafe" ) ) - #foreach ( $field in $allFields ) - #if ( $field.type == "java.util.List" ) - #set ( $dummy = $imports.add( "java.util.ArrayList" ) ) - #set ( $dummy = $imports.add( "java.util.Collection" ) ) - #set ( $dummy = $imports.add( "java.util.List" ) ) - #set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) ) - #elseif ( $field.type == "java.util.Properties" ) - #set ( $dummy = $imports.add( "java.util.Map" ) ) - #set ( $dummy = $types.put( $field, "Map" ) ) - #elseif ( $field.type == "DOM" ) - #set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) ) - #set ( $dummy = $types.put( $field, "XmlNode" ) ) - #else - #set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} ) - #set ( $idx = $fieldType.lastIndexOf('.') ) - #if ( $idx > 0 ) - #set ( $dummy = $imports.add( $fieldType ) ) - #set ( $dummy = $types.put( $fieldType, $fieldType.substring( $idx + 1 ) ) ) - #end - #end - #end - #set ( $eq = "" ) - #set ( $hc = "" ) - #foreach ( $field in $allFields ) - #if ( $field.identifier ) - #set ( $dummy = $imports.add( "java.util.Objects" ) ) - #set ( $dummy = $identifiers.add( $field ) ) - #if ( $eq == "" ) - #set ( $eq = "Objects.equals( this.${field.name}, that.${field.name} )" ) - #else - #set ( $eq = "$eq && Objects.equals( this.${field.name}, that.${field.name} )" ) - #end - #if ( $hc == "" ) - #set ( $hc = "${field.name}" ) - #else - #set ( $hc = "$hc, this.${field.name}" ) - #end - #end - #end -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - - #foreach ( $imp in $imports ) -import $imp; - #end - -/** - #foreach ( $line in ${class.description.trim().split("\n")} ) - * ${line.trim()} - #end - */ -@Experimental -@Generated @ThreadSafe @Immutable -public class ${class.name} - #if ( $class.superClass ) - extends ${class.superClass} - #end - #if ( $locationTracking ) - implements Serializable, InputLocationTracker - #else - implements Serializable - #end -{ - #if ( $class == $root ) - final String modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - /** - #foreach ( $line in ${field.description.trim().split("\n")} ) - * ${line.trim()} - #end - */ - final ${type} $field.name; - #end - #if ( $locationTracking ) - #if ( ! $class.superClass ) - /** Location of the xml element for this object. */ - final InputLocation location; - #end - #foreach ( $field in $class.getFields($version) ) - /** Location of the xml element for the field ${field.name}. */ - final InputLocation ${field.name}Location; - #end - #if ( ! $class.superClass ) - /** Other locations */ - final Map locations; - #end - #end - - /** - * Constructor for this class, package protected. - * @see Builder#build() - */ - ${class.name}( - #if ( $class == $root ) - String modelEncoding, - #end - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${allFields[${allFields.size()} - 1]}),#end" ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - $type $field.name${sep} - #end - #if ( $locationTracking ) - Map locations, - #set ( $sep = "#if(${allFields.size()}>0),#end" ) - InputLocation location${sep} - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${allFields[${allFields.size()} - 1]}),#end" ) - InputLocation ${field.name}Location${sep} - #end - #end - ) - { - #if ( $class.superClass ) - super( - #foreach ( $field in $inheritedFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${inheritedFields[${inheritedFields.size()} - 1]}),#end" ) - ${field.name}${sep} - #end - #if ( $locationTracking ) - locations, - #set ( $sep = "#if(${inheritedFields.size()}>0),#end" ) - location${sep} - #foreach ( $field in $inheritedFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${inheritedFields[${inheritedFields.size()} - 1]}),#end" ) - ${field.name}Location${sep} - #end - #end - ); - #end - #if ( $class == $root ) - this.modelEncoding = modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" || $field.type == "java.util.Map" ) - this.${field.name} = ImmutableCollections.copy( ${field.name} ); - #else - this.${field.name} = ${field.name}; - #end - #end - #if ( $locationTracking ) - #if ( ! $class.superClass ) - this.locations = ImmutableCollections.copy( locations ); - this.location = location; - #end - #foreach ( $field in $class.getFields($version) ) - this.${field.name}Location = ${field.name}Location; - #end - #end - } - - #if ( ! $eq.empty ) - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || !( o instanceof ${class.name} ) ) - { - return false; - } - ${class.name} that = ( ${class.name} ) o; - return ${eq}; - } - - @Override - public int hashCode() - { - return Objects.hash( ${hc} ); - } - - #end - #if ( $class == $root ) - public String getModelEncoding() - { - return modelEncoding; - } - - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type == "boolean" || $type == "Boolean" ) - #set ( $pfx = "is" ) - #else - #set ( $pfx = "get" ) - #end - /** - #set ( $desc = ${field.description.trim()} ) - #foreach ( $line in ${desc.split("\n")} ) - * ${line.trim()} - #end - * - * @return a {@code ${type}} - */ - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" ) - @Nonnull - #end - public ${type} ${pfx}${cap}() - { - return this.${field.name}; - } - - #end - #if ( $locationTracking ) - /** - * Gets the location of the specified field in the input source. - */ - public InputLocation getLocation( Object key ) - { - if ( key instanceof String ) - { - switch ( ( String ) key ) - { - #if ( ! $class.superClass ) - case "": - return location; - #end - #foreach ( $field in $class.getFields($version) ) - case "${field.name}": - return ${field.name}Location; - #end - } - } - #if ( $class.superClass ) - return super.getLocation( key ); - #else - return locations != null ? locations.get( key ) : null; - #end - } - - #end - /** - * Creates a new builder with this object as the basis. - * - * @return a {@code Builder} - */ - @Nonnull - public Builder with() - { - return newBuilder( this ); - } - #foreach ( $field in $allFields ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - /** - * Creates a new {@code ${class.name}} instance using the specified ${field.name}. - * - * @param ${field.name} the new {@code $type} to use - * @return a {@code ${class.name}} with the specified ${field.name} - */ - @Nonnull - public ${class.name} with${cap}( $type $field.name ) - { - return with().${field.name}( $field.name ).build(); - } - #end - - /** - * Creates a new {@code ${class.name}} instance. - * Equivalent to {@code newInstance( true )}. - * @see #newInstance(boolean) - * - * @return a new {@code ${class.name}} - */ - @Nonnull - public static ${class.name} newInstance() - { - return newInstance( true ); - } - - /** - * Creates a new {@code ${class.name}} instance using default values or not. - * Equivalent to {@code newBuilder( withDefaults ).build()}. - * - * @param withDefaults the boolean indicating whether default values should be used - * @return a new {@code ${class.name}} - */ - @Nonnull - public static ${class.name} newInstance( boolean withDefaults ) - { - return newBuilder( withDefaults ).build(); - } - - /** - * Creates a new {@code ${class.name}} builder instance. - * Equivalent to {@code newBuilder( true )}. - * @see #newBuilder(boolean) - * - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder() - { - return newBuilder( true ); - } - - /** - * Creates a new {@code ${class.name}} builder instance using default values or not. - * - * @param withDefaults the boolean indicating whether default values should be used - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder( boolean withDefaults ) - { - return new Builder( withDefaults ); - } - - /** - * Creates a new {@code ${class.name}} builder instance using the specified object as a basis. - * Equivalent to {@code newBuilder( from, false )}. - * - * @param from the {@code ${class.name}} instance to use as a basis - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder( ${class.name} from ) - { - return newBuilder( from, false ); - } - - /** - * Creates a new {@code ${class.name}} builder instance using the specified object as a basis. - * - * @param from the {@code ${class.name}} instance to use as a basis - * @param forceCopy the boolean indicating if a copy should be forced - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder( ${class.name} from, boolean forceCopy ) - { - return new Builder( from, forceCopy ); - } - - /** - * Builder class used to create ${class.name} instances. - * @see #with() - * @see #newBuilder() - */ - @NotThreadSafe - public static class Builder - #if ( $class.superClass ) - extends ${class.superClass}.Builder - #end - { - ${class.name} base; - #if ( $class == $root ) - String modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - #if ( $type == 'boolean' ) - Boolean ${field.name}; - #elseif ( $type == 'int' ) - Integer ${field.name}; - #else - ${type} ${field.name}; - #end - #end - #if ( ! $class.superClass && $locationTracking ) - Map locations; - #end - - Builder( boolean withDefaults ) - { - #if ( $class.superClass ) - super( withDefaults ); - #end - if ( withDefaults ) - { - #foreach ( $field in $class.getFields($version) ) - #if ( $field.defaultValue ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $field.type == "String" ) - this.${field.name} = "${field.defaultValue}"; - #elseif ( $field.type != "java.util.List" && $field.type != "java.util.Properties" ) - this.${field.name} = ${field.defaultValue}; - #end - #end - #end - } - } - - Builder( ${class.name} base, boolean forceCopy ) - { - #if ( $class.superClass ) - super( base, forceCopy ); - #end - if ( forceCopy ) - { - #foreach ( $field in $class.getFields($version) ) - this.${field.name} = base.${field.name}; - #end - } - else - { - this.base = base; - } - } - - #if ( $class == $root ) - @Nonnull - public Builder modelEncoding( String modelEncoding ) - { - this.modelEncoding = modelEncoding; - return this; - } - - #end - #foreach ( $field in $allFields ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - @Nonnull - public Builder ${field.name}( ${type} ${field.name} ) - { - this.${field.name} = ${field.name}; - return this; - } - - #end - - #if ( $locationTracking ) - @Nonnull - public Builder location( Object key, InputLocation location ) - { - if ( location != null ) - { - if ( this.locations == null ) - { - this.locations = new HashMap<>(); - } - this.locations.put( key, location ); - } - return this; - } - - #end - @Nonnull - public ${class.name} build() - { - if ( base != null - #foreach ( $field in $allFields ) - && ( ${field.name} == null || ${field.name} == base.${field.name} ) - #end - ) - { - return base; - } - #if ( $locationTracking ) - Map locations = null; - InputLocation location = null; - #foreach ( $field in $allFields ) - InputLocation ${field.name}Location = null; - #end - if ( this.locations != null ) - { - locations = this.locations; - location = locations.remove( "" ); - #foreach ( $field in $allFields ) - ${field.name}Location = locations.remove( "${field.name}" ); - #end - } - #end - return new ${class.name}( - #if ( $class == $root ) - modelEncoding != null ? modelEncoding : ( base != null ? base.modelEncoding : "UTF-8" ), - #end - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${allFields[${allFields.size()} - 1]}),#end" ) - #if ( $field.type == "boolean" || $field.type == "int" ) - ${field.name} != null ? ${field.name} : ( base != null ? base.${field.name} : ${field.defaultValue} )${sep} - #else - ${field.name} != null ? ${field.name} : ( base != null ? base.${field.name} : null )${sep} - #end - #end - #if ( $locationTracking ) - locations != null ? locations : ( base != null ? base.locations : null ), - #set ( $sep = "#if(${allFields.size()}>0),#end" ) - location != null ? location : ( base != null ? base.location : null )${sep} - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${allFields[${allFields.size()} - 1]}),#end" ) - ${field.name}Location != null ? ${field.name}Location : ( base != null ? base.${field.name}Location : null )${sep} - #end - #end - ); - } - } - - #foreach ( $cs in $class.getCodeSegments($version) ) -$cs.code - #end -} - #end -#end diff --git a/api/maven-api-settings/pom.xml b/api/maven-api-settings/pom.xml index ae75044a5dd1..279225a474de 100644 --- a/api/maven-api-settings/pom.xml +++ b/api/maven-api-settings/pom.xml @@ -41,27 +41,6 @@ under the License. - - org.codehaus.mojo - build-helper-maven-plugin - 3.2.0 - - - attach-mdo - - attach-artifact - - - - - src/main/mdo/settings.mdo - mdo - - - - - - org.codehaus.modello modello-maven-plugin @@ -73,11 +52,12 @@ under the License. 2.0.0 + ${project.basedir}/../../src/mdo src/main/mdo/settings.mdo - + packageModelV4=org.apache.maven.api.settings diff --git a/api/maven-api-settings/src/main/mdo/common.vm b/api/maven-api-settings/src/main/mdo/common.vm deleted file mode 100644 index aa3d17a0398e..000000000000 --- a/api/maven-api-settings/src/main/mdo/common.vm +++ /dev/null @@ -1,21 +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. -*# -## -## Nothing special to do here -## \ No newline at end of file diff --git a/api/maven-api-settings/src/main/mdo/model.vm b/api/maven-api-settings/src/main/mdo/model.vm deleted file mode 100644 index 664064531c64..000000000000 --- a/api/maven-api-settings/src/main/mdo/model.vm +++ /dev/null @@ -1,558 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageModelV4}" ) -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#foreach ( $class in $model.allClasses ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #set ( $inheritedFields = [] ) - #foreach ( $cl in $ancestors ) - #if ( $cl != $class ) - #set ( $dummy = $inheritedFields.addAll( $cl.getFields($version) ) ) - #end - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - #set ( $className = "${class.name}" ) -#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() ) - #set ( $dummy = $imports.add( "java.io.Serializable" ) ) - #set ( $dummy = $imports.add( "java.util.Collections" ) ) - #set ( $dummy = $imports.add( "java.util.HashMap" ) ) - #set ( $dummy = $imports.add( "java.util.Map" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Experimental" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Generated" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Immutable" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Nonnull" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.NotThreadSafe" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.ThreadSafe" ) ) - #foreach ( $field in $allFields ) - #if ( $field.type == "java.util.List" ) - #set ( $dummy = $imports.add( "java.util.ArrayList" ) ) - #set ( $dummy = $imports.add( "java.util.Collection" ) ) - #set ( $dummy = $imports.add( "java.util.List" ) ) - #set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) ) - #elseif ( $field.type == "java.util.Properties" ) - #set ( $dummy = $imports.add( "java.util.Map" ) ) - #set ( $dummy = $types.put( $field, "Map" ) ) - #elseif ( $field.type == "DOM" ) - #set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) ) - #set ( $dummy = $types.put( $field, "XmlNode" ) ) - #else - #set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} ) - #set ( $idx = $fieldType.lastIndexOf('.') ) - #if ( $idx > 0 ) - #set ( $dummy = $imports.add( $fieldType ) ) - #set ( $dummy = $types.put( $fieldType, $fieldType.substring( $idx + 1 ) ) ) - #end - #end - #end - #set ( $eq = "" ) - #set ( $hc = "" ) - #foreach ( $field in $allFields ) - #if ( $field.identifier ) - #set ( $dummy = $imports.add( "java.util.Objects" ) ) - #set ( $dummy = $identifiers.add( $field ) ) - #if ( $eq == "" ) - #set ( $eq = "Objects.equals( this.${field.name}, that.${field.name} )" ) - #else - #set ( $eq = "$eq && Objects.equals( this.${field.name}, that.${field.name} )" ) - #end - #if ( $hc == "" ) - #set ( $hc = "${field.name}" ) - #else - #set ( $hc = "$hc, this.${field.name}" ) - #end - #end - #end -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - - #foreach ( $imp in $imports ) -import $imp; - #end - -/** - #foreach ( $line in ${class.description.trim().split("\n")} ) - * ${line.trim()} - #end - */ -@Experimental -@Generated @ThreadSafe @Immutable -public class ${class.name} - #if ( $class.superClass ) - extends ${class.superClass} - #end - #if ( $locationTracking ) - implements Serializable, InputLocationTracker - #else - implements Serializable - #end -{ - #if ( $class == $root ) - final String modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - /** - #foreach ( $line in ${field.description.trim().split("\n")} ) - * ${line.trim()} - #end - */ - final ${type} $field.name; - #end - #if ( $locationTracking ) - #if ( ! $class.superClass ) - /** Location of the xml element for this object. */ - final InputLocation location; - #end - #foreach ( $field in $class.getFields($version) ) - /** Location of the xml element for the field ${field.name}. */ - final InputLocation ${field.name}Location; - #end - #if ( ! $class.superClass ) - /** Other locations */ - final Map locations; - #end - #end - - /** - * Constructor for this class, package protected. - * @see Builder#build() - */ - ${class.name}( - #if ( $class == $root ) - String modelEncoding, - #end - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${allFields[${allFields.size()} - 1]}),#end" ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - $type $field.name${sep} - #end - #if ( $locationTracking ) - Map locations, - #set ( $sep = "#if(${allFields.size()}>0),#end" ) - InputLocation location${sep} - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${allFields[${allFields.size()} - 1]}),#end" ) - InputLocation ${field.name}Location${sep} - #end - #end - ) - { - #if ( $class.superClass ) - super( - #foreach ( $field in $inheritedFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${inheritedFields[${inheritedFields.size()} - 1]}),#end" ) - ${field.name}${sep} - #end - #if ( $locationTracking ) - locations, - #set ( $sep = "#if(${inheritedFields.size()}>0),#end" ) - location${sep} - #foreach ( $field in $inheritedFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${inheritedFields[${inheritedFields.size()} - 1]}),#end" ) - ${field.name}Location${sep} - #end - #end - ); - #end - #if ( $class == $root ) - this.modelEncoding = modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" || $field.type == "java.util.Map" ) - this.${field.name} = ImmutableCollections.copy( ${field.name} ); - #else - this.${field.name} = ${field.name}; - #end - #end - #if ( $locationTracking ) - #if ( ! $class.superClass ) - this.locations = ImmutableCollections.copy( locations ); - this.location = location; - #end - #foreach ( $field in $class.getFields($version) ) - this.${field.name}Location = ${field.name}Location; - #end - #end - } - - #if ( ! $eq.empty ) - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || !( o instanceof ${class.name} ) ) - { - return false; - } - ${class.name} that = ( ${class.name} ) o; - return ${eq}; - } - - @Override - public int hashCode() - { - return Objects.hash( ${hc} ); - } - - #end - #if ( $class == $root ) - public String getModelEncoding() - { - return modelEncoding; - } - - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type == "boolean" || $type == "Boolean" ) - #set ( $pfx = "is" ) - #else - #set ( $pfx = "get" ) - #end - /** - #set ( $desc = ${field.description.trim()} ) - #foreach ( $line in ${desc.split("\n")} ) - * ${line.trim()} - #end - * - * @return a {@code ${type}} - */ - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" ) - @Nonnull - #end - public ${type} ${pfx}${cap}() - { - return this.${field.name}; - } - - #end - #if ( $locationTracking ) - /** - * Gets the location of the specified field in the input source. - */ - public InputLocation getLocation( Object key ) - { - if ( key instanceof String ) - { - switch ( ( String ) key ) - { - #if ( ! $class.superClass ) - case "": - return location; - #end - #foreach ( $field in $class.getFields($version) ) - case "${field.name}": - return ${field.name}Location; - #end - } - } - #if ( $class.superClass ) - return super.getLocation( key ); - #else - return locations != null ? locations.get( key ) : null; - #end - } - - #end - /** - * Creates a new builder with this object as the basis. - * - * @return a {@code Builder} - */ - @Nonnull - public Builder with() - { - return newBuilder( this ); - } - #foreach ( $field in $allFields ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - /** - * Creates a new {@code ${class.name}} instance using the specified ${field.name}. - * - * @param ${field.name} the new {@code $type} to use - * @return a {@code ${class.name}} with the specified ${field.name} - */ - @Nonnull - public ${class.name} with${cap}( $type $field.name ) - { - return with().${field.name}( $field.name ).build(); - } - #end - - /** - * Creates a new {@code ${class.name}} instance. - * Equivalent to {@code newInstance( true )}. - * @see #newInstance(boolean) - * - * @return a new {@code ${class.name}} - */ - @Nonnull - public static ${class.name} newInstance() - { - return newInstance( true ); - } - - /** - * Creates a new {@code ${class.name}} instance using default values or not. - * Equivalent to {@code newBuilder( withDefaults ).build()}. - * - * @param withDefaults the boolean indicating whether default values should be used - * @return a new {@code ${class.name}} - */ - @Nonnull - public static ${class.name} newInstance( boolean withDefaults ) - { - return newBuilder( withDefaults ).build(); - } - - /** - * Creates a new {@code ${class.name}} builder instance. - * Equivalent to {@code newBuilder( true )}. - * @see #newBuilder(boolean) - * - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder() - { - return newBuilder( true ); - } - - /** - * Creates a new {@code ${class.name}} builder instance using default values or not. - * - * @param withDefaults the boolean indicating whether default values should be used - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder( boolean withDefaults ) - { - return new Builder( withDefaults ); - } - - /** - * Creates a new {@code ${class.name}} builder instance using the specified object as a basis. - * Equivalent to {@code newBuilder( from, false )}. - * - * @param from the {@code ${class.name}} instance to use as a basis - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder( ${class.name} from ) - { - return newBuilder( from, false ); - } - - /** - * Creates a new {@code ${class.name}} builder instance using the specified object as a basis. - * - * @param from the {@code ${class.name}} instance to use as a basis - * @param forceCopy the boolean indicating if a copy should be forced - * @return a new {@code Builder} - */ - @Nonnull - public static Builder newBuilder( ${class.name} from, boolean forceCopy ) - { - return new Builder( from, forceCopy ); - } - - /** - * Builder class used to create ${class.name} instances. - * @see #with() - * @see #newBuilder() - */ - @NotThreadSafe - public static class Builder - #if ( $class.superClass ) - extends ${class.superClass}.Builder - #end - { - ${class.name} base; - #if ( $class == $root ) - String modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - #if ( $type == 'boolean' ) - Boolean ${field.name}; - #elseif ( $type == 'int' ) - Integer ${field.name}; - #else - ${type} ${field.name}; - #end - #end - #if ( ! $class.superClass && $locationTracking ) - Map locations; - #end - - Builder( boolean withDefaults ) - { - #if ( $class.superClass ) - super( withDefaults ); - #end - if ( withDefaults ) - { - #foreach ( $field in $class.getFields($version) ) - #if ( $field.defaultValue ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $field.type == "String" ) - this.${field.name} = "${field.defaultValue}"; - #elseif ( $field.type != "java.util.List" && $field.type != "java.util.Properties" ) - this.${field.name} = ${field.defaultValue}; - #end - #end - #end - } - } - - Builder( ${class.name} base, boolean forceCopy ) - { - #if ( $class.superClass ) - super( base, forceCopy ); - #end - if ( forceCopy ) - { - #foreach ( $field in $class.getFields($version) ) - this.${field.name} = base.${field.name}; - #end - } - else - { - this.base = base; - } - } - - #if ( $class == $root ) - @Nonnull - public Builder modelEncoding( String modelEncoding ) - { - this.modelEncoding = modelEncoding; - return this; - } - - #end - #foreach ( $field in $allFields ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - @Nonnull - public Builder ${field.name}( ${type} ${field.name} ) - { - this.${field.name} = ${field.name}; - return this; - } - - #end - - #if ( $locationTracking ) - @Nonnull - public Builder location( Object key, InputLocation location ) - { - if ( location != null ) - { - if ( this.locations == null ) - { - this.locations = new HashMap<>(); - } - this.locations.put( key, location ); - } - return this; - } - - #end - @Nonnull - public ${class.name} build() - { - if ( base != null - #foreach ( $field in $allFields ) - && ( ${field.name} == null || ${field.name} == base.${field.name} ) - #end - ) - { - return base; - } - #if ( $locationTracking ) - Map locations = null; - InputLocation location = null; - #foreach ( $field in $allFields ) - InputLocation ${field.name}Location = null; - #end - if ( this.locations != null ) - { - locations = this.locations; - location = locations.remove( "" ); - #foreach ( $field in $allFields ) - ${field.name}Location = locations.remove( "${field.name}" ); - #end - } - #end - return new ${class.name}( - #if ( $class == $root ) - modelEncoding != null ? modelEncoding : ( base != null ? base.modelEncoding : "UTF-8" ), - #end - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${allFields[${allFields.size()} - 1]}),#end" ) - #if ( $field.type == "boolean" || $field.type == "int" ) - ${field.name} != null ? ${field.name} : ( base != null ? base.${field.name} : ${field.defaultValue} )${sep} - #else - ${field.name} != null ? ${field.name} : ( base != null ? base.${field.name} : null )${sep} - #end - #end - #if ( $locationTracking ) - locations != null ? locations : ( base != null ? base.locations : null ), - #set ( $sep = "#if(${allFields.size()}>0),#end" ) - location != null ? location : ( base != null ? base.location : null )${sep} - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${allFields[${allFields.size()} - 1]}),#end" ) - ${field.name}Location != null ? ${field.name}Location : ( base != null ? base.${field.name}Location : null )${sep} - #end - #end - ); - } - } - - #foreach ( $cs in $class.getCodeSegments($version) ) -$cs.code - #end -} - #end -#end diff --git a/api/maven-api-toolchain/pom.xml b/api/maven-api-toolchain/pom.xml index ea734f5dc1ca..f3e74c32e648 100644 --- a/api/maven-api-toolchain/pom.xml +++ b/api/maven-api-toolchain/pom.xml @@ -40,27 +40,6 @@ under the License. - - org.codehaus.mojo - build-helper-maven-plugin - 3.2.0 - - - attach-mdo - - attach-artifact - - - - - src/main/mdo/toolchains.mdo - mdo - - - - - - org.codehaus.modello modello-maven-plugin @@ -72,11 +51,12 @@ under the License. 1.1.0 + ${project.basedir}/../../src/mdo src/main/mdo/toolchains.mdo - + packageModelV4=org.apache.maven.api.toolchain diff --git a/api/maven-api-toolchain/src/main/mdo/common.vm b/api/maven-api-toolchain/src/main/mdo/common.vm deleted file mode 100644 index aa3d17a0398e..000000000000 --- a/api/maven-api-toolchain/src/main/mdo/common.vm +++ /dev/null @@ -1,21 +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. -*# -## -## Nothing special to do here -## \ No newline at end of file diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 8fbd8317be57..56f03db5f109 100644 --- a/maven-model/pom.xml +++ b/maven-model/pom.xml @@ -46,43 +46,21 @@ under the License. - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-maven.mdo - - copy - - generate-sources - - - - org.apache.maven - maven-api-model - ${project.version} - mdo - target/mdo/ - maven.mdo - - - - - - org.codehaus.modello modello-maven-plugin + ${project.basedir}/../api/maven-api-model + ${project.basedir}/../src/mdo 4.0.0 - target/mdo/maven.mdo + src/main/mdo/maven.mdo packageModelV3=org.apache.maven.model packageModelV4=org.apache.maven.api.model packageToolV4=org.apache.maven.model.v4 + isMavenModel=true @@ -103,7 +81,7 @@ under the License. 4.1.0 - + @@ -116,12 +94,12 @@ under the License. 4.2.0 - - - - - - + + + + + + diff --git a/maven-model/src/main/mdo/common.vm b/maven-model/src/main/mdo/common.vm deleted file mode 100644 index 3c3f29cf7a27..000000000000 --- a/maven-model/src/main/mdo/common.vm +++ /dev/null @@ -1,31 +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. -*# -# -## -## The following loop code is required in order to change the type of the -## pomFile attribute to a java.nio.file.Path. Modello does not support this -## type and loading a model with such a type would fail the modello validation. -## -#foreach ( $field in $model.getClass("Model", $version).allFields ) - #if ( $field.name == "pomFile" ) - #set ( $dummy = $field.setType("java.nio.file.Path") ) - #end -#end -#set ( $locationTracking = true ) -# \ No newline at end of file diff --git a/maven-model/src/main/mdo/merger.vm b/maven-model/src/main/mdo/merger.vm deleted file mode 100644 index 2cf9da482e94..000000000000 --- a/maven-model/src/main/mdo/merger.vm +++ /dev/null @@ -1,380 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Merger" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.ObjectStreamException; -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Objects; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.api.xml.XmlNode; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.Name}; -#end - -@Generated -public class ${className} -{ - - /** - * Merges the specified source object into the given target object. - * - * @param target The target object whose existing contents should be merged with the source, must not be - * null. - * @param source The (read-only) source object that should be merged into the target object, may be - * null. - * @param sourceDominant A flag indicating whether either the target object or the source object provides the - * dominant data. - * @param hints A set of key-value pairs that customized merger implementations can use to carry domain-specific - * information along, may be null. - */ - public ${root.name} merge( ${root.name} target, ${root.name} source, boolean sourceDominant, Map hints ) - { - Objects.requireNonNull( target, "target cannot be null" ); - if ( source == null ) - { - return target; - } - Map context = new HashMap<>(); - if ( hints != null ) - { - context.putAll( hints ); - } - return merge${root.name}( target, source, sourceDominant, context ); - } - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #foreach ( $cl in $ancestors ) - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - protected ${class.name} merge${class.name}( ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - ${class.name}.Builder builder = ${class.name}.newBuilder( target ); - merge${class.name}( builder, target, source, sourceDominant, context ); - return builder.build(); - } - - protected void merge${class.name}( ${class.name}.Builder builder, ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - #if ( $class.superClass ) - merge${class.superClass}( builder, target ,source, sourceDominant, context ); - #end - #foreach ( $field in $class.getFields($version) ) - merge${field.modelClass.name}_${Helper.capitalise($field.name)}( builder, target, source, sourceDominant, context ); - #end - } - - #foreach ( $field in $allFields ) - #set ( $capField = ${Helper.capitalise($field.name)} ) - protected void merge${class.name}_${capField}( ${class.name}.Builder builder, ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - #if ( $field.type == "String" ) - String src = source.get${capField}(); - String tgt = target.get${capField}(); - if ( src != null && ( sourceDominant || tgt == null ) ) - { - builder.${field.name}( src ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, e -> e ) ); - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - Map src = source.get${capField}(); - if ( !src.isEmpty() ) - { - Map tgt = target.get${capField}(); - if ( tgt.isEmpty() ) - { - builder.${field.name}( src ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - else - { - Map merged = new HashMap<>(); - merged.putAll( sourceDominant ? target.get${capField}() : source.get${capField}() ); - merged.putAll( sourceDominant ? source.get${capField}() : target.get${capField}() ); - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", InputLocation.merge( target.getLocation( "${field.name}" ), source.getLocation( "${field.name}" ), sourceDominant ) ); - #end - } - } - #elseif ( $field.to && $field.multiplicity == "1" ) - ${field.to} src = source.get${capField}(); - if ( src != null ) - { - ${field.to} tgt = target.get${capField}(); - if ( tgt == null ) - { - tgt = ${field.to}.newInstance( false ); - } - ${field.to} merged = merge${field.to}( tgt, src, sourceDominant, context ); - if ( merged == src ) - { - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - else if ( merged != tgt ) - { - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", InputLocation.merge( target.getLocation( "${field.name}" ), source.getLocation( "${field.name}" ), sourceDominant ) ); - #end - } - } - #elseif ( $field.to && $field.multiplicity == "*" ) - builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) ); - #elseif ( $field.type == "DOM" ) - XmlNode src = source.getConfiguration(); - if ( src != null ) - { - XmlNode tgt = target.getConfiguration(); - if ( tgt == null ) - { - builder.configuration( src ); - } - else if ( sourceDominant ) - { - builder.configuration( src.merge( tgt ) ); - } - else - { - builder.configuration( tgt.merge( src ) ); - } - } - #elseif ( $field.type == "boolean" ) - if ( sourceDominant ) - { - builder.${field.name}( source.is${capField}() ); - } - #elseif ( $field.type == "int" || $field.type == "java.nio.file.Path" ) - if ( sourceDominant ) - { - builder.${field.name}( source.get${capField}() ); - } - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - } - #end - - #end -#end - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - protected KeyComputer<${class.name}> get${class.name}Key() - { - return v -> v; - } - #end -#end - - /** - * Use to compute keys for data structures - * @param the data structure type - */ - @FunctionalInterface - public interface KeyComputer extends Function - { - } - - /** - * Merge two lists - */ - public static List merge( List tgt, List src, boolean sourceDominant, KeyComputer computer ) - { - return merge( tgt, src, computer, ( t, s ) -> sourceDominant ? s : t ); - } - - public static List merge( List tgt, List src, KeyComputer computer, BinaryOperator remapping ) - { - if ( src.isEmpty() ) - { - return tgt; - } - - MergingList list; - if ( tgt instanceof MergingList ) - { - list = (MergingList) tgt; - } - else - { - list = new MergingList<>( computer, src.size() + tgt.size() ); - list.mergeAll( tgt, ( t, s ) -> s ); - } - - list.mergeAll( src, remapping ); - return list; - } - - /** - * Merging list - * @param - */ - private static class MergingList extends AbstractList implements java.io.Serializable - { - - private final KeyComputer keyComputer; - private Map map; - private List list; - - MergingList( KeyComputer keyComputer, int initialCapacity ) - { - this.map = new LinkedHashMap<>( initialCapacity ); - this.keyComputer = keyComputer; - } - - Object writeReplace() throws ObjectStreamException - { - return new ArrayList<>( this ); - } - - @Override - public Iterator iterator() - { - if ( map != null ) - { - return map.values().iterator(); - } - else - { - return list.iterator(); - } - } - - void mergeAll( Collection vs, BinaryOperator remapping ) - { - if ( map == null ) - { - map = list.stream().collect( Collectors.toMap( keyComputer, - Function.identity(), - null, - LinkedHashMap::new ) ); - - list = null; - } - - if ( vs instanceof MergingList && ( (MergingList) vs ).map != null ) - { - for ( Map.Entry e : ( (MergingList) vs ).map.entrySet() ) - { - Object key = e.getKey(); - V v = e.getValue(); - map.merge( key, v, remapping ); - } - } - else - { - for ( V v : vs ) - { - Object key = keyComputer.apply( v ); - - map.merge( key, v, remapping ); - } - } - } - - @Override - public boolean contains( Object o ) - { - if ( map != null ) - { - return map.containsValue( o ); - } - else - { - return list.contains( o ); - } - } - - private List asList() - { - if ( list == null ) - { - list = new ArrayList<>( map.values() ); - map = null; - } - return list; - } - - @Override - public void add( int index, V element ) - { - asList().add( index, element ); - } - - @Override - public V remove( int index ) - { - return asList().remove( index ); - } - - @Override - public V get( int index ) - { - return asList().get( index ); - } - - @Override - public int size() - { - if ( map != null ) - { - return map.size(); - } - else - { - return list.size(); - } - } - } -} diff --git a/maven-model/src/main/mdo/writer.vm b/maven-model/src/main/mdo/writer.vm deleted file mode 100644 index 7b2c805d3607..000000000000 --- a/maven-model/src/main/mdo/writer.vm +++ /dev/null @@ -1,331 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Xpp3Writer" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#set ( $rootXml = $Helper.xmlClassMetadata( $root ) ) -#set ( $rootTag = $rootXml.tagName ) -#set ( $rootUcapName = $Helper.capitalise( $root.name ) ) -#set ( $rootLcapName = $Helper.uncapitalise( $root.name ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.Set; -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.api.xml.XmlNode; -import org.apache.maven.internal.xml.XmlNodeBuilder; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.name}; -#end -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; -import org.codehaus.plexus.util.xml.pull.MXParser; -import org.codehaus.plexus.util.xml.pull.MXSerializer; -import org.codehaus.plexus.util.xml.pull.XmlPullParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.codehaus.plexus.util.xml.pull.XmlSerializer; - -@Generated -public class ${className} -{ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field NAMESPACE. - */ - private static final String NAMESPACE = null; - - /** - * Field fileComment. - */ - private String fileComment = null; - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method setFileComment. - * - * @param fileComment a fileComment object. - */ - public void setFileComment( String fileComment ) - { - this.fileComment = fileComment; - } //-- void setFileComment( String ) - - /** - * Method write. - * - * @param writer a writer object - * @param ${rootLcapName} a ${root.name} object - * @throws java.io.IOException java.io.IOException if any - */ - public void write( Writer writer, ${root.name} ${rootLcapName} ) - throws java.io.IOException - { - XmlSerializer serializer = new MXSerializer(); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); - serializer.setOutput( writer ); - serializer.startDocument( ${rootLcapName}.getModelEncoding(), null ); - write${root.name}( "$rootTag", ${rootLcapName}, serializer ); - serializer.endDocument(); - } //-- void write( Writer, ${root.name} ) - - /** - * Method write. - * - * @param stream a stream object - * @param ${rootLcapName} a ${root.name} object - * @throws java.io.IOException java.io.IOException if any - */ - public void write( OutputStream stream, ${root.name} ${rootLcapName} ) - throws java.io.IOException - { - XmlSerializer serializer = new MXSerializer(); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); - serializer.setOutput( stream, ${rootLcapName}.getModelEncoding() ); - serializer.startDocument( ${rootLcapName}.getModelEncoding(), null ); - write${root.name}( "$rootTag", ${rootLcapName}, serializer ); - serializer.endDocument(); - } //-- void write( OutputStream, ${root.name} ) - - /** - * Method writeDomToSerializer. - * - * @param dom a dom object. - * @param serializer a serializer object. - * @throws java.io.IOException java.io.IOException if any. - */ - protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer ) - throws java.io.IOException - { - serializer.startTag( NAMESPACE, dom.getName() ); - - for ( Map.Entry attribute : dom.getAttributes().entrySet() ) - { - serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() ); - } - for ( XmlNode aChild : dom.getChildren() ) - { - writeDomToSerializer( aChild, serializer ); - } - - String value = dom.getValue(); - if ( value != null ) - { - serializer.text( value ); - } - - serializer.endTag( NAMESPACE, dom.getName() ); - - } //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer ) - - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $classUcapName = $Helper.capitalise( $class.name ) ) - #set ( $classLcapName = $Helper.uncapitalise( $class.name ) ) - #set ( $allFields = $Helper.xmlFields( $class ) ) - private void write${classUcapName}( String tagName, ${classUcapName} ${classLcapName}, XmlSerializer serializer ) - throws IOException - { - if ( ${classLcapName} != null ) - { - #if ( $class == $root ) - if ( this.fileComment != null ) - { - serializer.comment(this.fileComment); - } - serializer.setPrefix( "", "http://maven.apache.org/POM/4.0.0" ); - serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - serializer.startTag( NAMESPACE, tagName ); - serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" ); - #else - serializer.startTag( NAMESPACE, tagName ); - #end - #foreach ( $field in $allFields ) - #if ( $Helper.xmlFieldMetadata( $field ).attribute ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - #if ( $field.type == "String" ) - writeAttr( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - #end - #end - #foreach ( $field in $allFields ) - #if ( ! $Helper.xmlFieldMetadata( $field ).attribute && ! $Helper.xmlFieldMetadata( $field ).transient ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - #set ( $def = ${field.defaultValue} ) - #if ( $field.type == "String" ) - #if ( ! $def ) - writeTag( "$fieldTagName", null, ${classLcapName}.get${fieldCapName}(), serializer ); - #else - writeTag( "$fieldTagName", "${def}", ${classLcapName}.get${fieldCapName}(), serializer ); - #end - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - #if ( ${def} == "true" ) - writeTag( "$fieldTagName", "${def}", ${classLcapName}.is${fieldCapName}() ? null : "false", serializer ); - #else - writeTag( "$fieldTagName", "${def}", ${classLcapName}.is${fieldCapName}() ? "true" : null, serializer ); - #end - #elseif ( $field.type == "int" ) - writeTag( "$fieldTagName", "${def}", Integer.toString( ${classLcapName}.get${fieldCapName}() ), serializer ); - #elseif ( $field.type == "DOM" ) - writeDom( ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - #set( $singularField = ${Helper.singular($fieldTagName)} ) - writeList( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer, t -> writeTag( "$singularField", "${def}", t, serializer ) ); - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - writeProperties( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.to && $field.multiplicity == "1" ) - write${field.to}( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.to && $field.multiplicity == "*" ) - #set( $singularField = ${Helper.singular($fieldTagName)} ) - writeList( "$fieldTagName", $Helper.isFlatItems($field), ${classLcapName}.get${fieldCapName}(), serializer, t -> write${field.to}( "$singularField", t, serializer ) ); - #else - // TODO: name=${field.name} type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - #end - #end - serializer.endTag( NAMESPACE, tagName ); - } - } - - #end -#end - @FunctionalInterface - private interface ElementWriter - { - public void write( T t ) throws IOException; - } - - private void writeList( String tagName, List list, XmlSerializer serializer, ElementWriter writer ) - throws IOException - { - writeList( tagName, false, list, serializer, writer ); - } - - private void writeList( String tagName, boolean flat, List list, XmlSerializer serializer, ElementWriter writer ) - throws IOException - { - if ( list != null && !list.isEmpty() ) - { - if ( !flat ) - { - serializer.startTag( NAMESPACE, tagName ); - } - for ( T t : list ) - { - writer.write( t ); - } - if ( !flat ) - { - serializer.endTag( NAMESPACE, tagName ); - } - } - } - - private void writeProperties( String tagName, Map props, XmlSerializer serializer ) - throws IOException - { - if ( props != null && !props.isEmpty() ) - { - serializer.startTag( NAMESPACE, tagName ); - for ( Map.Entry entry : props.entrySet() ) - { - writeTag( entry.getKey(), null, entry.getValue(), serializer ); - } - serializer.endTag( NAMESPACE, tagName ); - } - } - - private void writeDom( XmlNode dom, XmlSerializer serializer ) - throws IOException - { - if ( dom != null ) - { - serializer.startTag( NAMESPACE, dom.getName() ); - for ( Map.Entry attr : dom.getAttributes().entrySet() ) - { - serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() ); - } - for ( XmlNode child : dom.getChildren() ) - { - writeDom( child, serializer ); - } - String value = dom.getValue(); - if ( value != null ) - { - serializer.text( value ); - } - serializer.endTag( NAMESPACE, dom.getName() ); - } - } - - private void writeTag( String tagName, String defaultValue, String value, XmlSerializer serializer ) - throws IOException - { - if ( value != null && !Objects.equals( defaultValue, value ) ) - { - serializer.startTag( NAMESPACE, tagName ).text( value ).endTag( NAMESPACE, tagName ); - } - } - - private void writeAttr( String attrName, String value, XmlSerializer serializer ) - throws IOException - { - if ( value != null ) - { - serializer.attribute( NAMESPACE, attrName, value ); - } - } - -} diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml index 1294bcb7c7e1..420df66d1ea8 100644 --- a/maven-plugin-api/pom.xml +++ b/maven-plugin-api/pom.xml @@ -60,6 +60,7 @@ under the License. org.codehaus.modello modello-maven-plugin + ${project.basedir}/../src/mdo src/main/mdo/lifecycle.mdo @@ -74,9 +75,9 @@ under the License. generate-sources - - - + + + packageModelV3=org.apache.maven.plugin.lifecycle diff --git a/maven-plugin-api/src/main/mdo/common.vm b/maven-plugin-api/src/main/mdo/common.vm deleted file mode 100644 index aa3d17a0398e..000000000000 --- a/maven-plugin-api/src/main/mdo/common.vm +++ /dev/null @@ -1,21 +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. -*# -## -## Nothing special to do here -## \ No newline at end of file diff --git a/maven-plugin-api/src/main/mdo/merger.vm b/maven-plugin-api/src/main/mdo/merger.vm deleted file mode 100644 index 98b04d4627b7..000000000000 --- a/maven-plugin-api/src/main/mdo/merger.vm +++ /dev/null @@ -1,380 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Merger" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.ObjectStreamException; -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Objects; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.api.xml.XmlNode; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.Name}; -#end - -@Generated -public class ${className} -{ - - /** - * Merges the specified source object into the given target object. - * - * @param target The target object whose existing contents should be merged with the source, must not be - * null. - * @param source The (read-only) source object that should be merged into the target object, may be - * null. - * @param sourceDominant A flag indicating whether either the target object or the source object provides the - * dominant data. - * @param hints A set of key-value pairs that customized merger implementations can use to carry domain-specific - * information along, may be null. - */ - public ${root.name} merge( ${root.name} target, ${root.name} source, boolean sourceDominant, Map hints ) - { - Objects.requireNonNull( target, "target cannot be null" ); - if ( source == null ) - { - return target; - } - Map context = new HashMap<>(); - if ( hints != null ) - { - context.putAll( hints ); - } - return merge${root.name}( target, source, sourceDominant, context ); - } - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #foreach ( $cl in $ancestors ) - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - protected ${class.name} merge${class.name}( ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - ${class.name}.Builder builder = ${class.name}.newBuilder( target ); - merge${class.name}( builder, target, source, sourceDominant, context ); - return builder.build(); - } - - protected void merge${class.name}( ${class.name}.Builder builder, ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - #if ( $class.superClass ) - merge${class.superClass}( builder, target ,source, sourceDominant, context ); - #end - #foreach ( $field in $class.getFields($version) ) - merge${field.modelClass.name}_${Helper.capitalise($field.name)}( builder, target, source, sourceDominant, context ); - #end - } - - #foreach ( $field in $allFields ) - #set ( $capField = ${Helper.capitalise($field.name)} ) - protected void merge${class.name}_${capField}( ${class.name}.Builder builder, ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - #if ( $field.type == "String" ) - String src = source.get${capField}(); - String tgt = target.get${capField}(); - if ( src != null && ( sourceDominant || tgt == null ) ) - { - builder.${field.name}( src ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, e -> e ) ); - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - Properties src = source.get${capField}(); - if ( !src.isEmpty() ) - { - Properties tgt = target.get${capField}(); - if ( tgt.isEmpty() ) - { - builder.${field.name}( src ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - else - { - Properties merged = new Properties(); - merged.putAll( sourceDominant ? target.get${capField}() : source.get${capField}() ); - merged.putAll( sourceDominant ? source.get${capField}() : target.get${capField}() ); - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", InputLocation.merge( target.getLocation( "${field.name}" ), source.getLocation( "${field.name}" ), sourceDominant ) ); - #end - } - } - #elseif ( $field.to && $field.multiplicity == "1" ) - ${field.to} src = source.get${capField}(); - if ( src != null ) - { - ${field.to} tgt = target.get${capField}(); - if ( tgt == null ) - { - tgt = ${field.to}.newInstance( false ); - } - ${field.to} merged = merge${field.to}( tgt, src, sourceDominant, context ); - if ( merged == src ) - { - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - else if ( merged != tgt ) - { - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", InputLocation.merge( target.getLocation( "${field.name}" ), source.getLocation( "${field.name}" ), sourceDominant ) ); - #end - } - } - #elseif ( $field.to && $field.multiplicity == "*" ) - builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) ); - #elseif ( $field.type == "DOM" ) - XmlNode src = source.getConfiguration(); - if ( src != null ) - { - XmlNode tgt = target.getConfiguration(); - if ( tgt == null ) - { - builder.configuration( src ); - } - else if ( sourceDominant ) - { - builder.configuration( src.merge( tgt ) ); - } - else - { - builder.configuration( tgt.merge( src ) ); - } - } - #elseif ( $field.type == "boolean" ) - if ( sourceDominant ) - { - builder.${field.name}( source.is${capField}() ); - } - #elseif ( $field.type == "int" || $field.type == "java.nio.file.Path" ) - if ( sourceDominant ) - { - builder.${field.name}( source.get${capField}() ); - } - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - } - #end - - #end -#end - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - protected KeyComputer<${class.name}> get${class.name}Key() - { - return v -> v; - } - #end -#end - - /** - * Use to compute keys for data structures - * @param the data structure type - */ - @FunctionalInterface - public interface KeyComputer extends Function - { - } - - /** - * Merge two lists - */ - public static List merge( List tgt, List src, boolean sourceDominant, KeyComputer computer ) - { - return merge( tgt, src, computer, ( t, s ) -> sourceDominant ? s : t ); - } - - public static List merge( List tgt, List src, KeyComputer computer, BinaryOperator remapping ) - { - if ( src.isEmpty() ) - { - return tgt; - } - - MergingList list; - if ( tgt instanceof MergingList ) - { - list = (MergingList) tgt; - } - else - { - list = new MergingList<>( computer, src.size() + tgt.size() ); - list.mergeAll( tgt, ( t, s ) -> s ); - } - - list.mergeAll( src, remapping ); - return list; - } - - /** - * Merging list - * @param - */ - private static class MergingList extends AbstractList implements java.io.Serializable - { - - private final KeyComputer keyComputer; - private Map map; - private List list; - - MergingList( KeyComputer keyComputer, int initialCapacity ) - { - this.map = new LinkedHashMap<>( initialCapacity ); - this.keyComputer = keyComputer; - } - - Object writeReplace() throws ObjectStreamException - { - return new ArrayList<>( this ); - } - - @Override - public Iterator iterator() - { - if ( map != null ) - { - return map.values().iterator(); - } - else - { - return list.iterator(); - } - } - - void mergeAll( Collection vs, BinaryOperator remapping ) - { - if ( map == null ) - { - map = list.stream().collect( Collectors.toMap( keyComputer, - Function.identity(), - null, - LinkedHashMap::new ) ); - - list = null; - } - - if ( vs instanceof MergingList && ( (MergingList) vs ).map != null ) - { - for ( Map.Entry e : ( (MergingList) vs ).map.entrySet() ) - { - Object key = e.getKey(); - V v = e.getValue(); - map.merge( key, v, remapping ); - } - } - else - { - for ( V v : vs ) - { - Object key = keyComputer.apply( v ); - - map.merge( key, v, remapping ); - } - } - } - - @Override - public boolean contains( Object o ) - { - if ( map != null ) - { - return map.containsValue( o ); - } - else - { - return list.contains( o ); - } - } - - private List asList() - { - if ( list == null ) - { - list = new ArrayList<>( map.values() ); - map = null; - } - return list; - } - - @Override - public void add( int index, V element ) - { - asList().add( index, element ); - } - - @Override - public V remove( int index ) - { - return asList().remove( index ); - } - - @Override - public V get( int index ) - { - return asList().get( index ); - } - - @Override - public int size() - { - if ( map != null ) - { - return map.size(); - } - else - { - return list.size(); - } - } - } -} diff --git a/maven-plugin-api/src/main/mdo/model.vm b/maven-plugin-api/src/main/mdo/model.vm deleted file mode 100644 index 61d77726b755..000000000000 --- a/maven-plugin-api/src/main/mdo/model.vm +++ /dev/null @@ -1,516 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageModelV4}" ) -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#foreach ( $class in $model.allClasses ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #set ( $inheritedFields = [] ) - #foreach ( $cl in $ancestors ) - #if ( $cl != $class ) - #set ( $dummy = $inheritedFields.addAll( $cl.getFields($version) ) ) - #end - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - #set ( $className = "${class.name}" ) -#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() ) - #set ( $dummy = $imports.add( "java.io.Serializable" ) ) - #set ( $dummy = $imports.add( "java.util.Collections" ) ) - #set ( $dummy = $imports.add( "java.util.HashMap" ) ) - #set ( $dummy = $imports.add( "java.util.Map" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Generated" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Immutable" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Nonnull" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.NotThreadSafe" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.ThreadSafe" ) ) - #foreach ( $field in $allFields ) - #if ( $field.type == "java.util.List" ) - #set ( $dummy = $imports.add( "java.util.ArrayList" ) ) - #set ( $dummy = $imports.add( "java.util.Collection" ) ) - #set ( $dummy = $imports.add( "java.util.List" ) ) - #set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) ) - #elseif ( $field.type == "DOM" ) - #set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) ) - #set ( $dummy = $types.put( $field, "XmlNode" ) ) - #else - #set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} ) - #set ( $idx = $fieldType.lastIndexOf('.') ) - #if ( $idx > 0 ) - #set ( $dummy = $imports.add( $fieldType ) ) - #set ( $dummy = $types.put( $fieldType, $fieldType.substring( $idx + 1 ) ) ) - #end - #end - #end - #set ( $eq = "" ) - #set ( $hc = "" ) - #foreach ( $field in $allFields ) - #if ( $field.identifier ) - #set ( $dummy = $imports.add( "java.util.Objects" ) ) - #set ( $dummy = $identifiers.add( $field ) ) - #if ( $eq == "" ) - #set ( $eq = "Objects.equals( this.${field.name}, that.${field.name} )" ) - #else - #set ( $eq = "$eq && Objects.equals( this.${field.name}, that.${field.name} )" ) - #end - #if ( $hc == "" ) - #set ( $hc = "${field.name}" ) - #else - #set ( $hc = "$hc, this.${field.name}" ) - #end - #end - #end -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - - #foreach ( $imp in $imports ) -import $imp; - #end - -/** - #foreach ( $line in ${class.description.trim().split("\n")} ) - * ${line.trim()} - #end - */ -@Generated @ThreadSafe @Immutable -public class ${class.name} - #if ( $class.superClass ) - extends ${class.superClass} - #end - #if ( $locationTracking ) - implements Serializable, InputLocationTracker - #else - implements Serializable - #end -{ - #if ( $class == $root ) - final String modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - /** - #foreach ( $line in ${field.description.trim().split("\n")} ) - * ${line.trim()} - #end - */ - final ${type} $field.name; - #end - #if ( $locationTracking ) - #if ( ! $class.superClass ) - /** Location of the xml element for this object. */ - final InputLocation location; - #end - #foreach ( $field in $class.getFields($version) ) - /** Location of the xml element for the field ${field.name}. */ - final InputLocation ${field.name}Location; - #end - #if ( ! $class.superClass ) - /** Other locations */ - final Map locations; - #end - #end - - /** - * Constructor for this class, package protected. - * @see Builder#build() - */ - ${class.name}( - #if ( $class == $root ) - String modelEncoding, - #end - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${allFields[${allFields.size()} - 1]}),#end" ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - $type $field.name${sep} - #end - #if ( $locationTracking ) - Map locations, - InputLocation location, - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${allFields[${allFields.size()} - 1]}),#end" ) - InputLocation ${field.name}Location${sep} - #end - #end - ) - { - #if ( $class.superClass ) - super( - #foreach ( $field in $inheritedFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${inheritedFields[${inheritedFields.size()} - 1]}),#end" ) - ${field.name}${sep} - #end - #if ( $locationTracking ) - locations, - location, - #foreach ( $field in $inheritedFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${inheritedFields[${inheritedFields.size()} - 1]}),#end" ) - ${field.name}Location${sep} - #end - #end - ); - #end - #if ( $class == $root ) - this.modelEncoding = modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" || $field.type == "java.util.Map" ) - this.${field.name} = ImmutableCollections.copy( ${field.name} ); - #else - this.${field.name} = ${field.name}; - #end - #end - #if ( $locationTracking ) - #if ( ! $class.superClass ) - this.locations = ImmutableCollections.copy( locations ); - this.location = location; - #end - #foreach ( $field in $class.getFields($version) ) - this.${field.name}Location = ${field.name}Location; - #end - #end - } - - #if ( ! $eq.empty ) - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || !( o instanceof ${class.name} ) ) - { - return false; - } - ${class.name} that = ( ${class.name} ) o; - return ${eq}; - } - - @Override - public int hashCode() - { - return Objects.hash( ${hc} ); - } - - #end - #if ( $class == $root ) - public String getModelEncoding() - { - return modelEncoding; - } - - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type == "boolean" || $type == "Boolean" ) - #set ( $pfx = "is" ) - #else - #set ( $pfx = "get" ) - #end - /** - #set ( $desc = ${field.description.trim()} ) - #foreach ( $line in ${desc.split("\n")} ) - * ${line.trim()} - #end - */ - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" ) - @Nonnull - #end - public ${type} ${pfx}${cap}() - { - return this.${field.name}; - } - - #end - #if ( $locationTracking ) - /** - * Gets the location of the specified field in the input source. - */ - public InputLocation getLocation( Object key ) - { - if ( key instanceof String ) - { - switch ( ( String ) key ) - { - #if ( ! $class.superClass ) - case "": - return location; - #end - #foreach ( $field in $class.getFields($version) ) - case "${field.name}": - return ${field.name}Location; - #end - } - } - #if ( $class.superClass ) - return super.getLocation( key ); - #else - return locations != null ? locations.get( key ) : null; - #end - } - - #end - /** - * Creates a new builder with this object as the basis. - */ - @Nonnull - public Builder with() - { - return newBuilder( this ); - } - #foreach ( $field in $allFields ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - /** Creates a new ${class.name} instance using the specified ${field.name}. */ - @Nonnull - public ${class.name} with${cap}( $type $field.name ) - { - return with().${field.name}( $field.name ).build(); - } - #end - - /** - * Creates a new ${class.name} instance. - * Equivalent to {@code newInstance( true )}. - * @see #newInstance(boolean) - */ - @Nonnull - public static ${class.name} newInstance() - { - return newInstance( true ); - } - - /** - * Creates a new ${class.name} instance using default values or not. - * Equivalent to {@code newBuilder( withDefaults ).build()}. - */ - @Nonnull - public static ${class.name} newInstance( boolean withDefaults ) - { - return newBuilder( withDefaults ).build(); - } - - /** - * Creates a new ${class.name} builder instance. - * Equivalent to {@code newBuilder( true )}. - * @see #newBuilder(boolean) - */ - @Nonnull - public static Builder newBuilder() - { - return newBuilder( true ); - } - - /** - * Creates a new ${class.name} builder instance using default values or not. - */ - @Nonnull - public static Builder newBuilder( boolean withDefaults ) - { - return new Builder( withDefaults ); - } - - /** - * Creates a new ${class.name} builder instance using the specified object as a basis. - * Equivalent to {@code newBuilder( from, false )}. - */ - @Nonnull - public static Builder newBuilder( ${class.name} from ) - { - return newBuilder( from, false ); - } - - /** - * Creates a new ${class.name} builder instance using the specified object as a basis. - */ - @Nonnull - public static Builder newBuilder( ${class.name} from, boolean forceCopy ) - { - return new Builder( from, forceCopy ); - } - - /** - * Builder class used to create ${class.name} instances. - * @see #with() - * @see #newBuilder() - */ - @NotThreadSafe - public static class Builder - #if ( $class.superClass ) - extends ${class.superClass}.Builder - #end - { - ${class.name} base; - #if ( $class == $root ) - String modelEncoding; - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - #if ( $type == 'boolean' ) - Boolean ${field.name}; - #elseif ( $type == 'int' ) - Integer ${field.name}; - #else - ${type} ${field.name}; - #end - #end - #if ( ! $class.superClass && $locationTracking ) - Map locations; - #end - - Builder( boolean withDefaults ) - { - #if ( $class.superClass ) - super( withDefaults ); - #end - if ( withDefaults ) - { - #foreach ( $field in $class.getFields($version) ) - #if ( $field.defaultValue ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $field.type == "String" ) - this.${field.name} = "${field.defaultValue}"; - #elseif ( $field.type != "java.util.List" && $field.type != "java.util.Properties" ) - this.${field.name} = ${field.defaultValue}; - #end - #end - #end - } - } - - Builder( ${class.name} base, boolean forceCopy ) - { - #if ( $class.superClass ) - super( base, forceCopy ); - #end - if ( forceCopy ) - { - #foreach ( $field in $class.getFields($version) ) - this.${field.name} = base.${field.name}; - #end - } - else - { - this.base = base; - } - } - - #if ( $class == $root ) - @Nonnull - public Builder modelEncoding( String modelEncoding ) - { - this.modelEncoding = modelEncoding; - return this; - } - - #end - #foreach ( $field in $allFields ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type.startsWith("List<") ) - #set ( $type = ${type.replace('List<','Collection<')} ) - #end - @Nonnull - public Builder ${field.name}( ${type} ${field.name} ) - { - this.${field.name} = ${field.name}; - return this; - } - - #end - - #if ( $locationTracking ) - @Nonnull - public Builder location( Object key, InputLocation location ) - { - if ( location != null ) - { - if ( this.locations == null ) - { - this.locations = new HashMap<>(); - } - this.locations.put( key, location ); - } - return this; - } - - #end - @Nonnull - public ${class.name} build() - { - if ( base != null - #foreach ( $field in $allFields ) - && ( ${field.name} == null || ${field.name} == base.${field.name} ) - #end - ) - { - return base; - } - #if ( $locationTracking ) - Map locations = new HashMap<>( this.locations != null ? this.locations : ( base != null ? base.locations : Collections.emptyMap() ) ); - InputLocation location = locations.remove( "" ); - #foreach ( $field in $allFields ) - InputLocation ${field.name}Location = locations.remove( "${field.name}" ); - #end - #end - return new ${class.name}( - #if ( $class == $root ) - modelEncoding != null ? modelEncoding : ( base != null ? base.modelEncoding : "UTF-8" ), - #end - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}||$field!=${allFields[${allFields.size()} - 1]}),#end" ) - #if ( $field.type == "boolean" || $field.type == "int" ) - ${field.name} != null ? ${field.name} : ( base != null ? base.${field.name} : ${field.defaultValue} )${sep} - #else - ${field.name} != null ? ${field.name} : ( base != null ? base.${field.name} : null )${sep} - #end - #end - #if ( $locationTracking ) - locations, - location != null ? location : ( base != null ? base.location : null ), - #foreach ( $field in $allFields ) - #set ( $sep = "#if(${locationTracking}&&$field!=${allFields[${allFields.size()} - 1]}),#end" ) - ${field.name}Location != null ? ${field.name}Location : ( base != null ? base.${field.name}Location : null )${sep} - #end - #end - ); - } - } - - #foreach ( $cs in $class.getCodeSegments($version) ) -$cs.code - #end -} - #end -#end diff --git a/maven-plugin-api/src/main/mdo/reader.vm b/maven-plugin-api/src/main/mdo/reader.vm deleted file mode 100644 index 54b3882bbf2e..000000000000 --- a/maven-plugin-api/src/main/mdo/reader.vm +++ /dev/null @@ -1,899 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Xpp3Reader" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#set ( $rootXml = $Helper.xmlClassMetadata( $root ) ) -#set ( $rootTag = $rootXml.tagName ) -#set ( $rootUcapName = $Helper.capitalise( $root.name ) ) -#set ( $rootLcapName = $Helper.uncapitalise( $root.name ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.internal.xml.XmlNodeBuilder; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.name}; -#end -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; -import org.codehaus.plexus.util.xml.pull.MXParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -@Generated -public class ${className} -{ - private boolean addDefaultEntities = true; - - private final ContentTransformer contentTransformer; - - public ${className}() - { - this( ( s, f ) -> s ); - } - - public ${className}( ContentTransformer contentTransformer ) - { - this.contentTransformer = contentTransformer; - } - - /** - * Method checkFieldWithDuplicate. - * - * @param parser a parser object. - * @param parsed a parsed object. - * @param alias a alias object. - * @param tagName a tagName object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return boolean - */ - private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, Set parsed ) - throws XmlPullParserException - { - if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) - { - return false; - } - if ( !parsed.add( tagName ) ) - { - throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); - } - return true; - } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, Set ) - - /** - * Method checkUnknownAttribute. - * - * @param parser a parser object. - * @param strict a strict object. - * @param tagName a tagName object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @throws IOException IOException if any. - */ - private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) - throws XmlPullParserException, IOException - { - // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too - if ( strict ) - { - throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); - } - } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) - - /** - * Method checkUnknownElement. - * - * @param parser a parser object. - * @param strict a strict object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @throws IOException IOException if any. - */ - private void checkUnknownElement( XmlPullParser parser, boolean strict ) - throws XmlPullParserException, IOException - { - if ( strict ) - { - throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); - } - - for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) - { - int eventType = parser.next(); - if ( eventType == XmlPullParser.START_TAG ) - { - unrecognizedTagCount++; - } - else if ( eventType == XmlPullParser.END_TAG ) - { - unrecognizedTagCount--; - } - } - } //-- void checkUnknownElement( XmlPullParser, boolean ) - - /** - * Returns the state of the "add default entities" flag. - * - * @return boolean - */ - public boolean getAddDefaultEntities() - { - return addDefaultEntities; - } //-- boolean getAddDefaultEntities() - - /** - * Method getBooleanValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return boolean - */ - private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) - throws XmlPullParserException - { - return getBooleanValue( s, attribute, parser, null ); - } //-- boolean getBooleanValue( String, String, XmlPullParser ) - - /** - * Method getBooleanValue. - * - * @param s a s object. - * @param defaultValue a defaultValue object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return boolean - */ - private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) - throws XmlPullParserException - { - if ( s != null && s.length() != 0 ) - { - return Boolean.valueOf( s ).booleanValue(); - } - if ( defaultValue != null ) - { - return Boolean.valueOf( defaultValue ).booleanValue(); - } - return false; - } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) - - /** - * Method getByteValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return byte - */ - private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Byte.valueOf( s ).byteValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); - } - } - } - return 0; - } //-- byte getByteValue( String, String, XmlPullParser, boolean ) - - /** - * Method getCharacterValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return char - */ - private char getCharacterValue( String s, String attribute, XmlPullParser parser ) - throws XmlPullParserException - { - if ( s != null ) - { - return s.charAt( 0 ); - } - return 0; - } //-- char getCharacterValue( String, String, XmlPullParser ) - - /** - * Method getDateValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return Date - */ - private Date getDateValue( String s, String attribute, XmlPullParser parser ) - throws XmlPullParserException - { - return getDateValue( s, attribute, null, parser ); - } //-- Date getDateValue( String, String, XmlPullParser ) - - /** - * Method getDateValue. - * - * @param s a s object. - * @param parser a parser object. - * @param dateFormat a dateFormat object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return Date - */ - private Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) - throws XmlPullParserException - { - if ( s != null ) - { - String effectiveDateFormat = dateFormat; - if ( dateFormat == null ) - { - effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; - } - if ( "long".equals( effectiveDateFormat ) ) - { - try - { - return new java.util.Date( Long.parseLong( s ) ); - } - catch ( NumberFormatException e ) - { - throw new XmlPullParserException( e.getMessage(), parser, e ); - } - } - else - { - try - { - DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US ); - return dateParser.parse( s ); - } - catch ( java.text.ParseException e ) - { - throw new XmlPullParserException( e.getMessage(), parser, e ); - } - } - } - return null; - } //-- Date getDateValue( String, String, String, XmlPullParser ) - - /** - * Method getDoubleValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return double - */ - private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Double.valueOf( s ).doubleValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); - } - } - } - return 0; - } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) - - /** - * Method getFloatValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return float - */ - private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Float.valueOf( s ).floatValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); - } - } - } - return 0; - } //-- float getFloatValue( String, String, XmlPullParser, boolean ) - - /** - * Method getIntegerValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return int - */ - private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - return getIntegerValue( s, attribute, parser, strict, 0 ); - } //-- int getBooleanValue( String, String, XmlPullParser ) - - /** - * Method getIntegerValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return int - */ - private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict, int defaultValue ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Integer.valueOf( s ).intValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); - } - } - } - return defaultValue; - } //-- int getIntegerValue( String, String, XmlPullParser, boolean, int ) - - /** - * Method getLongValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return long - */ - private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Long.valueOf( s ).longValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); - } - } - } - return 0; - } //-- long getLongValue( String, String, XmlPullParser, boolean ) - - /** - * Method getRequiredAttributeValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return String - */ - private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s == null ) - { - if ( strict ) - { - throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); - } - } - return s; - } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) - - /** - * Method getShortValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return short - */ - private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Short.valueOf( s ).shortValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); - } - } - } - return 0; - } //-- short getShortValue( String, String, XmlPullParser, boolean ) - - /** - * Method getTrimmedValue. - * - * @param s a s object. - * @return String - */ - private String getTrimmedValue( String s ) - { - if ( s != null ) - { - s = s.trim(); - } - return s; - } //-- String getTrimmedValue( String ) - - /** - * Method interpolatedTrimmed. - * - * @param value a value object. - * @param context a context object. - * @return String - */ - private String interpolatedTrimmed( String value, String context ) - { - return getTrimmedValue( contentTransformer.transform( value, context ) ); - } //-- String interpolatedTrimmed( String, String ) - - /** - * Method nextTag. - * - * @param parser a parser object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return int - */ - private int nextTag( XmlPullParser parser ) - throws IOException, XmlPullParserException - { - int eventType = parser.next(); - if ( eventType == XmlPullParser.TEXT ) - { - eventType = parser.next(); - } - if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) - { - throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); - } - return eventType; - } //-- int nextTag( XmlPullParser ) - - /** - * @see ReaderFactory#newXmlReader - * - * @param reader a reader object. - * @param strict a strict object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( Reader reader, boolean strict ) - throws IOException, XmlPullParserException - { - XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( ); - - parser.setInput( reader ); - - - return read( parser, strict ); - } //-- ${root.name} read( Reader, boolean ) - - /** - * @see ReaderFactory#newXmlReader - * - * @param reader a reader object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( Reader reader ) - throws IOException, XmlPullParserException - { - return read( reader, true ); - } //-- ${root.name} read( Reader ) - - /** - * Method read. - * - * @param in a in object. - * @param strict a strict object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( InputStream in, boolean strict ) - throws IOException, XmlPullParserException - { - return read( ReaderFactory.newXmlReader( in ), strict ); - } //-- ${root.name} read( InputStream, boolean ) - - /** - * Method read. - * - * @param in a in object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( InputStream in ) - throws IOException, XmlPullParserException - { - return read( ReaderFactory.newXmlReader( in ) ); - } //-- ${root.name} read( InputStream ) - - /** - * Method read. - * - * @param parser a parser object. - * @param strict a strict object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( XmlPullParser parser, boolean strict ) - throws IOException, XmlPullParserException - { - $rootUcapName $rootLcapName = null; - int eventType = parser.getEventType(); - boolean parsed = false; - while ( eventType != XmlPullParser.END_DOCUMENT ) - { - if ( eventType == XmlPullParser.START_TAG ) - { - if ( strict && ! "${rootTag}".equals( parser.getName() ) ) - { - throw new XmlPullParserException( "Expected root element '${rootTag}' but found '" + parser.getName() + "'", parser, null ); - } - else if ( parsed ) - { - // fallback, already expected a XmlPullParserException due to invalid XML - throw new XmlPullParserException( "Duplicated tag: '${rootTag}'", parser, null ); - } - $rootLcapName = parse${rootUcapName}( parser, strict ); - parsed = true; - } - eventType = parser.next(); - } - if ( parsed ) - { - return $rootLcapName; - } - throw new XmlPullParserException( "Expected root element '${rootTag}' but found no element at all: invalid XML document", parser, null ); - } //-- ${root.name} read( XmlPullParser, boolean ) - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $classUcapName = $Helper.capitalise( $class.name ) ) - #set ( $classLcapName = $Helper.uncapitalise( $class.name ) ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #foreach ( $cl in $ancestors ) - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - private ${classUcapName} parse${classUcapName}( XmlPullParser parser, boolean strict ) - throws IOException, XmlPullParserException - { - String tagName = parser.getName(); - ${classUcapName}.Builder ${classLcapName} = ${classUcapName}.newBuilder( true ); - for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) - { - String name = parser.getAttributeName( i ); - String value = parser.getAttributeValue( i ); - if ( name.indexOf( ':' ) >= 0 ) - { - // just ignore attributes with non-default namespace (for example: xmlns:xsi) - } - #if ( $class == $root ) - else if ( "xmlns".equals( name ) ) - { - // ignore xmlns attribute in root class, which is a reserved attribute name - } - #end - #foreach ( $field in $allFields ) - #if ( $Helper.xmlFieldMetadata( $field ).attribute ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - else if ( "$fieldTagName".equals( name ) ) - { - #if ( $field.type == "String" ) - ${classLcapName}.${field.name}( interpolatedTrimmed( value, "$fieldTagName" ) ); - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - ${classLcapName}.${field.name}( getBooleanValue( interpolatedTrimmed( value, "$fieldTagName" ), "$fieldTagName", parser, "${field.defaultValue}" ) ); - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - } - #end - #end - else - { - checkUnknownAttribute( parser, name, tagName, strict ); - } - } - Set parsed = new HashSet<>(); - #foreach ( $field in $allFields ) - #if ( $Helper.isFlatItems( $field ) ) - List<$field.to> ${field.name} = new ArrayList<>(); - #end - #end - while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) - { - String childName = checkDuplicate( parser.getName(), parser, parsed ); - switch ( childName ) - { - #set( $ift = "if" ) - #foreach ( $field in $allFields ) - #if ( ! $Helper.xmlFieldMetadata( $field ).attribute && ! $Helper.xmlFieldMetadata( $field ).transient ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #if ( $Helper.isFlatItems( $field ) ) - #set ( $fieldTagName = $Helper.singular( $fieldTagName ) ) - #end - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - case "${fieldTagName}": - { - #if ( $field.type == "String" ) - ${classLcapName}.${field.name}( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ) ); - break; - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - ${classLcapName}.${field.name}( getBooleanValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, "${field.defaultValue}" ) ); - break; - #elseif ( $field.type == "int" ) - ${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) ); - break; - #elseif ( $field.type == "DOM" ) - ${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) ); - break; - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - List ${field.name} = new ArrayList<>(); - while ( parser.nextTag() == XmlPullParser.START_TAG ) - { - if ( "${Helper.singular($fieldTagName)}".equals( parser.getName() ) ) - { - ${field.name}.add( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ) ); - } - else - { - checkUnknownElement( parser, strict ); - } - } - ${classLcapName}.${field.name}( ${field.name} ); - break; - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - Properties ${field.name} = new Properties(); - while ( parser.nextTag() == XmlPullParser.START_TAG ) - { - String key = parser.getName(); - String value = parser.nextText().trim(); - ${field.name}.put( key, value ); - } - ${classLcapName}.${field.name}( ${field.name} ); - break; - #elseif ( $field.to && $field.multiplicity == "1" ) - ${classLcapName}.${field.name}( parse${field.toClass.name}( parser, strict ) ); - break; - #elseif ( $field.to && $field.multiplicity == "*" && $Helper.isFlatItems( $field ) ) - ${field.name}.add( parse${field.toClass.name}( parser, strict ) ); - break; - #elseif ( $field.to && $field.multiplicity == "*" ) - List<$field.to> ${field.name} = new ArrayList<>(); - while ( parser.nextTag() == XmlPullParser.START_TAG ) - { - if ( "${Helper.singular($fieldTagName)}".equals( parser.getName() ) ) - { - ${field.name}.add( parse${field.toClass.name}( parser, strict ) ); - } - else - { - checkUnknownElement( parser, strict ); - } - } - ${classLcapName}.${field.name}( ${field.name} ); - break; - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - break; - #end - } - #set( $ift = "else if" ) - #end - #end - default: - { - checkUnknownElement( parser, strict ); - break; - } - } - } - #foreach ( $field in $allFields ) - #if ( $Helper.isFlatItems( $field ) ) - ${classLcapName}.${field.name}( ${field.name} ); - #end - #end - #if ( $class == $root ) - ${classLcapName}.modelEncoding( parser.getInputEncoding() ); - #end - return ${classLcapName}.build(); - } - - #end -#end - - private String checkDuplicate( String tagName, XmlPullParser parser, Set parsed ) - throws XmlPullParserException - { -#set( $aliases = { } ) -#set( $flats = { } ) -#foreach( $class in $model.allClasses ) - #foreach ( $field in $class.getFields($version) ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #if ( $field.alias ) - #set ( $dummy = $aliases.put( $field.alias, $fieldTagName ) ) - #end - #if ( $Helper.isFlatItems( $field ) ) - #set ( $fieldTagName = $Helper.singular($fieldTagName) ) - #set ( $dummy = $flats.put( $fieldTagName, "" ) ) - #end - #end -#end -#if ( ! ${aliases.isEmpty()} ) - switch ( tagName ) - { - #foreach( $entry in $aliases.entrySet() ) - case "${entry.key}": - tagName = "${entry.value}"; - #end - } -#end -#if ( ! ${flats.isEmpty()} ) - switch ( tagName ) - { - #foreach( $entry in $flats.entrySet() ) - case "${entry.key}": - #end - break; - default: - if ( !parsed.add( tagName ) ) - { - throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); - } - } -#end - return tagName; - } - - /** - * Sets the state of the "add default entities" flag. - * - * @param addDefaultEntities a addDefaultEntities object. - */ - public void setAddDefaultEntities( boolean addDefaultEntities ) - { - this.addDefaultEntities = addDefaultEntities; - } //-- void setAddDefaultEntities( boolean ) - - public static interface ContentTransformer - { - /** - * Interpolate the value read from the xpp3 document - * @param source The source value - * @param fieldName A description of the field being interpolated. The implementation may use this to - * log stuff. - * @return The interpolated value. - */ - String transform( String source, String fieldName ); - } - -} diff --git a/maven-plugin-api/src/main/mdo/writer.vm b/maven-plugin-api/src/main/mdo/writer.vm deleted file mode 100644 index 7c2f46e364a5..000000000000 --- a/maven-plugin-api/src/main/mdo/writer.vm +++ /dev/null @@ -1,331 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Xpp3Writer" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#set ( $rootXml = $Helper.xmlClassMetadata( $root ) ) -#set ( $rootTag = $rootXml.tagName ) -#set ( $rootUcapName = $Helper.capitalise( $root.name ) ) -#set ( $rootLcapName = $Helper.uncapitalise( $root.name ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.Set; -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.api.xml.XmlNode; -import org.apache.maven.internal.xml.XmlNodeBuilder; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.name}; -#end -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; -import org.codehaus.plexus.util.xml.pull.MXParser; -import org.codehaus.plexus.util.xml.pull.MXSerializer; -import org.codehaus.plexus.util.xml.pull.XmlPullParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.codehaus.plexus.util.xml.pull.XmlSerializer; - -@Generated -public class ${className} -{ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field NAMESPACE. - */ - private static final String NAMESPACE = null; - - /** - * Field fileComment. - */ - private String fileComment = null; - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method setFileComment. - * - * @param fileComment a fileComment object. - */ - public void setFileComment( String fileComment ) - { - this.fileComment = fileComment; - } //-- void setFileComment( String ) - - /** - * Method write. - * - * @param writer a writer object - * @param ${rootLcapName} a ${root.name} object - * @throws java.io.IOException java.io.IOException if any. - */ - public void write( Writer writer, ${root.name} ${rootLcapName} ) - throws java.io.IOException - { - XmlSerializer serializer = new MXSerializer(); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); - serializer.setOutput( writer ); - serializer.startDocument( ${rootLcapName}.getModelEncoding(), null ); - write${root.name}( "$rootTag", ${rootLcapName}, serializer ); - serializer.endDocument(); - } //-- void write( Writer, ${root.name} ) - - /** - * Method write. - * - * @param stream a stream object - * @param ${rootLcapName} a ${root.name} object - * @throws java.io.IOException java.io.IOException if any. - */ - public void write( OutputStream stream, ${root.name} ${rootLcapName} ) - throws java.io.IOException - { - XmlSerializer serializer = new MXSerializer(); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); - serializer.setOutput( stream, ${rootLcapName}.getModelEncoding() ); - serializer.startDocument( ${rootLcapName}.getModelEncoding(), null ); - write${root.name}( "$rootTag", ${rootLcapName}, serializer ); - serializer.endDocument(); - } //-- void write( OutputStream, ${root.name} ) - - /** - * Method writeDomToSerializer. - * - * @param dom a dom object. - * @param serializer a serializer object. - * @throws java.io.IOException java.io.IOException if any. - */ - protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer ) - throws java.io.IOException - { - serializer.startTag( NAMESPACE, dom.getName() ); - - for ( Map.Entry attribute : dom.getAttributes().entrySet() ) - { - serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() ); - } - for ( XmlNode aChild : dom.getChildren() ) - { - writeDomToSerializer( aChild, serializer ); - } - - String value = dom.getValue(); - if ( value != null ) - { - serializer.text( value ); - } - - serializer.endTag( NAMESPACE, dom.getName() ); - - } //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer ) - - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $classUcapName = $Helper.capitalise( $class.name ) ) - #set ( $classLcapName = $Helper.uncapitalise( $class.name ) ) - #set ( $allFields = $Helper.xmlFields( $class ) ) - private void write${classUcapName}( String tagName, ${classUcapName} ${classLcapName}, XmlSerializer serializer ) - throws IOException - { - if ( ${classLcapName} != null ) - { - #if ( $class == $root ) - if ( this.fileComment != null ) - { - serializer.comment(this.fileComment); - } - serializer.setPrefix( "", "http://maven.apache.org/POM/4.0.0" ); - serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - serializer.startTag( NAMESPACE, tagName ); - serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" ); - #else - serializer.startTag( NAMESPACE, tagName ); - #end - #foreach ( $field in $allFields ) - #if ( $Helper.xmlFieldMetadata( $field ).attribute ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - #if ( $field.type == "String" ) - writeAttr( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - #end - #end - #foreach ( $field in $allFields ) - #if ( ! $Helper.xmlFieldMetadata( $field ).attribute && ! $Helper.xmlFieldMetadata( $field ).transient ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - #set ( $def = ${field.defaultValue} ) - #if ( $field.type == "String" ) - #if ( ! $def ) - writeTag( "$fieldTagName", null, ${classLcapName}.get${fieldCapName}(), serializer ); - #else - writeTag( "$fieldTagName", "${def}", ${classLcapName}.get${fieldCapName}(), serializer ); - #end - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - #if ( ${def} == "true" ) - writeTag( "$fieldTagName", "${def}", ${classLcapName}.is${fieldCapName}() ? null : "false", serializer ); - #else - writeTag( "$fieldTagName", "${def}", ${classLcapName}.is${fieldCapName}() ? "true" : null, serializer ); - #end - #elseif ( $field.type == "int" ) - writeTag( "$fieldTagName", "${def}", Integer.toString( ${classLcapName}.get${fieldCapName}() ), serializer ); - #elseif ( $field.type == "DOM" ) - writeDom( ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - #set( $singularField = ${Helper.singular($fieldTagName)} ) - writeList( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer, t -> writeTag( "$singularField", "${def}", t, serializer ) ); - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - writeProperties( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.to && $field.multiplicity == "1" ) - write${field.to}( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.to && $field.multiplicity == "*" ) - #set( $singularField = ${Helper.singular($fieldTagName)} ) - writeList( "$fieldTagName", $Helper.isFlatItems($field), ${classLcapName}.get${fieldCapName}(), serializer, t -> write${field.to}( "$singularField", t, serializer ) ); - #else - // TODO: name=${field.name} type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - #end - #end - serializer.endTag( NAMESPACE, tagName ); - } - } - - #end -#end - @FunctionalInterface - private interface ElementWriter - { - public void write( T t ) throws IOException; - } - - private void writeList( String tagName, List list, XmlSerializer serializer, ElementWriter writer ) - throws IOException - { - writeList( tagName, false, list, serializer, writer ); - } - - private void writeList( String tagName, boolean flat, List list, XmlSerializer serializer, ElementWriter writer ) - throws IOException - { - if ( list != null && !list.isEmpty() ) - { - if ( !flat ) - { - serializer.startTag( NAMESPACE, tagName ); - } - for ( T t : list ) - { - writer.write( t ); - } - if ( !flat ) - { - serializer.endTag( NAMESPACE, tagName ); - } - } - } - - private void writeProperties( String tagName, Properties props, XmlSerializer serializer ) - throws IOException - { - if ( props != null && !props.isEmpty() ) - { - serializer.startTag( NAMESPACE, tagName ); - for ( Map.Entry entry : props.entrySet() ) - { - writeTag( entry.getKey().toString(), null, entry.getValue().toString(), serializer ); - } - serializer.endTag( NAMESPACE, tagName ); - } - } - - private void writeDom( XmlNode dom, XmlSerializer serializer ) - throws IOException - { - if ( dom != null ) - { - serializer.startTag( NAMESPACE, dom.getName() ); - for ( Map.Entry attr : dom.getAttributes().entrySet() ) - { - serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() ); - } - for ( XmlNode child : dom.getChildren() ) - { - writeDom( child, serializer ); - } - String value = dom.getValue(); - if ( value != null ) - { - serializer.text( value ); - } - serializer.endTag( NAMESPACE, dom.getName() ); - } - } - - private void writeTag( String tagName, String defaultValue, String value, XmlSerializer serializer ) - throws IOException - { - if ( value != null && !Objects.equals( defaultValue, value ) ) - { - serializer.startTag( NAMESPACE, tagName ).text( value ).endTag( NAMESPACE, tagName ); - } - } - - private void writeAttr( String attrName, String value, XmlSerializer serializer ) - throws IOException - { - if ( value != null ) - { - serializer.attribute( NAMESPACE, attrName, value ); - } - } - -} diff --git a/maven-settings/pom.xml b/maven-settings/pom.xml index ee70516934cc..be088709b62d 100644 --- a/maven-settings/pom.xml +++ b/maven-settings/pom.xml @@ -50,38 +50,15 @@ under the License. - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-settings.mdo - - copy - - generate-sources - - - - org.apache.maven - maven-api-settings - ${project.version} - mdo - target/mdo/ - settings.mdo - - - - - - org.codehaus.modello modello-maven-plugin 2.0.0 + ${project.basedir}/../api/maven-api-settings + ${project.basedir}/../src/mdo - target/mdo/settings.mdo + src/main/mdo/settings.mdo @@ -93,10 +70,10 @@ under the License. generate-sources - - - - + + + + packageModelV3=org.apache.maven.settings diff --git a/maven-settings/src/main/mdo/common.vm b/maven-settings/src/main/mdo/common.vm deleted file mode 100644 index aa3d17a0398e..000000000000 --- a/maven-settings/src/main/mdo/common.vm +++ /dev/null @@ -1,21 +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. -*# -## -## Nothing special to do here -## \ No newline at end of file diff --git a/maven-settings/src/main/mdo/writer.vm b/maven-settings/src/main/mdo/writer.vm deleted file mode 100644 index 7b2c805d3607..000000000000 --- a/maven-settings/src/main/mdo/writer.vm +++ /dev/null @@ -1,331 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Xpp3Writer" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#set ( $rootXml = $Helper.xmlClassMetadata( $root ) ) -#set ( $rootTag = $rootXml.tagName ) -#set ( $rootUcapName = $Helper.capitalise( $root.name ) ) -#set ( $rootLcapName = $Helper.uncapitalise( $root.name ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Properties; -import java.util.Set; -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.api.xml.XmlNode; -import org.apache.maven.internal.xml.XmlNodeBuilder; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.name}; -#end -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; -import org.codehaus.plexus.util.xml.pull.MXParser; -import org.codehaus.plexus.util.xml.pull.MXSerializer; -import org.codehaus.plexus.util.xml.pull.XmlPullParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.codehaus.plexus.util.xml.pull.XmlSerializer; - -@Generated -public class ${className} -{ - //--------------------------/ - //- Class/Member Variables -/ - //--------------------------/ - - /** - * Field NAMESPACE. - */ - private static final String NAMESPACE = null; - - /** - * Field fileComment. - */ - private String fileComment = null; - - - //-----------/ - //- Methods -/ - //-----------/ - - /** - * Method setFileComment. - * - * @param fileComment a fileComment object. - */ - public void setFileComment( String fileComment ) - { - this.fileComment = fileComment; - } //-- void setFileComment( String ) - - /** - * Method write. - * - * @param writer a writer object - * @param ${rootLcapName} a ${root.name} object - * @throws java.io.IOException java.io.IOException if any - */ - public void write( Writer writer, ${root.name} ${rootLcapName} ) - throws java.io.IOException - { - XmlSerializer serializer = new MXSerializer(); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); - serializer.setOutput( writer ); - serializer.startDocument( ${rootLcapName}.getModelEncoding(), null ); - write${root.name}( "$rootTag", ${rootLcapName}, serializer ); - serializer.endDocument(); - } //-- void write( Writer, ${root.name} ) - - /** - * Method write. - * - * @param stream a stream object - * @param ${rootLcapName} a ${root.name} object - * @throws java.io.IOException java.io.IOException if any - */ - public void write( OutputStream stream, ${root.name} ${rootLcapName} ) - throws java.io.IOException - { - XmlSerializer serializer = new MXSerializer(); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " " ); - serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" ); - serializer.setOutput( stream, ${rootLcapName}.getModelEncoding() ); - serializer.startDocument( ${rootLcapName}.getModelEncoding(), null ); - write${root.name}( "$rootTag", ${rootLcapName}, serializer ); - serializer.endDocument(); - } //-- void write( OutputStream, ${root.name} ) - - /** - * Method writeDomToSerializer. - * - * @param dom a dom object. - * @param serializer a serializer object. - * @throws java.io.IOException java.io.IOException if any. - */ - protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer ) - throws java.io.IOException - { - serializer.startTag( NAMESPACE, dom.getName() ); - - for ( Map.Entry attribute : dom.getAttributes().entrySet() ) - { - serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() ); - } - for ( XmlNode aChild : dom.getChildren() ) - { - writeDomToSerializer( aChild, serializer ); - } - - String value = dom.getValue(); - if ( value != null ) - { - serializer.text( value ); - } - - serializer.endTag( NAMESPACE, dom.getName() ); - - } //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer ) - - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $classUcapName = $Helper.capitalise( $class.name ) ) - #set ( $classLcapName = $Helper.uncapitalise( $class.name ) ) - #set ( $allFields = $Helper.xmlFields( $class ) ) - private void write${classUcapName}( String tagName, ${classUcapName} ${classLcapName}, XmlSerializer serializer ) - throws IOException - { - if ( ${classLcapName} != null ) - { - #if ( $class == $root ) - if ( this.fileComment != null ) - { - serializer.comment(this.fileComment); - } - serializer.setPrefix( "", "http://maven.apache.org/POM/4.0.0" ); - serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" ); - serializer.startTag( NAMESPACE, tagName ); - serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" ); - #else - serializer.startTag( NAMESPACE, tagName ); - #end - #foreach ( $field in $allFields ) - #if ( $Helper.xmlFieldMetadata( $field ).attribute ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - #if ( $field.type == "String" ) - writeAttr( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - #end - #end - #foreach ( $field in $allFields ) - #if ( ! $Helper.xmlFieldMetadata( $field ).attribute && ! $Helper.xmlFieldMetadata( $field ).transient ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - #set ( $def = ${field.defaultValue} ) - #if ( $field.type == "String" ) - #if ( ! $def ) - writeTag( "$fieldTagName", null, ${classLcapName}.get${fieldCapName}(), serializer ); - #else - writeTag( "$fieldTagName", "${def}", ${classLcapName}.get${fieldCapName}(), serializer ); - #end - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - #if ( ${def} == "true" ) - writeTag( "$fieldTagName", "${def}", ${classLcapName}.is${fieldCapName}() ? null : "false", serializer ); - #else - writeTag( "$fieldTagName", "${def}", ${classLcapName}.is${fieldCapName}() ? "true" : null, serializer ); - #end - #elseif ( $field.type == "int" ) - writeTag( "$fieldTagName", "${def}", Integer.toString( ${classLcapName}.get${fieldCapName}() ), serializer ); - #elseif ( $field.type == "DOM" ) - writeDom( ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - #set( $singularField = ${Helper.singular($fieldTagName)} ) - writeList( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer, t -> writeTag( "$singularField", "${def}", t, serializer ) ); - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - writeProperties( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.to && $field.multiplicity == "1" ) - write${field.to}( "$fieldTagName", ${classLcapName}.get${fieldCapName}(), serializer ); - #elseif ( $field.to && $field.multiplicity == "*" ) - #set( $singularField = ${Helper.singular($fieldTagName)} ) - writeList( "$fieldTagName", $Helper.isFlatItems($field), ${classLcapName}.get${fieldCapName}(), serializer, t -> write${field.to}( "$singularField", t, serializer ) ); - #else - // TODO: name=${field.name} type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - #end - #end - serializer.endTag( NAMESPACE, tagName ); - } - } - - #end -#end - @FunctionalInterface - private interface ElementWriter - { - public void write( T t ) throws IOException; - } - - private void writeList( String tagName, List list, XmlSerializer serializer, ElementWriter writer ) - throws IOException - { - writeList( tagName, false, list, serializer, writer ); - } - - private void writeList( String tagName, boolean flat, List list, XmlSerializer serializer, ElementWriter writer ) - throws IOException - { - if ( list != null && !list.isEmpty() ) - { - if ( !flat ) - { - serializer.startTag( NAMESPACE, tagName ); - } - for ( T t : list ) - { - writer.write( t ); - } - if ( !flat ) - { - serializer.endTag( NAMESPACE, tagName ); - } - } - } - - private void writeProperties( String tagName, Map props, XmlSerializer serializer ) - throws IOException - { - if ( props != null && !props.isEmpty() ) - { - serializer.startTag( NAMESPACE, tagName ); - for ( Map.Entry entry : props.entrySet() ) - { - writeTag( entry.getKey(), null, entry.getValue(), serializer ); - } - serializer.endTag( NAMESPACE, tagName ); - } - } - - private void writeDom( XmlNode dom, XmlSerializer serializer ) - throws IOException - { - if ( dom != null ) - { - serializer.startTag( NAMESPACE, dom.getName() ); - for ( Map.Entry attr : dom.getAttributes().entrySet() ) - { - serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() ); - } - for ( XmlNode child : dom.getChildren() ) - { - writeDom( child, serializer ); - } - String value = dom.getValue(); - if ( value != null ) - { - serializer.text( value ); - } - serializer.endTag( NAMESPACE, dom.getName() ); - } - } - - private void writeTag( String tagName, String defaultValue, String value, XmlSerializer serializer ) - throws IOException - { - if ( value != null && !Objects.equals( defaultValue, value ) ) - { - serializer.startTag( NAMESPACE, tagName ).text( value ).endTag( NAMESPACE, tagName ); - } - } - - private void writeAttr( String attrName, String value, XmlSerializer serializer ) - throws IOException - { - if ( value != null ) - { - serializer.attribute( NAMESPACE, attrName, value ); - } - } - -} diff --git a/maven-toolchain-model/pom.xml b/maven-toolchain-model/pom.xml index 01ecb03cb058..ce241dbac015 100644 --- a/maven-toolchain-model/pom.xml +++ b/maven-toolchain-model/pom.xml @@ -49,38 +49,15 @@ under the License. - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-toolchains.mdo - - copy - - generate-sources - - - - org.apache.maven - maven-api-toolchain - ${project.version} - mdo - target/mdo/ - toolchains.mdo - - - - - - org.codehaus.modello modello-maven-plugin 1.1.0 + ${project.basedir}/../api/maven-api-toolchain + ${project.basedir}/../src/mdo - target/mdo/toolchains.mdo + src/main/mdo/toolchains.mdo @@ -92,10 +69,10 @@ under the License. generate-sources - - - - + + + + packageModelV3=org.apache.maven.toolchain.model diff --git a/maven-toolchain-model/src/main/mdo/common.vm b/maven-toolchain-model/src/main/mdo/common.vm deleted file mode 100644 index aa3d17a0398e..000000000000 --- a/maven-toolchain-model/src/main/mdo/common.vm +++ /dev/null @@ -1,21 +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. -*# -## -## Nothing special to do here -## \ No newline at end of file diff --git a/maven-toolchain-model/src/main/mdo/merger.vm b/maven-toolchain-model/src/main/mdo/merger.vm deleted file mode 100644 index 57d4fab0c928..000000000000 --- a/maven-toolchain-model/src/main/mdo/merger.vm +++ /dev/null @@ -1,379 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Merger" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.ObjectStreamException; -import java.util.AbstractList; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.api.xml.XmlNode; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.Name}; -#end - -@Generated -public class ${className} -{ - - /** - * Merges the specified source object into the given target object. - * - * @param target The target object whose existing contents should be merged with the source, must not be - * null. - * @param source The (read-only) source object that should be merged into the target object, may be - * null. - * @param sourceDominant A flag indicating whether either the target object or the source object provides the - * dominant data. - * @param hints A set of key-value pairs that customized merger implementations can use to carry domain-specific - * information along, may be null. - */ - public ${root.name} merge( ${root.name} target, ${root.name} source, boolean sourceDominant, Map hints ) - { - Objects.requireNonNull( target, "target cannot be null" ); - if ( source == null ) - { - return target; - } - Map context = new HashMap<>(); - if ( hints != null ) - { - context.putAll( hints ); - } - return merge${root.name}( target, source, sourceDominant, context ); - } - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #foreach ( $cl in $ancestors ) - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - protected ${class.name} merge${class.name}( ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - ${class.name}.Builder builder = ${class.name}.newBuilder( target ); - merge${class.name}( builder, target, source, sourceDominant, context ); - return builder.build(); - } - - protected void merge${class.name}( ${class.name}.Builder builder, ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - #if ( $class.superClass ) - merge${class.superClass}( builder, target ,source, sourceDominant, context ); - #end - #foreach ( $field in $class.getFields($version) ) - merge${field.modelClass.name}_${Helper.capitalise($field.name)}( builder, target, source, sourceDominant, context ); - #end - } - - #foreach ( $field in $allFields ) - #set ( $capField = ${Helper.capitalise($field.name)} ) - protected void merge${class.name}_${capField}( ${class.name}.Builder builder, ${class.name} target, ${class.name} source, boolean sourceDominant, Map context ) - { - #if ( $field.type == "String" ) - String src = source.get${capField}(); - String tgt = target.get${capField}(); - if ( src != null && ( sourceDominant || tgt == null ) ) - { - builder.${field.name}( src ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, e -> e ) ); - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - Map src = source.get${capField}(); - if ( !src.isEmpty() ) - { - Map tgt = target.get${capField}(); - if ( tgt.isEmpty() ) - { - builder.${field.name}( src ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - else - { - Map merged = new HashMap<>(); - merged.putAll( sourceDominant ? target.get${capField}() : source.get${capField}() ); - merged.putAll( sourceDominant ? source.get${capField}() : target.get${capField}() ); - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", InputLocation.merge( target.getLocation( "${field.name}" ), source.getLocation( "${field.name}" ), sourceDominant ) ); - #end - } - } - #elseif ( $field.to && $field.multiplicity == "1" ) - ${field.to} src = source.get${capField}(); - if ( src != null ) - { - ${field.to} tgt = target.get${capField}(); - if ( tgt == null ) - { - tgt = ${field.to}.newInstance( false ); - } - ${field.to} merged = merge${field.to}( tgt, src, sourceDominant, context ); - if ( merged == src ) - { - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", source.getLocation( "${field.name}" ) ); - #end - } - else if ( merged != tgt ) - { - builder.${field.name}( merged ); - #if ( $locationTracking ) - builder.location( "${field.name}", InputLocation.merge( target.getLocation( "${field.name}" ), source.getLocation( "${field.name}" ), sourceDominant ) ); - #end - } - } - #elseif ( $field.to && $field.multiplicity == "*" ) - builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) ); - #elseif ( $field.type == "DOM" ) - XmlNode src = source.getConfiguration(); - if ( src != null ) - { - XmlNode tgt = target.getConfiguration(); - if ( tgt == null ) - { - builder.configuration( src ); - } - else if ( sourceDominant ) - { - builder.configuration( src.merge( tgt ) ); - } - else - { - builder.configuration( tgt.merge( src ) ); - } - } - #elseif ( $field.type == "boolean" ) - if ( sourceDominant ) - { - builder.${field.name}( source.is${capField}() ); - } - #elseif ( $field.type == "int" || $field.type == "java.nio.file.Path" ) - if ( sourceDominant ) - { - builder.${field.name}( source.get${capField}() ); - } - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - } - #end - - #end -#end - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - protected KeyComputer<${class.name}> get${class.name}Key() - { - return v -> v; - } - #end -#end - - /** - * Use to compute keys for data structures - * @param the data structure type - */ - @FunctionalInterface - public interface KeyComputer extends Function - { - } - - /** - * Merge two lists - */ - public static List merge( List tgt, List src, boolean sourceDominant, KeyComputer computer ) - { - return merge( tgt, src, computer, ( t, s ) -> sourceDominant ? s : t ); - } - - public static List merge( List tgt, List src, KeyComputer computer, BinaryOperator remapping ) - { - if ( src.isEmpty() ) - { - return tgt; - } - - MergingList list; - if ( tgt instanceof MergingList ) - { - list = (MergingList) tgt; - } - else - { - list = new MergingList<>( computer, src.size() + tgt.size() ); - list.mergeAll( tgt, ( t, s ) -> s ); - } - - list.mergeAll( src, remapping ); - return list; - } - - /** - * Merging list - * @param - */ - private static class MergingList extends AbstractList implements java.io.Serializable - { - - private final KeyComputer keyComputer; - private Map map; - private List list; - - MergingList( KeyComputer keyComputer, int initialCapacity ) - { - this.map = new LinkedHashMap<>( initialCapacity ); - this.keyComputer = keyComputer; - } - - Object writeReplace() throws ObjectStreamException - { - return new ArrayList<>( this ); - } - - @Override - public Iterator iterator() - { - if ( map != null ) - { - return map.values().iterator(); - } - else - { - return list.iterator(); - } - } - - void mergeAll( Collection vs, BinaryOperator remapping ) - { - if ( map == null ) - { - map = list.stream().collect( Collectors.toMap( keyComputer, - Function.identity(), - null, - LinkedHashMap::new ) ); - - list = null; - } - - if ( vs instanceof MergingList && ( (MergingList) vs ).map != null ) - { - for ( Map.Entry e : ( (MergingList) vs ).map.entrySet() ) - { - Object key = e.getKey(); - V v = e.getValue(); - map.merge( key, v, remapping ); - } - } - else - { - for ( V v : vs ) - { - Object key = keyComputer.apply( v ); - - map.merge( key, v, remapping ); - } - } - } - - @Override - public boolean contains( Object o ) - { - if ( map != null ) - { - return map.containsValue( o ); - } - else - { - return list.contains( o ); - } - } - - private List asList() - { - if ( list == null ) - { - list = new ArrayList<>( map.values() ); - map = null; - } - return list; - } - - @Override - public void add( int index, V element ) - { - asList().add( index, element ); - } - - @Override - public V remove( int index ) - { - return asList().remove( index ); - } - - @Override - public V get( int index ) - { - return asList().get( index ); - } - - @Override - public int size() - { - if ( map != null ) - { - return map.size(); - } - else - { - return list.size(); - } - } - } -} diff --git a/maven-toolchain-model/src/main/mdo/model-v3.vm b/maven-toolchain-model/src/main/mdo/model-v3.vm deleted file mode 100644 index 9e06cff9ba59..000000000000 --- a/maven-toolchain-model/src/main/mdo/model-v3.vm +++ /dev/null @@ -1,255 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageModelV3}" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -# -#foreach ( $class in $model.allClasses ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #set ( $inheritedFields = [] ) - #foreach ( $cl in $ancestors ) - #if ( $cl != $class ) - #set ( $dummy = $inheritedFields.addAll( $cl.allFields ) ) - #end - #set ( $dummy = $allFields.addAll( $cl.allFields ) ) - #end - #set ( $className = "${class.name}" ) -#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() ) - #set ( $dummy = $imports.add( "java.io.Serializable" ) ) - #set ( $dummy = $imports.add( "java.util.AbstractList" ) ) - #set ( $dummy = $imports.add( "java.util.Collections" ) ) - #set ( $dummy = $imports.add( "java.util.HashMap" ) ) - #set ( $dummy = $imports.add( "java.util.List" ) ) - #set ( $dummy = $imports.add( "java.util.Map" ) ) - #set ( $dummy = $imports.add( "java.util.stream.Collectors" ) ) - #set ( $dummy = $imports.add( "java.util.stream.Stream" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Generated" ) ) - #set ( $dummy = $imports.add( "org.apache.maven.api.annotations.Nonnull" ) ) - #foreach ( $field in $allFields ) - #if ( $field.type == "java.util.List" ) - #set ( $dummy = $imports.add( "java.util.ArrayList" ) ) - #set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) ) - #elseif ( $field.type == "DOM" ) - #set ( $dummy = $imports.add( "org.codehaus.plexus.util.xml.Xpp3Dom" ) ) - #set ( $dummy = $types.put( $field, "Object" ) ) - #else - #set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} ) - #set ( $idx = $fieldType.lastIndexOf('.') ) - #if ( $idx > 0 ) - #set ( $dummy = $imports.add( $fieldType ) ) - #set ( $dummy = $types.put( $fieldType, $fieldType.substring( $idx + 1 ) ) ) - #end - #end - #end - #set ( $eq = "" ) - #set ( $hc = "" ) - #foreach ( $field in $allFields ) - #if ( $field.identifier ) - #set ( $dummy = $imports.add( "java.util.Objects" ) ) - #set ( $dummy = $identifiers.add( $field ) ) - #if ( $eq == "" ) - #set ( $eq = "Objects.equals( this.${field.name}, that.${field.name} )" ) - #else - #set ( $eq = "$eq && Objects.equals( this.${field.name}, that.${field.name} )" ) - #end - #if ( $hc == "" ) - #set ( $hc = "${field.name}" ) - #else - #set ( $hc = "$hc, this.${field.name}" ) - #end - #end - #end -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - - #foreach ( $imp in $imports ) -import $imp; - #end - -@Generated -public class ${class.name} - #if ( $class.superClass ) - extends ${class.superClass} - #end - implements Serializable, Cloneable -{ - - #if ( ! $class.superClass ) - ${packageModelV4}.${class.name} delegate; - #end - - public ${class.name}() - { - this( ${packageModelV4}.${class.name}.newInstance() ); - } - - public ${class.name}( ${packageModelV4}.${class.name} delegate ) - { - #if ( $class.superClass ) - super( delegate ); - #else - this.delegate = delegate; - #end - } - - public ${class.name} clone() - { - return new ${class.name}( getDelegate() ); - } - - #if ( $class.superClass ) - @Override - #end - public ${packageModelV4}.${class.name} getDelegate() - { - #if ( $class.superClass ) - return ( ${packageModelV4}.${class.name} ) delegate; - #else - return delegate; - #end - } - - #if ( ! $eq.empty ) - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || !( o instanceof ${class.name} ) ) - { - return false; - } - ${class.name} that = ( ${class.name} ) o; - return Objects.equals( this.delegate, that.delegate ); - } - - @Override - public int hashCode() - { - return getDelegate().hashCode(); - } - - #end - #if ( $class == $root ) - public String getModelEncoding() - { - return getDelegate().getModelEncoding(); - } - - #end - #foreach ( $field in $class.getFields($version) ) - #set ( $cap = $Helper.capitalise( $field.name ) ) - #set ( $type = ${types.getOrDefault($field,${types.getOrDefault($field.type,$field.type)})} ) - #if ( $type == "boolean" || $type == "Boolean" ) - #set ( $pfx = "is" ) - #else - #set ( $pfx = "get" ) - #end - #if ( $field.type == "java.util.List" || $field.type == "java.util.Properties" ) - @Nonnull - #end - public ${type} ${pfx}${cap}() - { - #if ( $field.to != "String" && $field.type == "java.util.List" && $field.multiplicity == "*" ) - return new WrapperList<${field.to}, ${packageModelV4}.${field.to}>( - getDelegate()::get${cap}, l -> delegate = getDelegate().with${cap}( l ), - ${field.to}::new, ${field.to}::getDelegate ); - #elseif ( $field.to == "String" && $field.type == "java.util.Properties" && $field.multiplicity == "*" ) - return new WrapperProperties( getDelegate()::get${cap}, this::set${cap} ); - #elseif ( $field.to == "String" && $field.type == "java.util.List" && $field.multiplicity == "*" ) - return new WrapperList( getDelegate()::get${cap}, this::set${cap}, s -> s, s -> s ); - #elseif ( $field.to ) - return getDelegate().${pfx}${cap}() != null ? new ${field.to}( getDelegate().${pfx}${cap}() ) : null; - #elseif ( $field.type == "DOM" ) - return getDelegate().${pfx}${cap}() != null ? new Xpp3Dom( getDelegate().${pfx}${cap}() ) : null; - #else - return getDelegate().${pfx}${cap}(); - #end - } - - public void set${cap}( ${type} ${field.name} ) - { - #if ( $field.type == "DOM" ) - delegate = getDelegate().with${cap}( ( ( Xpp3Dom ) ${field.name} ).getDom() ); - #elseif( $field.type == "java.util.Properties" ) - Map map = ${field.name}.entrySet().stream() - .collect( Collectors.toMap( e -> e.getKey().toString(), e -> e.getValue().toString() ) ); - delegate = getDelegate().with${cap}( map ); - #elseif ( $field.to != "String" && $field.type == "java.util.List" && $field.multiplicity == "*" ) - delegate = getDelegate().with${cap}( - ${field.name}.stream().map( c -> c.getDelegate() ).collect( Collectors.toList() ) ); - #elseif ( $field.to && $field.to != "String" ) - delegate = getDelegate().with${cap}( ${field.name}.getDelegate() ); - #else - delegate = getDelegate().with${cap}( ${field.name} ); - #end - } - - #if ( $field.type == "java.util.List" && $field.multiplicity == "*" ) - #set ( $v = $Helper.singular( ${field.name} ) ) - #set ( $scap = $Helper.capitalise( $v ) ) - public void add${scap}( ${field.to} ${v} ) - { - #if ( $field.to == "String" ) - delegate = getDelegate().with${cap}( - Stream.concat( getDelegate().get${cap}().stream(), Stream.of( ${v} ) ) - .collect( Collectors.toList() ) ); - #else - delegate = getDelegate().with${cap}( - Stream.concat( getDelegate().get${cap}().stream(), Stream.of( ${v}.getDelegate() ) ) - .collect( Collectors.toList() ) ); - #end - } - - #elseif ( $field.type == "java.util.Properties" && $field.multiplicity == "*" ) - #set ( $v = $Helper.singular( ${field.name} ) ) - #set ( $scap = $Helper.capitalise( $v ) ) - public void add${scap}( String key, String value ) - { - get${cap}().put( key, value ); - } - - #end - #end - public static List<${packageModelV4}.${class.name}> ${Helper.uncapitalise(${class.name})}ToApiV4( List<${class.name}> list ) - { - return list != null ? new WrapperList<>( list, ${class.name}::getDelegate, ${class.name}::new ) : null; - } - - public static List<${class.name}> ${Helper.uncapitalise(${class.name})}ToApiV3( List<${packageModelV4}.${class.name}> list ) - { - return list != null ? new WrapperList<>( list, ${class.name}::new, ${class.name}::getDelegate ) : null; - } - - #foreach ( $cs in $class.getCodeSegments($version) ) -$cs.code - #end -} - #end -#end diff --git a/maven-toolchain-model/src/main/mdo/reader.vm b/maven-toolchain-model/src/main/mdo/reader.vm deleted file mode 100644 index 02e9199ba8c1..000000000000 --- a/maven-toolchain-model/src/main/mdo/reader.vm +++ /dev/null @@ -1,902 +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. -*# -#parse ( "src/main/mdo/common.vm" ) -# -#set ( $package = "${packageToolV4}" ) -#set ( $className = "${model.name}Xpp3Reader" ) -# -#set ( $root = $model.getClass( $model.getRoot($version), $version ) ) -#set ( $rootXml = $Helper.xmlClassMetadata( $root ) ) -#set ( $rootTag = $rootXml.tagName ) -#set ( $rootUcapName = $Helper.capitalise( $root.name ) ) -#set ( $rootLcapName = $Helper.uncapitalise( $root.name ) ) -# -#MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java -// =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} -// ============================================================== -package ${package}; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import org.apache.maven.api.annotations.Generated; -import org.apache.maven.internal.xml.XmlNodeBuilder; -#foreach ( $class in $model.allClasses ) -import ${packageModelV4}.${class.name}; -#end -import org.codehaus.plexus.util.ReaderFactory; -import org.codehaus.plexus.util.xml.pull.EntityReplacementMap; -import org.codehaus.plexus.util.xml.pull.MXParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParser; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -@Generated -public class ${className} -{ - private boolean addDefaultEntities = true; - - private final ContentTransformer contentTransformer; - - public ${className}() - { - this( ( s, f ) -> s ); - } - - public ${className}( ContentTransformer contentTransformer ) - { - this.contentTransformer = contentTransformer; - } - - /** - * Method checkFieldWithDuplicate. - * - * @param parser a parser object. - * @param parsed a parsed object. - * @param alias a alias object. - * @param tagName a tagName object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return boolean - */ - private boolean checkFieldWithDuplicate( XmlPullParser parser, String tagName, String alias, Set parsed ) - throws XmlPullParserException - { - if ( !( parser.getName().equals( tagName ) || parser.getName().equals( alias ) ) ) - { - return false; - } - if ( !parsed.add( tagName ) ) - { - throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); - } - return true; - } //-- boolean checkFieldWithDuplicate( XmlPullParser, String, String, Set ) - - /** - * Method checkUnknownAttribute. - * - * @param parser a parser object. - * @param strict a strict object. - * @param tagName a tagName object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @throws IOException IOException if any. - */ - private void checkUnknownAttribute( XmlPullParser parser, String attribute, String tagName, boolean strict ) - throws XmlPullParserException, IOException - { - // strictXmlAttributes = true for model: if strict == true, not only elements are checked but attributes too - if ( strict ) - { - throw new XmlPullParserException( "Unknown attribute '" + attribute + "' for tag '" + tagName + "'", parser, null ); - } - } //-- void checkUnknownAttribute( XmlPullParser, String, String, boolean ) - - /** - * Method checkUnknownElement. - * - * @param parser a parser object. - * @param strict a strict object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @throws IOException IOException if any. - */ - private void checkUnknownElement( XmlPullParser parser, boolean strict ) - throws XmlPullParserException, IOException - { - if ( strict ) - { - throw new XmlPullParserException( "Unrecognised tag: '" + parser.getName() + "'", parser, null ); - } - - for ( int unrecognizedTagCount = 1; unrecognizedTagCount > 0; ) - { - int eventType = parser.next(); - if ( eventType == XmlPullParser.START_TAG ) - { - unrecognizedTagCount++; - } - else if ( eventType == XmlPullParser.END_TAG ) - { - unrecognizedTagCount--; - } - } - } //-- void checkUnknownElement( XmlPullParser, boolean ) - - /** - * Returns the state of the "add default entities" flag. - * - * @return boolean - */ - public boolean getAddDefaultEntities() - { - return addDefaultEntities; - } //-- boolean getAddDefaultEntities() - - /** - * Method getBooleanValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return boolean - */ - private boolean getBooleanValue( String s, String attribute, XmlPullParser parser ) - throws XmlPullParserException - { - return getBooleanValue( s, attribute, parser, null ); - } //-- boolean getBooleanValue( String, String, XmlPullParser ) - - /** - * Method getBooleanValue. - * - * @param s a s object. - * @param defaultValue a defaultValue object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return boolean - */ - private boolean getBooleanValue( String s, String attribute, XmlPullParser parser, String defaultValue ) - throws XmlPullParserException - { - if ( s != null && s.length() != 0 ) - { - return Boolean.valueOf( s ).booleanValue(); - } - if ( defaultValue != null ) - { - return Boolean.valueOf( defaultValue ).booleanValue(); - } - return false; - } //-- boolean getBooleanValue( String, String, XmlPullParser, String ) - - /** - * Method getByteValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return byte - */ - private byte getByteValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Byte.valueOf( s ).byteValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a byte", parser, nfe ); - } - } - } - return 0; - } //-- byte getByteValue( String, String, XmlPullParser, boolean ) - - /** - * Method getCharacterValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return char - */ - private char getCharacterValue( String s, String attribute, XmlPullParser parser ) - throws XmlPullParserException - { - if ( s != null ) - { - return s.charAt( 0 ); - } - return 0; - } //-- char getCharacterValue( String, String, XmlPullParser ) - - /** - * Method getDateValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return Date - */ - private Date getDateValue( String s, String attribute, XmlPullParser parser ) - throws XmlPullParserException - { - return getDateValue( s, attribute, null, parser ); - } //-- Date getDateValue( String, String, XmlPullParser ) - - /** - * Method getDateValue. - * - * @param s a s object. - * @param parser a parser object. - * @param dateFormat a dateFormat object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return Date - */ - private Date getDateValue( String s, String attribute, String dateFormat, XmlPullParser parser ) - throws XmlPullParserException - { - if ( s != null ) - { - String effectiveDateFormat = dateFormat; - if ( dateFormat == null ) - { - effectiveDateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"; - } - if ( "long".equals( effectiveDateFormat ) ) - { - try - { - return new java.util.Date( Long.parseLong( s ) ); - } - catch ( NumberFormatException e ) - { - throw new XmlPullParserException( e.getMessage(), parser, e ); - } - } - else - { - try - { - DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US ); - return dateParser.parse( s ); - } - catch ( java.text.ParseException e ) - { - throw new XmlPullParserException( e.getMessage(), parser, e ); - } - } - } - return null; - } //-- Date getDateValue( String, String, String, XmlPullParser ) - - /** - * Method getDoubleValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return double - */ - private double getDoubleValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Double.valueOf( s ).doubleValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); - } - } - } - return 0; - } //-- double getDoubleValue( String, String, XmlPullParser, boolean ) - - /** - * Method getFloatValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return float - */ - private float getFloatValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Float.valueOf( s ).floatValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a floating point number", parser, nfe ); - } - } - } - return 0; - } //-- float getFloatValue( String, String, XmlPullParser, boolean ) - - /** - * Method getIntegerValue. - * - * @param s a s object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return int - */ - private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - return getIntegerValue( s, attribute, parser, strict, 0 ); - } //-- int getBooleanValue( String, String, XmlPullParser ) - - /** - * Method getIntegerValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return int - */ - private int getIntegerValue( String s, String attribute, XmlPullParser parser, boolean strict, int defaultValue ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Integer.valueOf( s ).intValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be an integer", parser, nfe ); - } - } - } - return defaultValue; - } //-- int getIntegerValue( String, String, XmlPullParser, boolean, int ) - - /** - * Method getLongValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return long - */ - private long getLongValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Long.valueOf( s ).longValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a long integer", parser, nfe ); - } - } - } - return 0; - } //-- long getLongValue( String, String, XmlPullParser, boolean ) - - /** - * Method getRequiredAttributeValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return String - */ - private String getRequiredAttributeValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s == null ) - { - if ( strict ) - { - throw new XmlPullParserException( "Missing required value for attribute '" + attribute + "'", parser, null ); - } - } - return s; - } //-- String getRequiredAttributeValue( String, String, XmlPullParser, boolean ) - - /** - * Method getShortValue. - * - * @param s a s object. - * @param strict a strict object. - * @param parser a parser object. - * @param attribute a attribute object. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return short - */ - private short getShortValue( String s, String attribute, XmlPullParser parser, boolean strict ) - throws XmlPullParserException - { - if ( s != null ) - { - try - { - return Short.valueOf( s ).shortValue(); - } - catch ( NumberFormatException nfe ) - { - if ( strict ) - { - throw new XmlPullParserException( "Unable to parse element '" + attribute + "', must be a short integer", parser, nfe ); - } - } - } - return 0; - } //-- short getShortValue( String, String, XmlPullParser, boolean ) - - /** - * Method getTrimmedValue. - * - * @param s a s object. - * @return String - */ - private String getTrimmedValue( String s ) - { - if ( s != null ) - { - s = s.trim(); - } - return s; - } //-- String getTrimmedValue( String ) - - /** - * Method interpolatedTrimmed. - * - * @param value a value object. - * @param context a context object. - * @return String - */ - private String interpolatedTrimmed( String value, String context ) - { - return getTrimmedValue( contentTransformer.transform( value, context ) ); - } //-- String interpolatedTrimmed( String, String ) - - /** - * Method nextTag. - * - * @param parser a parser object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return int - */ - private int nextTag( XmlPullParser parser ) - throws IOException, XmlPullParserException - { - int eventType = parser.next(); - if ( eventType == XmlPullParser.TEXT ) - { - eventType = parser.next(); - } - if ( eventType != XmlPullParser.START_TAG && eventType != XmlPullParser.END_TAG ) - { - throw new XmlPullParserException( "expected START_TAG or END_TAG not " + XmlPullParser.TYPES[eventType], parser, null ); - } - return eventType; - } //-- int nextTag( XmlPullParser ) - - /** - * @see ReaderFactory#newXmlReader - * - * @param reader a reader object. - * @param strict a strict object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( Reader reader, boolean strict ) - throws IOException, XmlPullParserException - { - XmlPullParser parser = addDefaultEntities ? new MXParser(EntityReplacementMap.defaultEntityReplacementMap) : new MXParser( ); - - parser.setInput( reader ); - - - return read( parser, strict ); - } //-- ${root.name} read( Reader, boolean ) - - /** - * @see ReaderFactory#newXmlReader - * - * @param reader a reader object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( Reader reader ) - throws IOException, XmlPullParserException - { - return read( reader, true ); - } //-- ${root.name} read( Reader ) - - /** - * Method read. - * - * @param in a in object. - * @param strict a strict object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( InputStream in, boolean strict ) - throws IOException, XmlPullParserException - { - return read( ReaderFactory.newXmlReader( in ), strict ); - } //-- ${root.name} read( InputStream, boolean ) - - /** - * Method read. - * - * @param in a in object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( InputStream in ) - throws IOException, XmlPullParserException - { - return read( ReaderFactory.newXmlReader( in ) ); - } //-- ${root.name} read( InputStream ) - - /** - * Method read. - * - * @param parser a parser object. - * @param strict a strict object. - * @throws IOException IOException if any. - * @throws XmlPullParserException XmlPullParserException if - * any. - * @return ${root.name} - */ - public ${root.name} read( XmlPullParser parser, boolean strict ) - throws IOException, XmlPullParserException - { - $rootUcapName $rootLcapName = null; - int eventType = parser.getEventType(); - boolean parsed = false; - while ( eventType != XmlPullParser.END_DOCUMENT ) - { - if ( eventType == XmlPullParser.START_TAG ) - { - if ( strict && ! "${rootTag}".equals( parser.getName() ) ) - { - throw new XmlPullParserException( "Expected root element '${rootTag}' but found '" + parser.getName() + "'", parser, null ); - } - else if ( parsed ) - { - // fallback, already expected a XmlPullParserException due to invalid XML - throw new XmlPullParserException( "Duplicated tag: '${rootTag}'", parser, null ); - } - $rootLcapName = parse${rootUcapName}( parser, strict ); - parsed = true; - } - eventType = parser.next(); - } - if ( parsed ) - { - return $rootLcapName; - } - throw new XmlPullParserException( "Expected root element '${rootTag}' but found no element at all: invalid XML document", parser, null ); - } //-- ${root.name} read( XmlPullParser, boolean ) - -#foreach ( $class in $model.allClasses ) - #if ( $class.name != "InputSource" && $class.name != "InputLocation" ) - #set ( $classUcapName = $Helper.capitalise( $class.name ) ) - #set ( $classLcapName = $Helper.uncapitalise( $class.name ) ) - #set ( $ancestors = $Helper.ancestors( $class ) ) - #set ( $allFields = [] ) - #foreach ( $cl in $ancestors ) - #set ( $dummy = $allFields.addAll( $cl.getFields($version) ) ) - #end - private ${classUcapName} parse${classUcapName}( XmlPullParser parser, boolean strict ) - throws IOException, XmlPullParserException - { - String tagName = parser.getName(); - ${classUcapName}.Builder ${classLcapName} = ${classUcapName}.newBuilder( true ); - for ( int i = parser.getAttributeCount() - 1; i >= 0; i-- ) - { - String name = parser.getAttributeName( i ); - String value = parser.getAttributeValue( i ); - if ( name.indexOf( ':' ) >= 0 ) - { - // just ignore attributes with non-default namespace (for example: xmlns:xsi) - } - #if ( $class == $root ) - else if ( "xmlns".equals( name ) ) - { - // ignore xmlns attribute in root class, which is a reserved attribute name - } - #end - #foreach ( $field in $allFields ) - #if ( $Helper.xmlFieldMetadata( $field ).attribute ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - else if ( "$fieldTagName".equals( name ) ) - { - #if ( $field.type == "String" ) - ${classLcapName}.${field.name}( interpolatedTrimmed( value, "$fieldTagName" ) ); - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - ${classLcapName}.${field.name}( getBooleanValue( interpolatedTrimmed( value, "$fieldTagName" ), "$fieldTagName", parser, "${field.defaultValue}" ) ); - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - #end - } - #end - #end - else - { - checkUnknownAttribute( parser, name, tagName, strict ); - } - } - Set parsed = new HashSet<>(); - #foreach ( $field in $allFields ) - #if ( $Helper.isFlatItems( $field ) ) - List<$field.to> ${field.name} = new ArrayList<>(); - #end - #end - while ( ( strict ? parser.nextTag() : nextTag( parser ) ) == XmlPullParser.START_TAG ) - { - String childName = checkDuplicate( parser.getName(), parser, parsed ); - switch ( childName ) - { - #set( $ift = "if" ) - #foreach ( $field in $allFields ) - #if ( ! $Helper.xmlFieldMetadata( $field ).attribute && ! $Helper.xmlFieldMetadata( $field ).transient ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #if ( $Helper.isFlatItems( $field ) ) - #set ( $fieldTagName = $Helper.singular( $fieldTagName ) ) - #end - #set ( $fieldCapName = $Helper.capitalise( $field.name ) ) - case "${fieldTagName}": - { - #if ( $field.type == "String" ) - ${classLcapName}.${field.name}( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ) ); - break; - #elseif ( $field.type == "boolean" || $field.type == "Boolean" ) - ${classLcapName}.${field.name}( getBooleanValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, "${field.defaultValue}" ) ); - break; - #elseif ( $field.type == "int" ) - ${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) ); - break; - #elseif ( $field.type == "DOM" ) - ${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) ); - break; - #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" ) - List ${field.name} = new ArrayList<>(); - while ( parser.nextTag() == XmlPullParser.START_TAG ) - { - if ( "${Helper.singular($fieldTagName)}".equals( parser.getName() ) ) - { - ${field.name}.add( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ) ); - } - else - { - checkUnknownElement( parser, strict ); - } - } - ${classLcapName}.${field.name}( ${field.name} ); - break; - #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" ) - Map ${field.name} = new LinkedHashMap<>(); - while ( parser.nextTag() == XmlPullParser.START_TAG ) - { - String key = parser.getName(); - String value = parser.nextText().trim(); - ${field.name}.put( key, value ); - } - ${classLcapName}.${field.name}( ${field.name} ); - break; - #elseif ( $field.to && $field.multiplicity == "1" ) - ${classLcapName}.${field.name}( parse${field.toClass.name}( parser, strict ) ); - break; - #elseif ( $field.to && $field.multiplicity == "*" && $Helper.isFlatItems( $field ) ) - ${field.name}.add( parse${field.toClass.name}( parser, strict ) ); - break; - #elseif ( $field.to && $field.multiplicity == "*" ) - List<$field.to> ${field.name} = new ArrayList<>(); - while ( parser.nextTag() == XmlPullParser.START_TAG ) - { - if ( "${Helper.singular($fieldTagName)}".equals( parser.getName() ) ) - { - ${field.name}.add( parse${field.toClass.name}( parser, strict ) ); - } - else - { - checkUnknownElement( parser, strict ); - } - } - ${classLcapName}.${field.name}( ${field.name} ); - break; - #else - // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity} - break; - #end - } - #set( $ift = "else if" ) - #end - #end - default: - { - checkUnknownElement( parser, strict ); - break; - } - } - } - #foreach ( $field in $allFields ) - #if ( $Helper.isFlatItems( $field ) ) - ${classLcapName}.${field.name}( ${field.name} ); - #end - #end - #if ( $class == $root ) - ${classLcapName}.modelEncoding( parser.getInputEncoding() ); - #end - return ${classLcapName}.build(); - } - - #end -#end - - private String checkDuplicate( String tagName, XmlPullParser parser, Set parsed ) - throws XmlPullParserException - { -#set( $aliases = { } ) -#set( $flats = { } ) -#foreach( $class in $model.allClasses ) - #foreach ( $field in $class.getFields($version) ) - #set ( $fieldTagName = $Helper.xmlFieldMetadata( $field ).tagName ) - #if ( ! $fieldTagName ) - #set ( $fieldTagName = $field.name ) - #end - #if ( $field.alias ) - #set ( $dummy = $aliases.put( $field.alias, $fieldTagName ) ) - #end - #if ( $Helper.isFlatItems( $field ) ) - #set ( $fieldTagName = $Helper.singular($fieldTagName) ) - #set ( $dummy = $flats.put( $fieldTagName, "" ) ) - #end - #end -#end -#if ( ! ${aliases.isEmpty()} ) - switch ( tagName ) - { - #foreach( $entry in $aliases.entrySet() ) - case "${entry.key}": - tagName = "${entry.value}"; - #end - } -#end -#if ( ! ${flats.isEmpty()} ) - switch ( tagName ) - { - #foreach( $entry in $flats.entrySet() ) - case "${entry.key}": - #end - break; - default: - if ( !parsed.add( tagName ) ) - { - throw new XmlPullParserException( "Duplicated tag: '" + tagName + "'", parser, null ); - } - } -#end - return tagName; - } - - /** - * Sets the state of the "add default entities" flag. - * - * @param addDefaultEntities a addDefaultEntities object. - */ - public void setAddDefaultEntities( boolean addDefaultEntities ) - { - this.addDefaultEntities = addDefaultEntities; - } //-- void setAddDefaultEntities( boolean ) - - public static interface ContentTransformer - { - /** - * Interpolate the value read from the xpp3 document - * @param source The source value - * @param fieldName A description of the field being interpolated. The implementation may use this to - * log stuff. - * @return The interpolated value. - */ - String transform( String source, String fieldName ); - } - -} diff --git a/pom.xml b/pom.xml index 36820f12e30f..e15feb37f91f 100644 --- a/pom.xml +++ b/pom.xml @@ -525,7 +525,7 @@ under the License. org.codehaus.modello modello-maven-plugin - 2.1.0 + 2.1.1 modello-site-docs diff --git a/api/maven-api-model/src/main/mdo/common.vm b/src/mdo/common.vm similarity index 96% rename from api/maven-api-model/src/main/mdo/common.vm rename to src/mdo/common.vm index e300b2289fea..b8ae20968191 100644 --- a/api/maven-api-model/src/main/mdo/common.vm +++ b/src/mdo/common.vm @@ -17,6 +17,7 @@ under the License. *# # +#if ( "${isMavenModel}" == "true" ) ## ## The following loop code is required in order to change the type of the ## pomFile attribute to a java.nio.file.Path. Modello does not support this @@ -28,4 +29,5 @@ #end #end #set ( $locationTracking = true ) +#end # \ No newline at end of file diff --git a/maven-settings/src/main/mdo/merger.vm b/src/mdo/merger.vm similarity index 99% rename from maven-settings/src/main/mdo/merger.vm rename to src/mdo/merger.vm index 57d4fab0c928..ff4b81c19dc4 100644 --- a/maven-settings/src/main/mdo/merger.vm +++ b/src/mdo/merger.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Merger" ) @@ -25,7 +25,7 @@ # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-model/src/main/mdo/model-v3.vm b/src/mdo/model-v3-modified.vm similarity index 99% rename from maven-model/src/main/mdo/model-v3.vm rename to src/mdo/model-v3-modified.vm index c12c5f0e62cf..0bb0f58b70e2 100644 --- a/maven-model/src/main/mdo/model-v3.vm +++ b/src/mdo/model-v3-modified.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageModelV3}" ) # @@ -83,7 +83,7 @@ #end #end // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-settings/src/main/mdo/model-v3.vm b/src/mdo/model-v3.vm similarity index 98% rename from maven-settings/src/main/mdo/model-v3.vm rename to src/mdo/model-v3.vm index 9e06cff9ba59..5eb69dd3ae35 100644 --- a/maven-settings/src/main/mdo/model-v3.vm +++ b/src/mdo/model-v3.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageModelV3}" ) # @@ -82,7 +82,7 @@ #end #end // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/api/maven-api-toolchain/src/main/mdo/model.vm b/src/mdo/model.vm similarity index 99% rename from api/maven-api-toolchain/src/main/mdo/model.vm rename to src/mdo/model.vm index 664064531c64..4a8248ee886b 100644 --- a/api/maven-api-toolchain/src/main/mdo/model.vm +++ b/src/mdo/model.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageModelV4}" ) #set ( $root = $model.getClass( $model.getRoot($version), $version ) ) @@ -85,7 +85,7 @@ #end #end // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-model/src/main/mdo/reader-ex.vm b/src/mdo/reader-ex.vm similarity index 99% rename from maven-model/src/main/mdo/reader-ex.vm rename to src/mdo/reader-ex.vm index f084b41471b3..e92829538000 100644 --- a/maven-model/src/main/mdo/reader-ex.vm +++ b/src/mdo/reader-ex.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Xpp3ReaderEx" ) @@ -29,7 +29,7 @@ # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-model/src/main/mdo/reader.vm b/src/mdo/reader-modified.vm similarity index 99% rename from maven-model/src/main/mdo/reader.vm rename to src/mdo/reader-modified.vm index 8c47409d4cda..8787b8241bb7 100644 --- a/maven-model/src/main/mdo/reader.vm +++ b/src/mdo/reader-modified.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Xpp3Reader" ) @@ -29,7 +29,7 @@ # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-settings/src/main/mdo/reader.vm b/src/mdo/reader.vm similarity index 99% rename from maven-settings/src/main/mdo/reader.vm rename to src/mdo/reader.vm index 02e9199ba8c1..390fec487c45 100644 --- a/maven-settings/src/main/mdo/reader.vm +++ b/src/mdo/reader.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Xpp3Reader" ) @@ -29,7 +29,7 @@ # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-model/src/main/mdo/transformer.vm b/src/mdo/transformer.vm similarity index 98% rename from maven-model/src/main/mdo/transformer.vm rename to src/mdo/transformer.vm index 25a7fe5733a8..34bc3f63ba18 100644 --- a/maven-model/src/main/mdo/transformer.vm +++ b/src/mdo/transformer.vm @@ -16,14 +16,14 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Transformer" ) # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-model/src/main/mdo/writer-ex.vm b/src/mdo/writer-ex.vm similarity index 99% rename from maven-model/src/main/mdo/writer-ex.vm rename to src/mdo/writer-ex.vm index 7eb0e38fad76..4698225d7bef 100644 --- a/maven-model/src/main/mdo/writer-ex.vm +++ b/src/mdo/writer-ex.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Xpp3WriterEx" ) @@ -29,7 +29,7 @@ # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package}; diff --git a/maven-toolchain-model/src/main/mdo/writer.vm b/src/mdo/writer.vm similarity index 99% rename from maven-toolchain-model/src/main/mdo/writer.vm rename to src/mdo/writer.vm index 7b2c805d3607..aa754b73dae1 100644 --- a/maven-toolchain-model/src/main/mdo/writer.vm +++ b/src/mdo/writer.vm @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. *# -#parse ( "src/main/mdo/common.vm" ) +#parse ( "common.vm" ) # #set ( $package = "${packageToolV4}" ) #set ( $className = "${model.name}Xpp3Writer" ) @@ -29,7 +29,7 @@ # #MODELLO-VELOCITY#SAVE-OUTPUT-TO ${package.replace('.','/')}/${className}.java // =================== DO NOT EDIT THIS FILE ==================== -// ${generatedBy} +// Generated by Modello Velocity from ${template} template, any modifications will be overwritten. // ============================================================== package ${package};