<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2022 StreamThoughts.
  ~
  ~ 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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>

    <groupId>io.streamthoughts</groupId>
    <artifactId>jikkou</artifactId>
    <version>0.12.1</version>

    <name>Jikkou</name>
    <description>A command-line tool to help you automate the management of the configurations that live on your Apache
        Kafka clusters.
    </description>

    <developers>
        <developer>
            <organization>streamthoughts</organization>
            <organizationUrl>http://streamthoughts.io</organizationUrl>
        </developer>
    </developers>

    <organization>
        <name>streamthoughts</name>
        <url>https://www.streamthoughts.io</url>
    </organization>

    <scm>
        <url>https://github.com/streamthoughts/jikkou</url>
        <connection>scm:git:git://github.com:streamthoughts/jikkou.git</connection>
        <developerConnection>scm:git:git@github.com:streamthoughts/jikkou.git</developerConnection>
        <tag>HEAD</tag>
    </scm>

    <url>https://github.com/streamthoughts/jikkou</url>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <junit.version>5.8.2</junit.version>
        <maven.surefire.plugin.version>3.0.0-M6</maven.surefire.plugin.version>
        <maven.failsafe.plugin.version>3.0.0-M6</maven.failsafe.plugin.version>
        <testcontainer.version>1.17.2</testcontainer.version>
        <app.distribution.directory>${project.basedir}/dist</app.distribution.directory>
        <exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
        <vavr.version>0.10.4</vavr.version>
        <kafka.version>3.2.0</kafka.version>
        <jackson-databind.version>2.13.3</jackson-databind.version>
        <picocli.version>4.6.3</picocli.version>
        <jinjava.version>2.6.0</jinjava.version>
        <reflections.version>0.10.2</reflections.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>23.0.0</version>
        </dependency>
        <dependency>
            <groupId>io.vavr</groupId>
            <artifactId>vavr</artifactId>
            <version>${vavr.version}</version>
        </dependency>
        <dependency>
            <groupId>io.vavr</groupId>
            <artifactId>vavr-jackson</artifactId>
            <version>0.10.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>${kafka.version}</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe</groupId>
            <artifactId>config</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson-databind.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <version>${jackson-databind.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jdk8</artifactId>
            <version>${jackson-databind.version}</version>
        </dependency>
        <dependency>
            <groupId>info.picocli</groupId>
            <artifactId>picocli</artifactId>
            <version>${picocli.version}</version>
        </dependency>
        <dependency>
            <groupId>com.hubspot.jinjava</groupId>
            <artifactId>jinjava</artifactId>
            <version>${jinjava.version}</version>
        </dependency>
        <dependency>
            <groupId>org.reflections</groupId>
            <artifactId>reflections</artifactId>
            <version>${reflections.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.11</version>
        </dependency>
        <!-- START dependencies for Tests -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.5.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainer.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${testcontainer.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- END dependencies for Tests -->
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.10.1</version>
                    <configuration>
                        <parameters>true</parameters>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven.surefire.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven.failsafe.plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.vafer</groupId>
                    <artifactId>jdeb</artifactId>
                    <version>1.10</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${project.basedir}/dist</directory>
                        </fileset>
                        <fileset>
                            <directory>${project.basedir}/docker</directory>
                            <includes>
                                <include>**/*.zip</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <finalName>${project.artifactId}-runner</finalName>
                            <minimizeJar>true</minimizeJar>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>runner</shadedClassifierName>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>io.streamthoughts.jikkou.cli.Jikkou</mainClass>
                                    <manifestEntries>
                                        <Implementation-Title>Jikkou</Implementation-Title>
                                        <Implementation-Version>${project.version}</Implementation-Version>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludedGroups>integration</excludedGroups>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <groups>integration</groups>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-integration-test-source</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/integration-test/java</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-integration-test-resource</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>add-test-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>src/integration-test/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <version>4.7.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>spotbugs</goal>
                        </goals>
                        <phase>verify</phase>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs</artifactId>
                        <version>4.7.0</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <xmlOutput>true</xmlOutput>
                    <!-- Optional directory to put spotbugs xdoc xml report -->
                    <xmlOutputDirectory>target/site</xmlOutputDirectory>
                    <includeFilterFile>spotbugs/spotbugs-security-include.xml</includeFilterFile>
                    <excludeFilterFile>spotbugs/spotbugs-security-exclude.xml</excludeFilterFile>
                    <plugins>
                        <plugin>
                            <groupId>com.h3xstream.findsecbugs</groupId>
                            <artifactId>findsecbugs-plugin</artifactId>
                            <version>1.12.0</version>
                        </plugin>
                    </plugins>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <attach>false</attach>
                    <appendAssemblyId>false</appendAssemblyId>
                    <finalName>jikkou-${project.version}-runner</finalName>
                    <outputDirectory>${app.distribution.directory}</outputDirectory>
                    <skipAssembly>true</skipAssembly>
                </configuration>
                <executions>
                    <execution>
                        <id>make-distribution</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>dist</id>
            <activation>
                <property>
                    <name>dist</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>${exec-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>generate-autocompletion-script</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-Dpicocli.autocomplete.systemExitOnError</argument>
                                <argument>-cp</argument>
                                <classpath/>
                                <argument>picocli.AutoComplete</argument>
                                <argument>--force</argument><!-- overwrite if exists -->
                                <argument>--completionScript</argument>
                                <argument>${project.basedir}/jikkou_completion</argument>
                                <argument>io.streamthoughts.jikkou.cli.Jikkou</argument>
                            </arguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration combine.self="append">
                            <skipAssembly>false</skipAssembly>
                            <descriptors>
                                <descriptor>src/main/assembly/assembly.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.vafer</groupId>
                        <artifactId>jdeb</artifactId>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jdeb</goal>
                                </goals>
                                <configuration>
                                    <deb>${project.basedir}/dist/${project.artifactId}.deb</deb>
                                    <verbose>true</verbose>
                                    <snapshotExpand>true</snapshotExpand>
                                    <!-- expand "SNAPSHOT" to what is in the "USER" env variable -->
                                    <snapshotEnv>USER</snapshotEnv>
                                    <verbose>true</verbose>
                                    <controlDir>${basedir}/src/deb/control</controlDir>
                                    <dataSet>
                                        <data>
                                            <src>${project.basedir}/target/jikkou-runner.jar</src>
                                            <type>file</type>
                                            <mapper>
                                                <type>perm</type>
                                                <prefix>/opt/jikkou/lib</prefix>
                                                <filemode>444</filemode>
                                            </mapper>
                                        </data>

                                        <data>
                                            <src>${project.basedir}/src/main/bin/jikkou</src>
                                            <type>file</type>
                                            <mapper>
                                                <type>perm</type>
                                                <prefix>/opt/jikkou/bin</prefix>
                                                <filemode>755</filemode>
                                            </mapper>
                                        </data>

                                        <data>
                                            <src>${project.basedir}/src/main/conf/</src>
                                            <type>directory</type>
                                            <mapper>
                                                <type>perm</type>
                                                <prefix>/opt/jikkou/etc</prefix>
                                                <filemode>755</filemode>
                                            </mapper>
                                        </data>

                                        <data>
                                            <src>${project.basedir}/jikkou_completion</src>
                                            <type>file</type>
                                            <mapper>
                                                <type>perm</type>
                                                <prefix>/opt/jikkou/</prefix>
                                                <filemode>444</filemode>
                                            </mapper>
                                        </data>
                                    </dataSet>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>rpm</id>
            <activation>
                <file>
                    <exists>/usr/bin/rpmbuild</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                        <version>2.2.0</version>
                        <executions>
                            <execution>
                                <id>generate-rpm</id>
                                <goals>
                                    <goal>attached-rpm</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <name>jikkou</name>
                            <version>${project.version}</version>
                            <license>Apache License Version 2.0</license>
                            <group>Applications/Programming</group>
                            <needarch>noarch</needarch>
                            <defaultFilemode>644</defaultFilemode>
                            <defaultUsername>root</defaultUsername>
                            <defaultGroupname>root</defaultGroupname>
                            <defaultDirmode>755</defaultDirmode>
                            <packager>Streamthoughts</packager>
                            <prefix>/opt/jikkou</prefix>
                            <requires>
                                <require>java</require>
                            </requires>
                            <mappings>
                                <mapping>
                                    <directory>/opt/jikkou/lib/</directory>
                                    <filemode>444</filemode>
                                    <sources>
                                        <source>
                                            <location>${project.basedir}/target/jikkou-runner.jar</location>
                                        </source>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>/opt/jikkou/bin/</directory>
                                    <filemode>755</filemode>
                                    <sources>
                                        <source>
                                            <location>${project.basedir}/src/main/bin/jikkou</location>
                                        </source>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>/opt/jikkou/etc/</directory>
                                    <filemode>640</filemode>
                                    <configuration>noreplace</configuration>
                                    <sources>
                                        <source>
                                            <location>${project.basedir}/src/main/conf/</location>
                                        </source>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>/opt/jikkou/</directory>
                                    <filemode>640</filemode>
                                    <sources>
                                        <source>
                                            <location>${project.basedir}/jikkou_completion</location>
                                        </source>
                                    </sources>
                                </mapping>
                            </mappings>
                            <preinstallScriptlet>
                                <scriptFile>src/rpm/scripts/preinstall</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                                <filter>true</filter>
                            </preinstallScriptlet>
                            <postinstallScriptlet>
                                <scriptFile>src/rpm/scripts/postinstall</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                                <filter>true</filter>
                            </postinstallScriptlet>
                            <preremoveScriptlet>
                                <scriptFile>src/rpm/scripts/preremove</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                            </preremoveScriptlet>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>ossrh</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.13</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>false</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.2.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.4.0</version>
                        <configuration>
                            <doclint>none</doclint><!-- Turnoff all checks -->
                            <source>17</source>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
