You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/10/14 08:23:56 UTC
[maven] branch master updated (78edd4312 -> 49d1ec166)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
from 78edd4312 [MNG-7106] Accept same lower and upper bound in version spec string (#825)
new c3361ab62 Fix javadoc issues
new 49d1ec166 Restore the serializable aspect of the Model
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../maven/api/annotations/NotThreadSafe.java | 2 +-
.../maven/api/model/ImmutableCollections.java | 17 ++++--
.../org/apache/maven/api/model/InputLocation.java | 15 ++++-
.../org/apache/maven/api/model/InputSource.java | 4 ++
.../org/apache/maven/api/model/package-info.java | 4 +-
api/maven-api-model/src/main/mdo/maven.mdo | 6 +-
api/maven-api-model/src/main/mdo/model.vm | 52 ++++++++++++-----
.../maven/api/settings/ImmutableCollections.java | 13 ++++-
api/maven-api-settings/src/main/mdo/model.vm | 56 +++++++++++++++----
.../maven/api/toolchain/ImmutableCollections.java | 13 ++++-
api/maven-api-toolchain/src/main/mdo/model.vm | 56 +++++++++++++++----
.../java/org/apache/maven/model/BaseObject.java | 3 +-
.../org/apache/maven/model/SerializationTest.java | 65 ++++++++++++++++++++++
maven-model/{ => src/test/resources/xml}/pom.xml | 0
.../plugin/lifecycle/ImmutableCollections.java | 13 ++++-
15 files changed, 261 insertions(+), 58 deletions(-)
create mode 100644 maven-model/src/test/java/org/apache/maven/model/SerializationTest.java
copy maven-model/{ => src/test/resources/xml}/pom.xml (100%)
[maven] 01/02: Fix javadoc issues
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit c3361ab62296f35c5e8149a0633d450747a697c9
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Oct 13 17:35:27 2022 +0200
Fix javadoc issues
---
.../maven/api/annotations/NotThreadSafe.java | 2 +-
.../org/apache/maven/api/model/InputLocation.java | 15 +++++-
.../org/apache/maven/api/model/InputSource.java | 4 ++
.../org/apache/maven/api/model/package-info.java | 4 +-
api/maven-api-model/src/main/mdo/maven.mdo | 6 +--
api/maven-api-model/src/main/mdo/model.vm | 52 +++++++++++++++-----
api/maven-api-settings/src/main/mdo/model.vm | 56 +++++++++++++++++-----
api/maven-api-toolchain/src/main/mdo/model.vm | 56 +++++++++++++++++-----
8 files changed, 152 insertions(+), 43 deletions(-)
diff --git a/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java
index ae4a6286f..b33381dd7 100644
--- a/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java
+++ b/api/maven-api-meta/src/main/java/org/apache/maven/api/annotations/NotThreadSafe.java
@@ -26,7 +26,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * This annotation indicates that the annotated type is <bold>not</bold> threadsafe
+ * This annotation indicates that the annotated type is <strong>not</strong> threadsafe
* and should only be used by a single thread.
*
* @see ThreadSafe
diff --git a/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java b/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java
index 5aff705b0..8be05dbaa 100644
--- a/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java
+++ b/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java
@@ -97,7 +97,12 @@ public class InputLocation
}
/**
- * Method merge.
+ * Merges the {@code source} location into the {@code target} location.
+ *
+ * @param target the target location
+ * @param source the source location
+ * @param sourceDominant the boolean indicating of {@code source} is dominant compared to {@code target}
+ * @return the merged location
*/
public static InputLocation merge( InputLocation target, InputLocation source, boolean sourceDominant )
{
@@ -132,7 +137,13 @@ public class InputLocation
} //-- InputLocation merge( InputLocation, InputLocation, boolean )
/**
- * Method merge.
+ * Merges the {@code source} location into the {@code target} location.
+ * This method is used when the locations refer to lists and also merges the indices.
+ *
+ * @param target the target location
+ * @param source the source location
+ * @param indices the list of integers for the indices
+ * @return the merged location
*/
public static InputLocation merge( InputLocation target, InputLocation source, Collection<Integer> indices )
{
diff --git a/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputSource.java b/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputSource.java
index 34c8bf642..37cb13c1f 100644
--- a/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputSource.java
+++ b/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputSource.java
@@ -39,6 +39,8 @@ public class InputSource
/**
* Get the path/URL of the POM or {@code null} if unknown.
+ *
+ * @return the location
*/
public String getLocation()
{
@@ -47,6 +49,8 @@ public class InputSource
/**
* Get the identifier of the POM in the format {@code <groupId>:<artifactId>:<version>}.
+ *
+ * @return the model id
*/
public String getModelId()
{
diff --git a/api/maven-api-model/src/main/java/org/apache/maven/api/model/package-info.java b/api/maven-api-model/src/main/java/org/apache/maven/api/model/package-info.java
index bfcdbe273..0924cab90 100644
--- a/api/maven-api-model/src/main/java/org/apache/maven/api/model/package-info.java
+++ b/api/maven-api-model/src/main/java/org/apache/maven/api/model/package-info.java
@@ -1,7 +1,7 @@
// CHECKSTYLE_OFF: RegexpHeader
/**
* Maven POM (Project Object Model) classes, generated from <code>maven.mdo</code> model.
- * The root class is {@link org.apache.maven.model.Model}.
+ * The root class is {@link org.apache.maven.api.model.Model}.
*/
package org.apache.maven.api.model;
@@ -22,4 +22,4 @@ package org.apache.maven.api.model;
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
\ No newline at end of file
+ */
diff --git a/api/maven-api-model/src/main/mdo/maven.mdo b/api/maven-api-model/src/main/mdo/maven.mdo
index 7bd835d09..8e6f14665 100644
--- a/api/maven-api-model/src/main/mdo/maven.mdo
+++ b/api/maven-api-model/src/main/mdo/maven.mdo
@@ -629,7 +629,7 @@
/**
* @return a Map of plugins field with {@code Plugins#getKey()} as key
- * @see org.apache.maven.model.Plugin#getKey()
+ * @see Plugin#getKey()
*/
public synchronized Map<String, Plugin> getPluginsAsMap()
{
@@ -2281,7 +2281,7 @@
}
/**
* @return a Map of executions field with {@code PluginExecution#getId()} as key
- * @see org.apache.maven.model.PluginExecution#getId()
+ * @see PluginExecution#getId()
*/
public java.util.Map<String, PluginExecution> getExecutionsAsMap()
{
@@ -2884,7 +2884,7 @@
/**
* @return a Map of reportSets field with {@code ReportSet#getId()} as key
- * @see org.apache.maven.model.ReportSet#getId()
+ * @see ReportSet#getId()
*/
public java.util.Map<String, ReportSet> getReportSetsAsMap()
{
diff --git a/api/maven-api-model/src/main/mdo/model.vm b/api/maven-api-model/src/main/mdo/model.vm
index 9240aeecd..60f013dc1 100644
--- a/api/maven-api-model/src/main/mdo/model.vm
+++ b/api/maven-api-model/src/main/mdo/model.vm
@@ -47,13 +47,13 @@
#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 + ">" ) )
+ #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<String, String>" ) )
+ #set ( $dummy = $imports.add( "java.util.Map" ) )
+ #set ( $dummy = $types.put( $field, "Map<String, String>" ) )
#elseif ( $field.type == "DOM" )
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
#set ( $dummy = $types.put( $field, "Dom" ) )
@@ -245,6 +245,8 @@ public class ${class.name}
#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
@@ -285,6 +287,8 @@ public class ${class.name}
#end
/**
* Creates a new builder with this object as the basis.
+ *
+ * @return a {@code Builder}
*/
@Nonnull
public Builder with()
@@ -297,7 +301,12 @@ public class ${class.name}
#if ( $type.startsWith("List<") )
#set ( $type = ${type.replace('List<','Collection<')} )
#end
- /** Creates a new ${class.name} instance using the specified ${field.name}. */
+ /**
+ * 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 )
{
@@ -306,9 +315,11 @@ public class ${class.name}
#end
/**
- * Creates a new ${class.name} instance.
+ * 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()
@@ -317,8 +328,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} instance using default values or not.
+ * 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 )
@@ -327,9 +341,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance.
+ * 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()
@@ -338,7 +354,10 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using default values or not.
+ * 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 )
@@ -347,8 +366,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using the specified object as a basis.
+ * 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 )
@@ -357,7 +379,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using the specified object as a basis.
+ * 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 )
diff --git a/api/maven-api-settings/src/main/mdo/model.vm b/api/maven-api-settings/src/main/mdo/model.vm
index a547db349..60f013dc1 100644
--- a/api/maven-api-settings/src/main/mdo/model.vm
+++ b/api/maven-api-settings/src/main/mdo/model.vm
@@ -245,6 +245,8 @@ public class ${class.name}
#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
@@ -285,6 +287,8 @@ public class ${class.name}
#end
/**
* Creates a new builder with this object as the basis.
+ *
+ * @return a {@code Builder}
*/
@Nonnull
public Builder with()
@@ -297,7 +301,12 @@ public class ${class.name}
#if ( $type.startsWith("List<") )
#set ( $type = ${type.replace('List<','Collection<')} )
#end
- /** Creates a new ${class.name} instance using the specified ${field.name}. */
+ /**
+ * 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 )
{
@@ -306,9 +315,11 @@ public class ${class.name}
#end
/**
- * Creates a new ${class.name} instance.
+ * 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()
@@ -317,8 +328,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} instance using default values or not.
+ * 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 )
@@ -327,9 +341,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance.
+ * 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()
@@ -338,7 +354,10 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using default values or not.
+ * 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 )
@@ -347,8 +366,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using the specified object as a basis.
+ * 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 )
@@ -357,7 +379,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using the specified object as a basis.
+ * 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 )
@@ -485,11 +511,19 @@ public class ${class.name}
return base;
}
#if ( $locationTracking )
- Map<Object, InputLocation> locations = new HashMap<>( this.locations != null ? this.locations : ( base != null ? base.locations : Collections.emptyMap() ) );
- InputLocation location = locations.remove( "" );
+ Map<Object, InputLocation> 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 )
- InputLocation ${field.name}Location = locations.remove( "${field.name}" );
+ ${field.name}Location = locations.remove( "${field.name}" );
#end
+ }
#end
return new ${class.name}(
#if ( $class == $root )
@@ -504,7 +538,7 @@ public class ${class.name}
#end
#end
#if ( $locationTracking )
- locations,
+ 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 )
diff --git a/api/maven-api-toolchain/src/main/mdo/model.vm b/api/maven-api-toolchain/src/main/mdo/model.vm
index a547db349..60f013dc1 100644
--- a/api/maven-api-toolchain/src/main/mdo/model.vm
+++ b/api/maven-api-toolchain/src/main/mdo/model.vm
@@ -245,6 +245,8 @@ public class ${class.name}
#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
@@ -285,6 +287,8 @@ public class ${class.name}
#end
/**
* Creates a new builder with this object as the basis.
+ *
+ * @return a {@code Builder}
*/
@Nonnull
public Builder with()
@@ -297,7 +301,12 @@ public class ${class.name}
#if ( $type.startsWith("List<") )
#set ( $type = ${type.replace('List<','Collection<')} )
#end
- /** Creates a new ${class.name} instance using the specified ${field.name}. */
+ /**
+ * 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 )
{
@@ -306,9 +315,11 @@ public class ${class.name}
#end
/**
- * Creates a new ${class.name} instance.
+ * 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()
@@ -317,8 +328,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} instance using default values or not.
+ * 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 )
@@ -327,9 +341,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance.
+ * 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()
@@ -338,7 +354,10 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using default values or not.
+ * 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 )
@@ -347,8 +366,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using the specified object as a basis.
+ * 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 )
@@ -357,7 +379,11 @@ public class ${class.name}
}
/**
- * Creates a new ${class.name} builder instance using the specified object as a basis.
+ * 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 )
@@ -485,11 +511,19 @@ public class ${class.name}
return base;
}
#if ( $locationTracking )
- Map<Object, InputLocation> locations = new HashMap<>( this.locations != null ? this.locations : ( base != null ? base.locations : Collections.emptyMap() ) );
- InputLocation location = locations.remove( "" );
+ Map<Object, InputLocation> 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 )
- InputLocation ${field.name}Location = locations.remove( "${field.name}" );
+ ${field.name}Location = locations.remove( "${field.name}" );
#end
+ }
#end
return new ${class.name}(
#if ( $class == $root )
@@ -504,7 +538,7 @@ public class ${class.name}
#end
#end
#if ( $locationTracking )
- locations,
+ 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 )
[maven] 02/02: Restore the serializable aspect of the Model
Posted by gn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 49d1ec1668448528e0bc96bc3410144e0334002e
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Oct 14 10:20:25 2022 +0200
Restore the serializable aspect of the Model
---
.../maven/api/model/ImmutableCollections.java | 17 ++-
.../maven/api/settings/ImmutableCollections.java | 13 ++-
.../maven/api/toolchain/ImmutableCollections.java | 13 ++-
.../java/org/apache/maven/model/BaseObject.java | 3 +-
.../org/apache/maven/model/SerializationTest.java | 65 +++++++++++
maven-model/src/test/resources/xml/pom.xml | 123 +++++++++++++++++++++
.../plugin/lifecycle/ImmutableCollections.java | 13 ++-
7 files changed, 232 insertions(+), 15 deletions(-)
diff --git a/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java b/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java
index 35c98d6e7..e47fa1a8b 100644
--- a/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java
+++ b/api/maven-api-model/src/main/java/org/apache/maven/api/model/ImmutableCollections.java
@@ -19,6 +19,7 @@ package org.apache.maven.api.model;
* under the License.
*/
+import java.io.Serializable;
import java.util.AbstractList;
import java.util.AbstractMap;
import java.util.AbstractSet;
@@ -251,7 +252,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableList<E> extends AbstractList<E> implements RandomAccess
+ private abstract static class AbstractImmutableList<E>
+ extends AbstractList<E>
+ implements RandomAccess, Serializable
{
@Override
public boolean add( E e )
@@ -541,7 +544,7 @@ class ImmutableCollections
private static class Map1<K, V> extends AbstractImmutableMap<K, V>
{
- private final Map.Entry<K, V> entry;
+ private final Entry<K, V> entry;
private Map1( K key, V value )
{
@@ -618,7 +621,7 @@ class ImmutableCollections
{
if ( index < entries.length )
{
- return ( Map.Entry<K, V> ) entries[index++];
+ return ( Entry<K, V> ) entries[index++];
}
throw new NoSuchElementException();
}
@@ -634,7 +637,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableMap<K, V> extends AbstractMap<K, V>
+ private abstract static class AbstractImmutableMap<K, V>
+ extends AbstractMap<K, V>
+ implements Serializable
{
@Override
public void replaceAll( BiFunction<? super K, ? super V, ? extends V> function )
@@ -691,7 +696,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableSet<E> extends AbstractSet<E>
+ private abstract static class AbstractImmutableSet<E>
+ extends AbstractSet<E>
+ implements Serializable
{
@Override
public boolean removeAll( Collection<?> c )
diff --git a/api/maven-api-settings/src/main/java/org/apache/maven/api/settings/ImmutableCollections.java b/api/maven-api-settings/src/main/java/org/apache/maven/api/settings/ImmutableCollections.java
index 850e0ef66..bdd5567b8 100644
--- a/api/maven-api-settings/src/main/java/org/apache/maven/api/settings/ImmutableCollections.java
+++ b/api/maven-api-settings/src/main/java/org/apache/maven/api/settings/ImmutableCollections.java
@@ -19,6 +19,7 @@ package org.apache.maven.api.settings;
* under the License.
*/
+import java.io.Serializable;
import java.util.AbstractList;
import java.util.AbstractMap;
import java.util.AbstractSet;
@@ -251,7 +252,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableList<E> extends AbstractList<E> implements RandomAccess
+ private abstract static class AbstractImmutableList<E>
+ extends AbstractList<E>
+ implements RandomAccess, Serializable
{
@Override
public boolean add( E e )
@@ -634,7 +637,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableMap<K, V> extends AbstractMap<K, V>
+ private abstract static class AbstractImmutableMap<K, V>
+ extends AbstractMap<K, V>
+ implements Serializable
{
@Override
public void replaceAll( BiFunction<? super K, ? super V, ? extends V> function )
@@ -691,7 +696,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableSet<E> extends AbstractSet<E>
+ private abstract static class AbstractImmutableSet<E>
+ extends AbstractSet<E>
+ implements Serializable
{
@Override
public boolean removeAll( Collection<?> c )
diff --git a/api/maven-api-toolchain/src/main/java/org/apache/maven/api/toolchain/ImmutableCollections.java b/api/maven-api-toolchain/src/main/java/org/apache/maven/api/toolchain/ImmutableCollections.java
index 934a40331..8e95ea98c 100644
--- a/api/maven-api-toolchain/src/main/java/org/apache/maven/api/toolchain/ImmutableCollections.java
+++ b/api/maven-api-toolchain/src/main/java/org/apache/maven/api/toolchain/ImmutableCollections.java
@@ -19,6 +19,7 @@ package org.apache.maven.api.toolchain;
* under the License.
*/
+import java.io.Serializable;
import java.util.AbstractList;
import java.util.AbstractMap;
import java.util.AbstractSet;
@@ -251,7 +252,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableList<E> extends AbstractList<E> implements RandomAccess
+ private abstract static class AbstractImmutableList<E>
+ extends AbstractList<E>
+ implements RandomAccess, Serializable
{
@Override
public boolean add( E e )
@@ -634,7 +637,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableMap<K, V> extends AbstractMap<K, V>
+ private abstract static class AbstractImmutableMap<K, V>
+ extends AbstractMap<K, V>
+ implements Serializable
{
@Override
public void replaceAll( BiFunction<? super K, ? super V, ? extends V> function )
@@ -691,7 +696,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableSet<E> extends AbstractSet<E>
+ private abstract static class AbstractImmutableSet<E>
+ extends AbstractSet<E>
+ implements Serializable
{
@Override
public boolean removeAll( Collection<?> c )
diff --git a/maven-model/src/main/java/org/apache/maven/model/BaseObject.java b/maven-model/src/main/java/org/apache/maven/model/BaseObject.java
index 69536fd4a..de1bd2df9 100644
--- a/maven-model/src/main/java/org/apache/maven/model/BaseObject.java
+++ b/maven-model/src/main/java/org/apache/maven/model/BaseObject.java
@@ -24,7 +24,8 @@ import java.io.Serializable;
public abstract class BaseObject
implements Serializable, Cloneable, InputLocationTracker
{
- protected ChildrenTracking childrenTracking;
+ protected transient ChildrenTracking childrenTracking;
+
protected Object delegate;
public BaseObject()
diff --git a/maven-model/src/test/java/org/apache/maven/model/SerializationTest.java b/maven-model/src/test/java/org/apache/maven/model/SerializationTest.java
new file mode 100644
index 000000000..311b987e7
--- /dev/null
+++ b/maven-model/src/test/java/org/apache/maven/model/SerializationTest.java
@@ -0,0 +1,65 @@
+package org.apache.maven.model;
+
+/*
+ * 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.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class SerializationTest
+{
+
+ @Test
+ public void testModelSerialization()
+ throws Exception
+ {
+ Model model;
+ try ( InputStream is = getClass().getResourceAsStream( "/xml/pom.xml" ) )
+ {
+ model = new MavenXpp3Reader().read( is );
+ }
+
+ // Serialize an inner child here so that the BaseObject.childrenTracking is non null
+ Build build = model.getBuild();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try( ObjectOutputStream oos = new ObjectOutputStream( baos ) )
+ {
+ oos.writeObject( build );
+ }
+
+ Build build2;
+ ByteArrayInputStream bais = new ByteArrayInputStream( baos.toByteArray() );
+ try( ObjectInputStream ois = new ObjectInputStream( bais ) )
+ {
+ build2 = (Build) ois.readObject();
+ }
+
+ assertNotNull( build2 );
+ }
+
+}
diff --git a/maven-model/src/test/resources/xml/pom.xml b/maven-model/src/test/resources/xml/pom.xml
new file mode 100644
index 000000000..01b679687
--- /dev/null
+++ b/maven-model/src/test/resources/xml/pom.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>maven-model</artifactId>
+
+ <name>Maven Model</name>
+ <description>Model for Maven POM (Project Object Model)</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-model</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-xml-impl</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.2.0</version>
+ <executions>
+ <execution>
+ <id>copy-model</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-model</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ <type>mdo</type>
+ <outputDirectory>target/mdo/</outputDirectory>
+ <destFileName>maven.mdo</destFileName>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>modello-plugin-velocity</artifactId>
+ <version>4.0.0-alpha-1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>velocity</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>velocity</goal>
+ </goals>
+ <configuration>
+ <version>4.0.0</version>
+ <models>
+ <model>target/mdo/maven.mdo</model>
+ </models>
+ <templates>
+ <template>src/main/mdo/model-v3.vm</template>
+ <template>src/main/mdo/merger.vm</template>
+ <template>src/main/mdo/transformer.vm</template>
+ <template>src/main/mdo/reader.vm</template>
+ <template>src/main/mdo/reader-ex.vm</template>
+ <template>src/main/mdo/writer.vm</template>
+ <template>src/main/mdo/writer-ex.vm</template>
+ </templates>
+ <params>
+ <param>packageModelV3=org.apache.maven.model</param>
+ <param>packageModelV4=org.apache.maven.api.model</param>
+ <param>packageToolV4=org.apache.maven.model.v4</param>
+ </params>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>**/package-info.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/lifecycle/ImmutableCollections.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/lifecycle/ImmutableCollections.java
index 4479e4113..875b0b22f 100644
--- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/lifecycle/ImmutableCollections.java
+++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/lifecycle/ImmutableCollections.java
@@ -19,6 +19,7 @@ package org.apache.maven.plugin.lifecycle;
* under the License.
*/
+import java.io.Serializable;
import java.util.AbstractList;
import java.util.AbstractMap;
import java.util.AbstractSet;
@@ -251,7 +252,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableList<E> extends AbstractList<E> implements RandomAccess
+ private abstract static class AbstractImmutableList<E>
+ extends AbstractList<E>
+ implements RandomAccess, Serializable
{
@Override
public boolean add( E e )
@@ -634,7 +637,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableMap<K, V> extends AbstractMap<K, V>
+ private abstract static class AbstractImmutableMap<K, V>
+ extends AbstractMap<K, V>
+ implements Serializable
{
@Override
public void replaceAll( BiFunction<? super K, ? super V, ? extends V> function )
@@ -691,7 +696,9 @@ class ImmutableCollections
}
}
- private abstract static class AbstractImmutableSet<E> extends AbstractSet<E>
+ private abstract static class AbstractImmutableSet<E>
+ extends AbstractSet<E>
+ implements Serializable
{
@Override
public boolean removeAll( Collection<?> c )