[MNG-7836] IT for alternative pom syntax (#276)
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7836AlternativePomSyntaxTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7836AlternativePomSyntaxTest.java
new file mode 100644
index 0000000..f505ffc
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7836AlternativePomSyntaxTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.it;
+
+import java.io.File;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import org.apache.maven.shared.verifier.Verifier;
+import org.apache.maven.shared.verifier.util.ResourceExtractor;
+import org.junit.jupiter.api.Test;
+
+class MavenITmng7836AlternativePomSyntaxTest extends AbstractMavenIntegrationTestCase {
+
+ protected MavenITmng7836AlternativePomSyntaxTest() {
+ // New feature in alpha-8-SNAPSHOT
+ super("(4.0.0-alpha-7,)");
+ }
+
+ @Test
+ void testAlternativeSyntax() throws Exception {
+ File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-7836-alternative-pom-syntax");
+
+ final Verifier pluginVerifier = newVerifier(new File(testDir, "maven-hocon-extension").getPath());
+ pluginVerifier.addCliArgument("clean");
+ pluginVerifier.addCliArgument("install");
+ pluginVerifier.addCliArgument("-V");
+ pluginVerifier.execute();
+ pluginVerifier.verifyErrorFreeLog();
+
+ final Verifier consumerVerifier = newVerifier(new File(testDir, "simple").getPath());
+ consumerVerifier.addCliArgument("clean");
+ consumerVerifier.addCliArgument("install");
+ consumerVerifier.addCliArgument("-Drat.skip=true");
+ consumerVerifier.addCliArgument("-V");
+
+ Path consumerPom = Paths.get(consumerVerifier.getArtifactPath(
+ "org.apache.maven.its.mng-7836", "hocon-simple", "1.0.0-SNAPSHOT", "pom", ""));
+ Path buildPom = Paths.get(consumerVerifier.getArtifactPath(
+ "org.apache.maven.its.mng-7836", "hocon-simple", "1.0.0-SNAPSHOT", "pom", "build"));
+ consumerVerifier.deleteArtifacts("org.apache.maven.its.mng-7836", "hocon-simple", "1.0.0-SNAPSHOT");
+
+ consumerVerifier.execute();
+ consumerVerifier.verifyErrorFreeLog();
+
+ assertTrue(Files.isRegularFile(consumerPom));
+ List<String> consumerPomLines = Files.readAllLines(consumerPom, StandardCharsets.UTF_8);
+ assertFalse(consumerPomLines.stream().anyMatch(l -> l.contains("<name>Apache-2.0</name>")));
+ assertTrue(consumerPomLines.stream().anyMatch(l -> l.contains("<parent>")));
+
+ // The build pom is the original POM, so the hocon file
+ assertTrue(Files.isRegularFile(buildPom));
+ List<String> buildPomLines = Files.readAllLines(buildPom, StandardCharsets.UTF_8);
+ assertTrue(buildPomLines.stream().anyMatch(l -> l.contains("groupId = org.apache.maven.extensions")));
+ }
+}
diff --git a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
index a039462..b21b595 100644
--- a/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
+++ b/core-it-suite/src/test/java/org/apache/maven/it/TestSuiteOrdering.java
@@ -120,10 +120,12 @@
* the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well.
*/
+ suite.addTestSuite(MavenITmng7836AlternativePomSyntaxTest.class);
suite.addTestSuite(MavenITmng7891ConfigurationForExtensionsTest.class);
suite.addTestSuite(MavenITmng6401ProxyPortInterpolationTest.class);
suite.addTestSuite(MavenITmng7228LeakyModelTest.class);
suite.addTestSuite(MavenITmng7819FileLockingWithSnapshotsTest.class);
+ suite.addTestSuite(MavenITmng5659ProjectSettingsTest.class);
suite.addTestSuite(MavenITmng5600DependencyManagementImportExclusionsTest.class);
suite.addTestSuite(MavenITmng7740ConsumerBuildShouldCleanUpOldFilesTest.class);
suite.addTestSuite(MavenITmng7587Jsr330.class);
diff --git a/core-it-suite/src/test/resources-filtered/bootstrap.txt b/core-it-suite/src/test/resources-filtered/bootstrap.txt
index aa936ab..439d9fe 100644
--- a/core-it-suite/src/test/resources-filtered/bootstrap.txt
+++ b/core-it-suite/src/test/resources-filtered/bootstrap.txt
@@ -7,6 +7,7 @@
com.google.code.findbugs:jsr305:1.3.9
com.google.guava:guava:10.0.1
com.thoughtworks.qdox:qdox:2.0-M9
+com.typesafe:config:1.4.2
commons-codec:commons-codec:1.15
commons-lang:commons-lang:2.6
dom4j:dom4j:1.6.1
@@ -17,6 +18,7 @@
org.apache.geronimo.specs:geronimo-jcdi_2.0_spec:1.3
org.apache.groovy:groovy-ant:4.0.6
org.apache.groovy:groovy:4.0.6
+org.apache.maven.extensions:maven-extensions:40:pom
org.apache.maven.its.plugins.class-loader:dep-c:${project.version}
org.apache.maven.its.plugins:maven-it-plugin-active-collection:${project.version}
org.apache.maven.its.plugins:maven-it-plugin-all:${project.version}
@@ -123,6 +125,7 @@
org.apache.maven.shared:maven-shared-utils:3.3.3
org.apache.maven.skins:maven-default-skin:1.3
org.apache.maven.surefire:surefire-junit4:3.0.0-M7
+org.apache.maven.surefire:surefire-junit-platform:3.0.0-M7
org.apache.maven.wagon:wagon-webdav-jackrabbit:2.10
org.apache.maven.wagon:wagon-webdav:1.0-beta-2
org.apache.maven:maven-core:3.8.6
@@ -139,6 +142,7 @@
org.apache.maven:maven-settings:3.1.1
org.apache.maven.plugin-testing:maven-plugin-testing-harness:3.3.0
org.codehaus.gmavenplus:gmavenplus-plugin:1.11.0
+org.codehaus.modello:modello-maven-plugin:2.1.1
org.codehaus.mojo:build-helper-maven-plugin:3.2.0
org.codehaus.mojo:flatten-maven-plugin:1.0.0
org.codehaus.mojo:versions-maven-plugin:2.15.0
@@ -155,15 +159,17 @@
org.codehaus.plexus:plexus-utils:1.5.6
org.codehaus.plexus:plexus-utils:2.0.4
org.codehaus.plexus:plexus-utils:2.0.5
-org.codehaus.plexus:plexus-utils:3.0.10
org.codehaus.plexus:plexus-utils:3.0.9
+org.codehaus.plexus:plexus-utils:3.0.10
org.eclipse.aether:aether-impl:0.9.0.M2
org.eclipse.aether:aether-spi:0.9.0.M2
org.eclipse.sisu:org.eclipse.sisu.inject:0.0.0.M5
org.eclipse.sisu:org.eclipse.sisu.plexus:0.0.0.M5
org.eclipse.sisu:sisu-maven-plugin:0.3.5
org.junit:junit-bom:5.9.1:pom
+org.junit.jupiter:junit-jupiter:5.9.1
org.junit.jupiter:junit-jupiter-engine:5.9.1
+org.junit.platform:junit-platform-launcher:1.9.1
org.ow2.asm:asm:4.1
org.ow2.asm:asm:6.2
org.ow2.asm:asm:7.2
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/pom.xml b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/pom.xml
new file mode 100644
index 0000000..3e9a868
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/pom.xml
@@ -0,0 +1,143 @@
+<?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>
+
+ <groupId>org.apache.maven.its.mng-7836</groupId>
+ <artifactId>maven-hocon-extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <properties>
+ <javaVersion>8</javaVersion>
+ <maven.compiler.source>${javaVersion}</maven.compiler.source>
+ <maven.compiler.target>${javaVersion}</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-spi</artifactId>
+ <version>4.0.0-alpha-8-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-core</artifactId>
+ <version>4.0.0-alpha-8-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.typesafe</groupId>
+ <artifactId>config</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>javax.annotation-api</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>5.9.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>3.3.0</version>
+ <executions>
+ <execution>
+ <id>copy-mdo</id>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-api-model</artifactId>
+ <version>4.0.0-alpha-8-SNAPSHOT</version>
+ <type>mdo</type>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.modello</groupId>
+ <artifactId>modello-maven-plugin</artifactId>
+ <version>2.1.1</version>
+ <executions>
+ <execution>
+ <id>generate-hocon-reader</id>
+ <goals>
+ <goal>velocity</goal>
+ </goals>
+ <phase>generate-sources</phase>
+ <configuration>
+ <version>4.2.0</version>
+ <models>
+ <model>target/dependency/maven-api-model-4.0.0-alpha-8-SNAPSHOT.mdo</model>
+ </models>
+ <templates>
+ <template>src/mdo/hocon-reader.vm</template>
+ </templates>
+ <params>
+ <param>packageModelV4=org.apache.maven.api.model</param>
+ </params>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.eclipse.sisu</groupId>
+ <artifactId>sisu-maven-plugin</artifactId>
+ <version>0.3.5</version>
+ <executions>
+ <execution>
+ <id>index-project</id>
+ <goals>
+ <goal>main-index</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M7</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/main/java/org/apache/maven/hocon/HoconModelReader.java b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/main/java/org/apache/maven/hocon/HoconModelReader.java
new file mode 100644
index 0000000..0a7e55b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/main/java/org/apache/maven/hocon/HoconModelReader.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.hocon;
+
+import javax.annotation.Priority;
+import javax.inject.Named;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.Optional;
+
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.apache.maven.api.model.Model;
+import org.apache.maven.api.services.Source;
+import org.apache.maven.api.spi.ModelParser;
+import org.apache.maven.api.spi.ModelParserException;
+
+@Named("hocon")
+@Priority(1)
+public class HoconModelReader implements ModelParser {
+
+ @Override
+ public Optional<Source> locate(Path path) {
+ Path pom = Files.isDirectory(path) ? path.resolve("pom.hocon") : path;
+ return Files.isRegularFile(pom) ? Optional.of(new PathSource(pom)) : Optional.empty();
+ }
+
+ @Override
+ public Model parse(Source source, Map<String, ?> map) throws ModelParserException {
+ Config config;
+ if (source.getPath() != null) {
+ config = ConfigFactory.parseFile(source.getPath().toFile());
+ } else {
+ try (InputStream input = source.openStream()) {
+ config = ConfigFactory.parseReader(new InputStreamReader(input, StandardCharsets.UTF_8));
+ } catch (IOException e) {
+ throw new ModelParserException("Unable to parse: " + source.getLocation(), e);
+ }
+ }
+ return new HoconReader().parseModel(config.root());
+ }
+}
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/main/java/org/apache/maven/hocon/PathSource.java b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/main/java/org/apache/maven/hocon/PathSource.java
new file mode 100644
index 0000000..c9c55d4
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/main/java/org/apache/maven/hocon/PathSource.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.hocon;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Objects;
+
+import org.apache.maven.api.services.Source;
+
+public class PathSource implements Source {
+
+ private final Path path;
+
+ public PathSource(Path path) {
+ this.path = Objects.requireNonNull(path);
+ }
+
+ @Override
+ public Path getPath() {
+ return path;
+ }
+
+ @Override
+ public InputStream openStream() throws IOException {
+ return Files.newInputStream(path);
+ }
+
+ @Override
+ public String getLocation() {
+ return path.toString();
+ }
+}
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/mdo/hocon-reader.vm b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/mdo/hocon-reader.vm
new file mode 100644
index 0000000..7664db4
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/mdo/hocon-reader.vm
@@ -0,0 +1,202 @@
+#*
+ 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.
+*#
+#set ( $package = "org.apache.maven.hocon" )
+#set ( $className = "HoconReader" )
+#
+#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 ====================
+// Generated by Modello Velocity from ${template}
+// template, any modifications will be overwritten.
+// ==============================================================
+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 java.util.function.Function;
+import java.util.stream.Collectors;
+import org.apache.maven.api.annotations.Generated;
+#foreach ( $class in $model.allClasses )
+import ${packageModelV4}.${class.name};
+#end
+import com.typesafe.config.ConfigList;
+import com.typesafe.config.ConfigObject;
+import com.typesafe.config.ConfigValue;
+import com.typesafe.config.ConfigValueType;
+
+@Generated
+public class ${className} {
+
+#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
+ public ${classUcapName} parse${classUcapName}(ConfigValue value) {
+ if (value instanceof ConfigObject) {
+ ${classUcapName}.Builder ${classLcapName} = ${classUcapName}.newBuilder(true);
+ ((ConfigObject) value).forEach((k, v) -> {
+ switch (k) {
+ #foreach ( $field in $allFields )
+ #if ( ! $Helper.xmlFieldMetadata( $field ).transient && $field.name != "root" )
+ #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}(getStringValue(v));
+ break;
+ #elseif ( $field.type == "boolean" || $field.type == "Boolean" )
+ ${classLcapName}.${field.name}(getBooleanValue(v));
+ break;
+ #elseif ( $field.type == "int" )
+ ${classLcapName}.${field.name}(getIntegerValue(v));
+ break;
+ #elseif ( $field.type == "DOM" )
+// ${classLcapName}.${field.name}(XmlNodeBuilder.build(parser, true));
+ break;
+ #elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
+ ${classLcapName}.${field.name}(getStringList(v));
+ break;
+ #elseif ( $field.type == "java.util.Properties" && $field.to == "String" && $field.multiplicity == "*" )
+ ${classLcapName}.${field.name}(getStringMap(v));
+ break;
+ #elseif ( $field.to && $field.multiplicity == "1" )
+ ${classLcapName}.${field.name}(parse${field.toClass.name}(v));
+ break;
+ #elseif ( $field.to && $field.multiplicity == "*" && $Helper.isFlatItems( $field ) )
+ ${field.name}.add(parse${field.toClass.name}(v));
+ break;
+ #elseif ( $field.to && $field.multiplicity == "*" )
+ ${classLcapName}.${field.name}(getList(v, this::parse${field.toClass.name}));
+ break;
+ #else
+ // TODO: type=${field.type} to=${field.to} multiplicity=${field.multiplicity}
+ break;
+ #end
+ }
+ #end
+ #end
+ default: {
+ checkUnknownElement(k, v);
+ break;
+ }
+ }
+ });
+ #foreach ( $field in $allFields )
+ #if ( $Helper.isFlatItems( $field ) )
+ ${classLcapName}.${field.name}(${field.name});
+ #end
+ #end
+ return ${classLcapName}.build();
+ #if($class.name=="Dependency")
+ } else if (value != null && value.valueType() == ConfigValueType.STRING) {
+ Dependency.Builder dependency = Dependency.newBuilder(true);
+ String[] tokens = ((String) value.unwrapped()).split(":");
+ if (tokens.length < 3 || tokens.length > 5) {
+ throw new RuntimeException("Invalid artifact, you must specify "
+ + "groupId:artifactId:version[:packaging[:classifier]] " + value);
+ }
+ dependency.groupId(tokens[0]);
+ dependency.artifactId(tokens[1]);
+ dependency.version(tokens[2]);
+ if (tokens.length >= 4) {
+ dependency.type(tokens[3]);
+ }
+ if (tokens.length == 5) {
+ dependency.classifier(tokens[4]);
+ }
+ return dependency.build();
+ #end
+ } else if (value != null) {
+ throw new IllegalArgumentException("Invalid syntax: cannot parse: " + value);
+ }
+ return null;
+ }
+
+ #end
+#end
+
+ protected String getStringValue(ConfigValue v) {
+ return v.unwrapped().toString();
+ }
+
+ protected List<String> getStringList(ConfigValue v) {
+ if (v instanceof ConfigList) {
+ return ((ConfigList) v).unwrapped().stream().map(Object::toString)
+ .collect(Collectors.toList());
+ }
+ throw new IllegalArgumentException("Unable to convert to List<String>: '" + v + "'");
+ }
+
+ protected boolean getBooleanValue(ConfigValue v) {
+ return Boolean.parseBoolean(v.unwrapped().toString());
+ }
+
+ protected ConfigList getList(ConfigValue v) {
+ if (v instanceof ConfigList) {
+ return (ConfigList) v;
+ }
+ throw new IllegalArgumentException("Unable to convert to List<?>: '" + v + "'");
+ }
+
+ protected <T> List<T> getList(ConfigValue v, Function<ConfigValue, T> parser) {
+ return getList(v).stream().map(parser).collect(Collectors.toList());
+ }
+
+ protected Map<String, String> getStringMap(ConfigValue v) {
+ if (v instanceof ConfigObject) {
+ return ((ConfigObject) v).entrySet().stream().collect(Collectors.toMap(
+ e -> e.getKey(),
+ e -> getStringValue(e.getValue())
+ ));
+ }
+ throw new IllegalArgumentException("Unable to convert to Map<String, String>: '" + v + "'");
+ }
+
+ protected void checkUnknownElement(String k, Object v) {
+ throw new IllegalArgumentException("Unrecognized element '" + k + "' with value '" + v + "'");
+ }
+
+}
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/test/java/org/apache/maven/hocon/ParsingTest.java b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/test/java/org/apache/maven/hocon/ParsingTest.java
new file mode 100644
index 0000000..6f611af
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/test/java/org/apache/maven/hocon/ParsingTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.hocon;
+
+import java.io.File;
+
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.apache.maven.api.model.Model;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class ParsingTest {
+
+ @Test
+ void testParse() throws Exception {
+ Config config = ConfigFactory.parseFile(new File("src/test/resources/pom.hocon"));
+
+ Model model = new HoconReader().parseModel(config.root());
+
+ assertEquals("40", model.getParent().getVersion());
+ assertEquals(1, model.getDependencies().size());
+ assertEquals(2, model.getProperties().size());
+ }
+}
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/test/resources/pom.hocon b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/test/resources/pom.hocon
new file mode 100644
index 0000000..c51b554
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/maven-hocon-extension/src/test/resources/pom.hocon
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+modelVersion = 4.0.0
+parent {
+ groupId = org.apache.maven.extensions
+ artifactId = maven-extensions
+ version = 40
+}
+groupId = org.apache.maven.extensions
+artifactId = maven-hocon-extension
+version = 1.0.0-SNAPSHOT
+
+properties = {
+ "my.property" = foo
+ pluginVersion = 3.9
+}
+
+dependencies = [
+ { groupId = org.apache.maven, artifactId = maven-api-core, version = 4.0.0-alpha-8-SNAPSHOT }
+]
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/simple/.mvn/extensions.xml b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/simple/.mvn/extensions.xml
new file mode 100644
index 0000000..5c69abc
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/simple/.mvn/extensions.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+<extensions>
+ <extension>
+ <groupId>org.apache.maven.its.mng-7836</groupId>
+ <artifactId>maven-hocon-extension</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </extension>
+</extensions>
diff --git a/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/simple/pom.hocon b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/simple/pom.hocon
new file mode 100644
index 0000000..3164b51
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7836-alternative-pom-syntax/simple/pom.hocon
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+modelVersion = 4.0.0
+parent {
+ groupId = org.apache.maven.extensions
+ artifactId = maven-extensions
+ version = 40
+}
+groupId = org.apache.maven.its.mng-7836
+artifactId = hocon-simple
+version = 1.0.0-SNAPSHOT
+
+properties = {
+ "my.property" = foo
+ pluginVersion = 3.9
+}
+
+dependencies = [
+ # just add one dummy dependency
+ "com.typesafe:config:1.4.2"
+]
\ No newline at end of file