<?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.tsfile</groupId>
        <artifactId>tsfile-java</artifactId>
        <version>2.3.1</version>
    </parent>
    <artifactId>tsfile</artifactId>
    <name>TsFile: Java: TsFile</name>
    <description>A columnar file format designed for time-series data</description>
    <properties>
        <tsfile.it.skip>${tsfile.test.skip}</tsfile.it.skip>
        <tsfile.test.skip>false</tsfile.test.skip>
        <tsfile.ut.skip>${tsfile.test.skip}</tsfile.ut.skip>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.tsfile</groupId>
            <artifactId>common</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.github.luben</groupId>
            <artifactId>zstd-jni</artifactId>
        </dependency>
        <dependency>
            <groupId>org.xerial.snappy</groupId>
            <artifactId>snappy-java</artifactId>
        </dependency>
        <dependency>
            <groupId>at.yawk.lz4</groupId>
            <artifactId>lz4-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.tukaani</groupId>
            <artifactId>xz</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>antlr4</goal>
                        </goals>
                        <configuration>
                            <listener>false</listener>
                            <visitor>true</visitor>
                            <libDirectory>src/main/antlr4/org/apache/tsfile/parser</libDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/antlr4</source>
                                <source>${project.build.directory}/generated-sources/freemarker</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${basedir}/gen</directory>
                        </fileset>
                        <fileset>
                            <directory>${basedir}/src</directory>
                            <includes>
                                <include>**/*.tokens</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.4.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations/>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"/>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--
              Generate an OSGI compatible MANIFEST file.
            -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle</id>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>bundle-manifest</id>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                    <instructions>
                        <Export-Package>org.apache.tsfile.*</Export-Package>
                        <Embed-Dependency>common;inline=true</Embed-Dependency>
                        <Embed-Transitive>false</Embed-Transitive>
                        <Private-Package/>
                        <_removeheaders>Bnd-LastModified,Built-By</_removeheaders>
                        <Bundle-SymbolicName>org.apache.tsfile</Bundle-SymbolicName>
                    </instructions>
                </configuration>
            </plugin>
            <!--
              Use the MANIFEST file generated by the maven-bundle-plugin.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <!--using `mvn test` to run UT, `mvn verify` to run ITs
            Reference: https://antoniogoncalves.org/2012/12/13/lets-turn-integration-tests-with-maven-to-a-first-class-citizen/-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>${tsfile.ut.skip}</skipTests>
                    <reuseForks>false</reuseForks>
                    <runOrder>random</runOrder>
                    <!-- Pin tsfile.locale=en so tests run against the English (root) message
                         bundle regardless of the JVM default locale. Must be set at JVM
                         startup because Messages.BUNDLE is initialized once at class load. -->
                    <systemPropertyVariables>
                        <tsfile.locale>en</tsfile.locale>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <skipTests>${tsfile.test.skip}</skipTests>
                    <skipITs>${tsfile.it.skip}</skipITs>
                    <reuseForks>false</reuseForks>
                    <runOrder>random</runOrder>
                    <systemPropertyVariables>
                        <tsfile.locale>en</tsfile.locale>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>run-integration-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <phase>integration-test</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- generate sources from fmpp -->
                <groupId>org.apache.drill.tools</groupId>
                <artifactId>drill-fmpp-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-fmpp</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <config>${project.basedir}/src/main/codegen/config.fmpp</config>
                            <output>${project.build.directory}/generated-sources/freemarker</output>
                            <templates>${project.basedir}/src/main/codegen/templates/</templates>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>skipTsfileTests</id>
            <activation>
                <property>
                    <name>skipTests</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <tsfile.it.skip>true</tsfile.it.skip>
                <tsfile.test.skip>true</tsfile.test.skip>
                <tsfile.ut.skip>true</tsfile.ut.skip>
            </properties>
        </profile>
        <profile>
            <id>skipUT_TsFileTests</id>
            <activation>
                <property>
                    <name>skipUTs</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <tsfile.ut.skip>true</tsfile.ut.skip>
            </properties>
        </profile>
        <profile>
            <id>get-jar-with-dependencies</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make-assembly</id>
                                <!-- bind to the packaging phase -->
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <!-- this is used for inheritance merges -->
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
