<?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>
    <parent>
        <groupId>tigase</groupId>
        <artifactId>tigase-projects-parent</artifactId>
        <version>1.0.6</version>
        <relativePath/>
    </parent>

    <profiles>
        <profile>
            <id>alpine</id>
            <properties>
                <jib.from.image.base>alpine</jib.from.image.base>
                <jib.image.tag>latest-${jib.from.image.flavour}-${jib.from.image.base}</jib.image.tag>
            </properties>
        </profile>
        <profile>
            <id>dev</id>
            <properties>
                <jib.image.tag>latest-dev</jib.image.tag>
                <jib.from.image.flavour>jdk</jib.from.image.flavour>
            </properties>
        </profile>
    </profiles>

    <properties>
        <james.groupId>org.apache.james</james.groupId>

        <!--        <james.version>3.7.3</james.version>-->
        <james.version>3.9.0-SNAPSHOT</james.version>

        <slf4j.version>2.0.6</slf4j.version>
        <log4j2.version>2.19.0</log4j2.version>

        <!--Don't set static/date tag! If you need stable tag use `docker buildx imagetools` as described in readme!-->
        <!--by default we should use `nightly` tag to avoid accidentally pushing test version - at least until having regular release cycle -->
        <jib.image.tag>nightly</jib.image.tag>

        <jib.from.image.base>jammy</jib.from.image.base>
        <jib.from.image.flavour>jre</jib.from.image.flavour>
        <jib.from.image>eclipse-temurin:${maven.compiler.source}-${jib.from.image.flavour}-${jib.from.image.base}</jib.from.image>

        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
        <maven.compiler.release>${maven.compiler.source}</maven.compiler.release>

        <os.architecture>amd64</os.architecture>
    </properties>

    <artifactId>james-tigase-repository</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Tigase extensions of Apache James</name>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.openjpa</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <version>4.0.0</version>
                <configuration>
                    <includes>tigase/james/rewrite/TygrysJPA*.class</includes>
                    <addDefaultConstructor>true</addDefaultConstructor>
                    <enforcePropertyRestrictions>true</enforcePropertyRestrictions>
                    <persistenceUnitName>Tygrys</persistenceUnitName>
                    <persistenceXmlFile>${basedir}/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
                </configuration>
                <executions>
                    <execution>
                        <id>enhancer</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <from>
                        <image>${jib.from.image}</image>
                        <platforms>
                            <platform>
                                <architecture>arm64</architecture>
                                <os>linux</os>
                            </platform>
                            <platform>
                                <architecture>amd64</architecture>
                                <os>linux</os>
                            </platform>
                        </platforms>
                    </from>
                    <to>
                        <image>tygrysinc/james-tigase-integration:${jib.image.tag}</image>
                    </to>
                    <container>
                        <mainClass>tigase.james.TigaseJPAJamesServerMain</mainClass>
                        <ports>
                            <port>80</port> <!-- JMAP -->
                            <port>143</port> <!-- IMAP -->
                            <port>993</port> <!-- IMAPS -->
                            <port>25</port> <!-- SMTP -->
                            <port>465</port> <!-- SMTP + STARTTLS -->
                            <port>587</port> <!-- SMTPS -->
                            <port>4000</port> <!-- GLOWROOT, if activated -->
                            <port>8000</port> <!-- WEBADMIN -->
                            <port>9999</port> <!-- WEBADMIN -->
                        </ports>
                        <appRoot>/root</appRoot>
                        <jvmFlags>
                            <jvmFlag>-Dlogback.configurationFile=/root/conf/logback.xml</jvmFlag>
                            <jvmFlag>-Dworking.directory=/root/</jvmFlag>
                            <!-- Prevents Logjam (CVE-2015-4000) -->
                            <jvmFlag>-Djdk.tls.ephemeralDHKeySize=2048</jvmFlag>
                            <jvmFlag>-Dextra.props=/root/conf/jvm.properties</jvmFlag>
                            <jvmFlag>-XX:+CrashOnOutOfMemoryError</jvmFlag>
                        </jvmFlags>
                        <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
                        <volumes>
                            <volume>/logs</volume>
                            <volume>/root/conf</volume>
                            <volume>/root/secrets</volume>
                            <volume>/root/extensions-jars</volume>
                            <!-- Data for ActiveMQ and lucene mailQueue -->
                            <volume>/root/var</volume>
                        </volumes>
                    </container>
                    <extraDirectories>
                        <paths>
                            <path>
                                <from>conf</from>
                                <into>/root/conf</into>
                            </path>
                            <path>
                                <from>src/main/scripts</from>
                                <into>/usr/bin</into>
                            </path>
                        </paths>
                        <permissions>
                            <permission>
                                <file>/usr/bin/james-cli</file>
                                <mode>755</mode> <!-- Read/write/execute for owner, read/execute for group/other -->
                            </permission>
                        </permissions>
                    </extraDirectories>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <phase>deploy</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit4</artifactId>
                        <version>2.22.0</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-jpa-app</artifactId>
            <version>${james.version}</version>
            <!--            TODO: Remove if fixed upstream-->
            <exclusions>
                <exclusion>
                    <groupId>org.apache.geronimo.specs</groupId>
                    <artifactId>geronimo-jms_1.1_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-jpa-common-guice</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-data-file</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-core</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <version>${james.version}</version>
            <artifactId>james-server-guice-webadmin-mail-over-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.3.7</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.28</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>queue-activemq-guice</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-configuration2</artifactId>
            <version>2.9.0</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>apache-mailet-api</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-data-api</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-dnsservice-api</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <version>${james.version}</version>
            <artifactId>james-server-filesystem-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-lifecycle-api</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-util</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.5.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.16</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-data-library</artifactId>
            <version>${james.version}</version>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-data-ldap</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-mailbox</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-mailbox-jpa</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-sieve-jpa</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-imap</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-jmap</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-managedsieve</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-pop</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-smtp</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-webadmin-mailbox</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-webadmin-jmap</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-jmx</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-mailets</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-webadmin-mailqueue</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-webadmin-mailrepository</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-webadmin</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>apache-james-mailbox-api</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${james.groupId}</groupId>
            <artifactId>james-server-guice-lmtp</artifactId>
            <version>${james.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.github.hakky54</groupId>
            <artifactId>sslcontext-kickstart-for-pem</artifactId>
            <version>8.1.2</version>
        </dependency>

        <!--  Dependency required to have database connection pool -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.9.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.github.rholder/guava-retrying -->
        <dependency>
            <groupId>com.github.rholder</groupId>
            <artifactId>guava-retrying</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.mail</groupId>
            <artifactId>jakarta.mail</artifactId>
            <version>2.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>tigase</id>
            <url>https://maven-repo.tigase.org/repository/tigase</url>
        </repository>
    </repositories>
</project>
