<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>net.leanix</groupId>
    <artifactId>leanix-sdk-java</artifactId>
    <packaging>jar</packaging>

    <version>2.1.3</version>

    <parent>
        <groupId>net.leanix.poms</groupId>
        <artifactId>sdk-parent</artifactId>
        <version>0.9.9</version>
        <relativePath />
    </parent>

    <name>leanix-sdk-java</name>

    <description>SDK for Java to access leanIX REST API</description>

    <url>https://dev.leanix.net</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <url>https://github.com/leanix/leanix-sdk-java</url>
        <connection>scm:git:git@github.com:leanix/leanix-sdk-java.git</connection>
        <developerConnection>scm:git:git@github.com:leanix/leanix-sdk-java.git</developerConnection>
    </scm>

    <developers>
        <developer>
            <id>andrechrist</id>
            <name>Andre Christ</name>
            <email>andre.christ@leanix.net</email>
            <url>https://www.leanix.net</url>
            <organization>LeanIX GmbH</organization>
            <organizationUrl>https://www.leanix.net</organizationUrl>
        </developer>
    </developers>

    <properties>
        <downloadSources>true</downloadSources>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- properties related to sdk code generation -->
        <leanix-dropkit-sdk-utils-version>1.0.3</leanix-dropkit-sdk-utils-version>
        <codegenHost>test-app.leanix.net</codegenHost>
        <swagger-inputSpec>https://${codegenHost}/demo/api/v1/api-docs/</swagger-inputSpec>

    </properties>

    <dependencies>

        <!-- Testing -->
        <dependency>
            <groupId>net.leanix</groupId>
            <artifactId>leanix-mtm-sdk-java</artifactId>
            <version>1.6.1</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>performTests</id>
            <activation>
                <property>
                    <name>api.hostname</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>codegen</id>
            <build>
                <plugins>

                    <!-- 1) generate api using the swagger-codegen-maven-plugin -->
                    <plugin>
                        <groupId>io.swagger</groupId>
                        <artifactId>swagger-codegen-maven-plugin</artifactId>
                        <version>2.1.6</version>
                        <configuration>
                            <inputSpec>${swagger-inputSpec}</inputSpec>
                            <language>java</language>
                            <apiPackage>net.leanix.api</apiPackage>
                            <modelPackage>net.leanix.api.models</modelPackage>
                            <addCompileSourceRoot>false</addCompileSourceRoot>
                            <configOptions>
                                <groupId>net.leanix</groupId>
                                <artifactId>leanix-sdk-java</artifactId>
                                <invokerPackage>net.leanix.api.common</invokerPackage>
                                <library>jersey2</library>
                                <hideGenerationTimestamp>true</hideGenerationTimestamp>
                            </configOptions>
                            <!-- used to get help from cli that describes possible configOptions -->
                            <!--configHelp>true</configHelp -->
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- 2.) copy swagger's generated sources + adapted sources into /src/main/java folder -->
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.8</version>
                        <executions>
                            <execution>
                                <phase>process-sources</phase>
                                <configuration>
                                    <target>
                                        <copy todir="src" overwrite="true">
                                            <fileset dir="target/generated-sources/swagger/src" includes="**" />
                                        </copy>
                                         <copy todir="src/main/java" overwrite="true">
                                            <fileset dir="src/main/resources/codegen-templates" includes="**" />
                                        </copy>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>

</project>

