<?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 http://maven.apache.org/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.camel</groupId>
    <artifactId>tooling</artifactId>
    <version>2.25.4</version>
  </parent>

  <!-- should not be OSGi bundle as we shade this component into camel-core and camel-catalog -->

  <artifactId>json-simple-ordered</artifactId>
  <name>Camel :: JSon Simple Ordered</name>
  <description>A patched json-simple parser that preserves the ordering in Map as read from JSon source</description>

  <!-- TODO: this is only needed until https://github.com/cliftonlabs/json-simple/issues/17 is fixed and released -->

  <dependencies>

    <!-- json parser -->
    <dependency>
      <groupId>com.github.cliftonlabs</groupId>
      <artifactId>json-simple</artifactId>
      <version>${json-simple2-version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <id>unpack-source</id>
            <phase>initialize</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <classifier>sources</classifier>
              <includeGroupIds>com.github.cliftonlabs</includeGroupIds>
              <outputDirectory>src/main/java</outputDirectory>
              <excludes>META-INF/**,**/JSONArray.java,**/JSONObject.java</excludes>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- patch json-simple -->
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>1.5.3</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includes>
            <include>${basedir}/src/main/java/org/json/simple/JsonObject.java</include>
          </includes>
          <replacements>
            <replacement>
              <token>import java.util.HashMap;</token>
              <value>import java.util.LinkedHashMap;</value>
            </replacement>
            <replacement>
              <token>public class JsonObject extends HashMap</token>
              <value>public class JsonObject extends LinkedHashMap</value>
            </replacement>
          </replacements>
        </configuration>
      </plugin>

    </plugins>

  </build>

</project>
