<?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>3.9.25</version>

    <parent>
        <groupId>net.leanix.poms</groupId>
        <artifactId>sdk-parent</artifactId>
        <version>0.10.2</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-1.leanix.net</codegenHost>
        <swagger-inputSpec>https://${codegenHost}/services/pathfinder/v1/api-docs/</swagger-inputSpec>

    </properties>

    <dependencies>

        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>2.8.7</version>
        </dependency>

        <!-- Testing -->

    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <showDeprecation>true</showDeprecation>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules combine.children="override">
                                <requireMavenVersion>
                                    <version>3.0.5</version>
                                </requireMavenVersion>
                                <requirePluginVersions>
                                    <message>Best Practice is to always define plugin versions!</message>
                                    <banLatest>true</banLatest>
                                    <banRelease>true</banRelease>
                                    <banSnapshots>false</banSnapshots>
                                    <phases>clean,deploy,site</phases>
                                    <additionalPlugins>
                                        <additionalPlugin>org.apache.maven.plugins:maven-eclipse-plugin</additionalPlugin>
                                    </additionalPlugins>
                                </requirePluginVersions>
                                <requireJavaVersion>
                                    <version>[1.8,1.9)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                    </execution>
                </executions>
            </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.2.2</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>
                                <dateLibrary>java8</dateLibrary>
                                <hideGenerationTimestamp>true</hideGenerationTimestamp>
                                <type-mappings>DateTime=Instant,date=LocalDate</type-mappings>
                                <import-mappings>Instant=java.time.Instant,LocalDate=java.time.LocalDate</import-mappings>
                            </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>

