diff --git a/src/it/projects/evaluate-model-collections/invoker.properties b/src/it/projects/evaluate-model-collections/invoker.properties
new file mode 100644
index 00000000..c8086734
--- /dev/null
+++ b/src/it/projects/evaluate-model-collections/invoker.properties
@@ -0,0 +1,19 @@
+# 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.
+
+invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:evaluate
+invoker.maven.version = 4+
diff --git a/src/it/projects/evaluate-model-collections/pom.xml b/src/it/projects/evaluate-model-collections/pom.xml
new file mode 100644
index 00000000..8231a792
--- /dev/null
+++ b/src/it/projects/evaluate-model-collections/pom.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+ 4.0.0
+
+ org.apache.maven.its.help
+ evaluate-model-collections
+ 1.0
+
diff --git a/src/it/projects/evaluate-model-collections/test.properties b/src/it/projects/evaluate-model-collections/test.properties
new file mode 100644
index 00000000..afcf63bb
--- /dev/null
+++ b/src/it/projects/evaluate-model-collections/test.properties
@@ -0,0 +1,18 @@
+# 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.
+
+expression = project.build.resources
diff --git a/src/it/projects/evaluate-model-collections/verify.groovy b/src/it/projects/evaluate-model-collections/verify.groovy
new file mode 100644
index 00000000..cefa26ba
--- /dev/null
+++ b/src/it/projects/evaluate-model-collections/verify.groovy
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+def result = new File(basedir, 'build.log').text
+
+assert result.contains('')
+assert result.contains('' + new File(basedir, 'src/main/resources').absolutePath + '')
diff --git a/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java b/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
index 163a37f8..111c7567 100644
--- a/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
+++ b/src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
+import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -35,6 +36,8 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.MarshallingContext;
+import com.thoughtworks.xstream.converters.collections.CollectionConverter;
+import com.thoughtworks.xstream.converters.collections.MapConverter;
import com.thoughtworks.xstream.converters.collections.PropertiesConverter;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import org.apache.maven.execution.MavenSession;
@@ -345,12 +348,12 @@ private String toXML(String expr, Object obj) {
Object elt = list.iterator().next();
String name = StringUtils.lowercaseFirstLetter(elt.getClass().getSimpleName());
- currentXStream.alias(pluralize(name), List.class);
+ currentXStream.alias(pluralize(name), list.getClass());
} else {
// try to detect the alias from question
if (expr.indexOf('.') != -1) {
String name = expr.substring(expr.indexOf('.') + 1, expr.indexOf('}'));
- currentXStream.alias(name, List.class);
+ currentXStream.alias(name, list.getClass());
}
}
}
@@ -364,6 +367,18 @@ private String toXML(String expr, Object obj) {
private XStream getXStream() {
if (xstream == null) {
xstream = new XStream();
+ xstream.registerConverter(new CollectionConverter(xstream.getMapper()) {
+ @Override
+ public boolean canConvert(Class type) {
+ return Collection.class.isAssignableFrom(type);
+ }
+ });
+ xstream.registerConverter(new MapConverter(xstream.getMapper()) {
+ @Override
+ public boolean canConvert(Class type) {
+ return Map.class.isAssignableFrom(type);
+ }
+ });
addAlias(xstream);
// handle Properties a la Maven