<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2020-2021 Heiko Bornholdt and Kevin Röbert
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy
  ~ of this software and associated documentation files (the "Software"), to deal
  ~ in the Software without restriction, including without limitation the rights
  ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  ~ copies of the Software, and to permit persons to whom the Software is
  ~ furnished to do so, subject to the following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all
  ~ copies or substantial portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  ~ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  ~ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  ~ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  ~ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  ~ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  ~ OR OTHER DEALINGS IN THE SOFTWARE.
  -->

<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>drasyl-parent</artifactId>
        <groupId>org.drasyl</groupId>
        <version>0.10.0</version>
    </parent>

    <artifactId>drasyl-cli</artifactId>

    <name>drasyl: General-Purpose Overlay Network Framework - CLI Package</name>
    <description>
        This package contains a pre-packed drasyl Node. It can be run via the command line interface. This allows you to easily create new (root) super peers.
    </description>
    <url>https://drasyl.org/</url>

    <properties>
        <picocli.version>4.7.1</picocli.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>drasyl-plugin-groups-manager</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>

        <!-- Command Line Argument Parser -->
        <dependency>
            <groupId>info.picocli</groupId>
            <artifactId>picocli</artifactId>
            <version>${picocli.version}</version>
        </dependency>

        <!-- Progress Bar -->
        <dependency>
            <groupId>me.tongfei</groupId>
            <artifactId>progressbar</artifactId>
            <version>0.9.5</version>
        </dependency>

        <!-- TUN device access -->
        <dependency>
            <groupId>org.drasyl</groupId>
            <artifactId>netty-tun</artifactId>
            <version>1.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http</artifactId>
            <version>${netty.version}</version>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>drasyl-core</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>drasyl-node</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <configuration>
                            <propertiesEncoding>UTF-8</propertiesEncoding>
                            <!-- We don't want maven to destroy our binaries -->
                            <nonFilteredFileExtensions>
                                <nonFilteredFileExtension>so</nonFilteredFileExtension>
                                <nonFilteredFileExtension>dll</nonFilteredFileExtension>
                                <nonFilteredFileExtension>dylib</nonFilteredFileExtension>
                            </nonFilteredFileExtensions>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-dependencies</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                    <includeScope>compile</includeScope>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assembly/dist.xml</descriptor>
                            </descriptors>
                            <finalName>drasyl-${project.version}</finalName>
                            <outputDirectory>${project.parent.basedir}</outputDirectory>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                        <executions>
                            <execution>
                                <id>create-archive</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>native</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <configuration>
                            <propertiesEncoding>UTF-8</propertiesEncoding>
                            <!-- We don't want maven to destroy our binaries -->
                            <nonFilteredFileExtensions>
                                <nonFilteredFileExtension>so</nonFilteredFileExtension>
                                <nonFilteredFileExtension>dll</nonFilteredFileExtension>
                                <nonFilteredFileExtension>dylib</nonFilteredFileExtension>
                            </nonFilteredFileExtensions>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>ban-bad-log4j-versions</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <bannedDependencies>
                                            <excludes>
                                                <exclude>org.apache.logging.log4j:log4j-core:(,2.17.0)</exclude>
                                            </excludes>
                                        </bannedDependencies>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.graalvm.nativeimage</groupId>
                        <artifactId>native-image-maven-plugin</artifactId>
                        <version>21.2.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>native-image</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <imageName>drasyl</imageName>
                            <mainClass>org.drasyl.cli.Cli</mainClass>
                            <outputDirectory>${project.parent.basedir}</outputDirectory>
                            <buildArgs>--no-fallback</buildArgs>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <!-- annotationProcessorPaths requires maven-compiler-plugin version 3.5 or higher -->
                        <configuration>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>info.picocli</groupId>
                                    <artifactId>picocli-codegen</artifactId>
                                    <version>${picocli.version}</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
