<?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/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>iotdb-parent</artifactId>
        <groupId>org.apache.iotdb</groupId>
        <version>1.2.0</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>openapi</artifactId>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.9.1</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.basedir}/target/generated-sources/java/src/gen/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-jersey2-jaxrs</artifactId>
            <scope>compile</scope>
            <version>${swagger.core.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>${servlet.api.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.jaxrs</groupId>
            <artifactId>jackson-jaxrs-json-provider</artifactId>
            <version>${jackson.version}</version>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>openapi-generation</id>
            <activation>
                <file>
                    <exists>src/main/openapi3</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.openapitools</groupId>
                        <artifactId>openapi-generator-maven-plugin</artifactId>
                        <version>${openapi.generator.version}</version>
                        <executions>
                            <execution>
                                <id>generate-java-rest-codes-common</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_common.yaml</inputSpec>
                                    <output>${project.build.directory}/generated-sources/java</output>
                                    <apiPackage>org.apache.iotdb.db.protocol.rest</apiPackage>
                                    <modelPackage>org.apache.iotdb.db.protocol.rest.model</modelPackage>
                                    <invokerPackage>org.apache.iotdb.db.protocol.rest.invoker</invokerPackage>
                                    <generatorName>jaxrs-jersey</generatorName>
                                    <groupId>org.apache.iotdb</groupId>
                                    <artifactId>iotdb-rest-service</artifactId>
                                    <artifactVersion>${project.version}</artifactVersion>
                                    <addCompileSourceRoot>true</addCompileSourceRoot>
                                    <configOptions>
                                        <licenseName>Apache License 2.0</licenseName>
                                        <groupId>org.apache.iotdb</groupId>
                                        <artifactId>iotdb-rest-service</artifactId>
                                        <artifactVersion>${project.version}</artifactVersion>
                                        <dateLibrary>java8</dateLibrary>
                                        <useGzipFeature>true</useGzipFeature>
                                    </configOptions>
                                </configuration>
                            </execution>
                            <execution>
                                <id>generate-java-rest-codes-v1</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_v1.yaml</inputSpec>
                                    <output>${project.build.directory}/generated-sources/java</output>
                                    <apiPackage>org.apache.iotdb.db.protocol.rest.v1</apiPackage>
                                    <modelPackage>org.apache.iotdb.db.protocol.rest.v1.model</modelPackage>
                                    <invokerPackage>org.apache.iotdb.db.protocol.rest.v1.invoker</invokerPackage>
                                    <generatorName>jaxrs-jersey</generatorName>
                                    <groupId>org.apache.iotdb</groupId>
                                    <artifactId>iotdb-rest-service</artifactId>
                                    <artifactVersion>${project.version}</artifactVersion>
                                    <addCompileSourceRoot>true</addCompileSourceRoot>
                                    <configOptions>
                                        <licenseName>Apache License 2.0</licenseName>
                                        <groupId>org.apache.iotdb</groupId>
                                        <artifactId>iotdb-rest-service</artifactId>
                                        <artifactVersion>${project.version}</artifactVersion>
                                        <dateLibrary>java8</dateLibrary>
                                        <useGzipFeature>true</useGzipFeature>
                                    </configOptions>
                                </configuration>
                            </execution>
                            <execution>
                                <id>generate-java-rest-codes-v2</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <inputSpec>${project.basedir}/src/main/openapi3/iotdb_rest_v2.yaml</inputSpec>
                                    <output>${project.build.directory}/generated-sources/java</output>
                                    <apiPackage>org.apache.iotdb.db.protocol.rest.v2</apiPackage>
                                    <modelPackage>org.apache.iotdb.db.protocol.rest.v2.model</modelPackage>
                                    <invokerPackage>org.apache.iotdb.db.protocol.rest.v2.invoker</invokerPackage>
                                    <generatorName>jaxrs-jersey</generatorName>
                                    <groupId>org.apache.iotdb</groupId>
                                    <artifactId>iotdb-rest-service</artifactId>
                                    <artifactVersion>${project.version}</artifactVersion>
                                    <addCompileSourceRoot>true</addCompileSourceRoot>
                                    <configOptions>
                                        <licenseName>Apache License 2.0</licenseName>
                                        <groupId>org.apache.iotdb</groupId>
                                        <artifactId>iotdb-rest-service</artifactId>
                                        <artifactVersion>${project.version}</artifactVersion>
                                        <dateLibrary>java8</dateLibrary>
                                        <useGzipFeature>true</useGzipFeature>
                                    </configOptions>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
