Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/it/projects/evaluate-model-collections/invoker.properties
Original file line number Diff line number Diff line change
@@ -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+
28 changes: 28 additions & 0 deletions src/it/projects/evaluate-model-collections/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.help</groupId>
<artifactId>evaluate-model-collections</artifactId>
<version>1.0</version>
</project>
18 changes: 18 additions & 0 deletions src/it/projects/evaluate-model-collections/test.properties
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions src/it/projects/evaluate-model-collections/verify.groovy
Original file line number Diff line number Diff line change
@@ -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('<resources>')
assert result.contains('<directory>' + new File(basedir, 'src/main/resources').absolutePath + '</directory>')
19 changes: 17 additions & 2 deletions src/main/java/org/apache/maven/plugins/help/EvaluateMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
Expand All @@ -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
Expand Down
Loading