<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright 2015 herd contributors

  Licensed 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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.finra.herd</groupId>
    <artifactId>herd-code</artifactId>
    <version>0.158.0</version>
  </parent>
  <groupId>org.finra.herd</groupId>
  <artifactId>herd-sdk-common</artifactId>
  <version>0.158.0</version>
  <packaging>pom</packaging>
  <name>herd sdk common</name>
  <description>This project contains swagger generated clients that invoke the herd REST API's.</description>
  <url>http://finraos.github.io/herd/</url>
  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <modules>
    <module>herd-sdk</module>
    <module>herd-sdk-ext</module>
  </modules>
  <properties>
    <swagger.spec.path>${project.build.directory}/generated-resources/herd-docs-swagger-${project.version}/docs/rest/${swagger.spec.name}</swagger.spec.path>
    <maven.replacer.plugin.version>1.5.3</maven.replacer.plugin.version>
    <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
    <swagger.spec.name>herd.swagger.yaml</swagger.spec.name>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.finra.herd</groupId>
      <artifactId>herd-sdk-resources</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey.contribs</groupId>
      <artifactId>jersey-multipart</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${apache.spark.jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>${apache.spark.jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${apache.spark.jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.jaxrs</groupId>
      <artifactId>jackson-jaxrs-json-provider</artifactId>
      <version>${apache.spark.jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-joda</artifactId>
      <version>${apache.spark.jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
    </dependency>
    <dependency>
      <groupId>com.brsanthu</groupId>
      <artifactId>migbase64</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.commonjava.maven.plugins</groupId>
        <artifactId>directory-maven-plugin</artifactId>
        <version>0.1</version>
        <executions>
          <execution>
            <id>directories</id>
            <phase>initialize</phase>
            <goals>
              <goal>directory-of</goal>
            </goals>
            <configuration>
              <property>herd-sdk-common.basedir</property>
              <project>
                <groupId>org.finra.herd</groupId>
                <artifactId>herd-sdk-common</artifactId>
              </project>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-remote-resources-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>process-remote-resources</id>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <resourceBundles>
                <resourceBundle>org.finra.herd:herd-sdk-resources:${project.version}</resourceBundle>
              </resourceBundles>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-shared-resources</id>
            <phase>initialize</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>herd-docs-swagger</artifactId>
                  <version>${project.version}</version>
                  <type>zip</type>
                  <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
                  <includes>**/${swagger.spec.name}</includes>
                </artifactItem>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>herd-docs-swagger-new</artifactId>
                  <version>${project.version}</version>
                  <type>zip</type>
                  <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
                  <includes>**/${swagger.spec.name}</includes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>herd-docs-swagger</artifactId>
            <version>${project.version}</version>
          </dependency>
          <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>herd-docs-swagger-new</artifactId>
            <version>${project.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>JAVA-Generation</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${swagger.spec.path}</inputSpec>
              <output>${project.build.directory}/generated-sources/swagger</output>
              <addCompileSourceRoot>false</addCompileSourceRoot>
              <generatorName>java</generatorName>
              <apiPackage>org.finra.herd.sdk.api</apiPackage>
              <modelPackage>org.finra.herd.sdk.model</modelPackage>
              <invokerPackage>org.finra.herd.sdk.invoker</invokerPackage>
              <generateApiTests>false</generateApiTests>
              <generateModelTests>false</generateModelTests>
              <generateApiDocumentation>false</generateApiDocumentation>
              <generateModelDocumentation>false</generateModelDocumentation>
              <configOptions>
                <licenseName>Apache-2.0</licenseName>
                <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
                <library>jersey1</library>
                <dateLibrary>joda</dateLibrary>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>SCALA-Generation</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${swagger.spec.path}</inputSpec>
              <output>${project.build.directory}/scala-client</output>
              <addCompileSourceRoot>false</addCompileSourceRoot>
              <generatorName>scala-httpclient</generatorName>
              <apiPackage>org.finra.herd.sdk.api</apiPackage>
              <modelPackage>org.finra.herd.sdk.model</modelPackage>
              <invokerPackage>org.finra.herd.sdk.invoker</invokerPackage>
              <configOptions>
                <licenseName>Apache-2.0</licenseName>
                <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
                <library>jersey1</library>
                <dateLibrary>joda</dateLibrary>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>Node-Generation</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${swagger.spec.path}</inputSpec>
              <output>${project.build.directory}/node-client</output>
              <generatorName>typescript-node</generatorName>
            </configuration>
          </execution>
          <execution>
            <id>AngularJS-Generation</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${swagger.spec.path}</inputSpec>
              <output>${project.build.directory}/angularjs-client</output>
              <generatorName>typescript-angularjs</generatorName>
            </configuration>
          </execution>
          <execution>
            <id>Angular-Generation</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${swagger.spec.path}</inputSpec>
              <output>${project.build.directory}/angular-client</output>
              <generatorName>typescript-angular</generatorName>
              <configOptions>
                <ngVersion>6.1.2</ngVersion>
                <providedInRoot>true</providedInRoot>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>Python-Generation</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${swagger.spec.path}</inputSpec>
              <output>${project.build.directory}/python-client</output>
              <generatorName>python</generatorName>
              <configOptions>
                <packageName>herdsdk</packageName>
                <projectName>herdsdk</projectName>
                <packageVersion>${herd.sdk.version}</packageVersion>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>${maven.replacer.plugin.version}</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>replace</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includes>
            <include>${project.build.directory}/generated-sources/swagger/**/*/ApiClient.java</include>
          </includes>
          <replacements>
            <replacement>
              <token>ClientResponse response = getAPIResponse</token>
              <valueFile>${herd-sdk-common.basedir}/src/main/resources/replacement.txt</valueFile>
            </replacement>
          </replacements>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/swagger/src/main/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includes>
            <include>**/*.java</include>
          </includes>
          <excludes>
            <excludes>swagger/src/main/java/**</excludes>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
          <execution>
            <id>jar</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <sourcepath>${project.build.directory}/generated-sources/swagger/src/main/java</sourcepath>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>replace-herd-sdk-version</id>
            <phase>initialize</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <replace dir="${herd-sdk-common.basedir}/src/main/resources/" value="${project.version}" token="VERSION">
                  <include name="replacement.txt" />
                </replace>
              </tasks>
            </configuration>
          </execution>
          <execution>
            <id>copy-angular-ts-config</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy todir="${project.build.directory}/angular-client" overwrite="true">
                  <fileset dir="${project.build.directory}/maven-shared-archive-resources/tsconfig/angular" />
                  <filterset>
                    <filter value="${project.version}.${maven.build.timestamp}" token="NPM_VERSION" />
                  </filterset>
                </copy>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>copy-angularjs-ts-config</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy todir="${project.build.directory}/angularjs-client" overwrite="true">
                  <fileset dir="${project.build.directory}/maven-shared-archive-resources/tsconfig/angularjs" />
                  <filterset>
                    <filter value="${project.version}.${maven.build.timestamp}" token="NPM_VERSION" />
                  </filterset>
                </copy>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>copy-node-ts-config</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy todir="${project.build.directory}/node-client" overwrite="true">
                  <fileset dir="${project.build.directory}/maven-shared-archive-resources/tsconfig/node" />
                  <filterset>
                    <filter value="${project.version}.${maven.build.timestamp}" token="NPM_VERSION" />
                  </filterset>
                </copy>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
