<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2023 / present - Yupiik SAS - https://www.yupiik.com
    Licensed 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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.yupiik.ldapserver</groupId>
    <artifactId>ldap-server</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>
    <name>LDAP Server</name>
    <description>A simple light weight LDAP server.</description>
    <url>https://yupiik.github.io/ldap-server/</url>

    <properties>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <main.class>io.yupiik.fusion.framework.api.main.Launcher</main.class>

        <yupiik-logging.version>1.0.8</yupiik-logging.version>
        <fusion.version>1.0.31</fusion.version>
        <arthur.version>1.0.8</arthur.version>
        <unboundid-ldapsdk.version>6.0.7</unboundid-ldapsdk.version>
        <junit.version>5.13.4</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.unboundid</groupId>
            <artifactId>unboundid-ldapsdk</artifactId>
            <version>${unboundid-ldapsdk.version}</version>
        </dependency>

        <dependency>
            <groupId>io.yupiik.fusion</groupId>
            <artifactId>fusion-build-api</artifactId>
            <version>${fusion.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.yupiik.fusion</groupId>
            <artifactId>fusion-processor</artifactId>
            <version>${fusion.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.yupiik.fusion</groupId>
            <artifactId>fusion-api</artifactId>
            <version>${fusion.version}</version>
        </dependency>
        <dependency>
            <groupId>io.yupiik.fusion</groupId>
            <artifactId>fusion-observability</artifactId>
            <version>${fusion.version}</version>
        </dependency>
        <dependency>
            <groupId>io.yupiik.logging</groupId>
            <artifactId>yupiik-logging-jul</artifactId>
            <version>${yupiik-logging.version}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>io.yupiik.fusion</groupId>
            <artifactId>fusion-testing</artifactId>
            <version>${fusion.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.5.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.1.4</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.14.0</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                    <encoding>UTF-8</encoding>
                    <parameters>true</parameters>
                    <compilerArgs>
                        <compilerArg>-Xlint:unchecked</compilerArg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.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-release-plugin</artifactId>
                <version>3.1.1</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <releaseProfiles>release</releaseProfiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.nicoulaj.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <version>1.11</version>
            </plugin>
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.6.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>true</autoPublish>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.21.0</version>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>4.5</version>
                <executions>
                    <execution>
                        <id>check-license</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <inherited>false</inherited>
                <configuration>
                    <aggregate>true</aggregate>
                    <mapping>
                        <adoc>DOUBLESLASH_STYLE</adoc>
                    </mapping>
                    <licenseSets>
                        <licenseSet>
                            <inlineHeader><![CDATA[Copyright (c) ${project.inceptionYear} - ${project.organization.name} - ${project.organization.url}
Licensed 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.
]]></inlineHeader>
                            <useDefaultExcludes>true</useDefaultExcludes>
                            <includes>
                                <include>**/*.properties</include>
                                <include>**/*.java</include>
                                <include>**/*.xml</include>
                                <include>**/*.yaml</include>
                            </includes>
                            <excludes>
                                <exclude>LICENSE</exclude>
                                <exclude>**/*.adoc</exclude>
                                <exclude>**/*.idea</exclude>
                                <exclude>**/target/**</exclude>
                                <exclude>**/generated/**</exclude>
                                <exclude>**/minisite/**</exclude>
                                <exclude>**/file</exclude>
                                <exclude>**/.m2/**</exclude>
                            </excludes>
                        </licenseSet>
                    </licenseSets>
                </configuration>
            </plugin>
            <plugin><!--  mvn ossindex:audit -->
                <groupId>org.sonatype.ossindex.maven</groupId>
                <artifactId>ossindex-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>audit-dependencies</id>
                        <phase />
                        <goals>
                            <goal>audit</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scope>compile,runtime</scope>
                </configuration>
            </plugin>
            <plugin><!-- mvn exec:java -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.2</version>
                <configuration>
                    <mainClass>${main.class}</mainClass>
                    <systemProperties>
                        <property>
                            <key>java.util.logging.manager</key>
                            <value>io.yupiik.logging.jul.YupiikLogManager</value>
                        </property>
                        <property>
                            <key>yupiik.ldap.server.host</key>
                            <value>localhost</value>
                        </property>
                        <property>
                            <key>yupiik.ldap.server.port</key>
                            <value>4444</value>
                        </property>
                        <property>
                            <key>yupiik.ldap.server.provisioning</key>
                            <value>true</value>
                        </property>
                        <property>
                            <key>yupiik.ldap.server.provisioningSource</key>
                            <value>${project.basedir}/src/test/resources/server</value>
                        </property>
                        <property>
                            <key>yupiik.ldap.server.schemaSource</key>
                            <value>${project.basedir}/src/test/resources/schema/50-custom.ldif</value>
                        </property>
                        <property>
                            <key>yupiik.ldap.server.baseDn</key>
                            <value>dc=yupiik,dc=io</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.3</version>
                <configuration>
                    <trimStackTrace>false</trimStackTrace>
                    <systemPropertyVariables>
                        <java.util.logging.manager>io.yupiik.logging.jul.YupiikLogManager</java.util.logging.manager>
                        <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
                        <fusion.http-server.port>0</fusion.http-server.port>
                        <fusion.observability.server.port>0</fusion.observability.server.port>
                        <yupiik.ldap.server.provisioning>true</yupiik.ldap.server.provisioning>
                        <yupiik.ldap.server.provisioningSource>${project.basedir}/src/test/resources/server</yupiik.ldap.server.provisioningSource>
                        <yupiik.ldap.server.schemaSource>${project.basedir}/src/test/resources/schema/50-custom.ldif</yupiik.ldap.server.schemaSource>
                        <yupiik.ldap.server.baseDn>dc=yupiik,dc=io</yupiik.ldap.server.baseDn>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <!--
                    mvn arthur:native-image for binaries
                    mvn arthur:native-image arthur:docker for build docker image with binaries
                -->
                <groupId>org.apache.geronimo.arthur</groupId>
                <artifactId>arthur-maven-plugin</artifactId>
                <version>${arthur.version}</version>
                <configuration>
                    <main>${main.class}</main>
                    <usePackagedArtifact>true</usePackagedArtifact>
                    <graalVersion>21.0.2</graalVersion>
                    <graalDownloadUrl>
                        https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_linux-x64_bin.tar.gz
                    </graalDownloadUrl>
                    <buildStaticImage>false</buildStaticImage>
                    <useLDD>true</useLDD>
                    <includeNatives>false</includeNatives>
                    <fallbackMode>no</fallbackMode>
                    <enableAllSecurityServices>false</enableAllSecurityServices>
                    <scanningExcludedArtifacts>*</scanningExcludedArtifacts>
                    <customOptions>
                        <customOption>-Djava.util.logging.manager=io.yupiik.logging.jul.YupiikLogManager</customOption>
                        <customOption>-Djava.net.preferIPv4Stack=true</customOption>
                        <customOption>-Duser.language=en</customOption>
                        <customOption>-Duser.country=US</customOption>
                        <customOption>-Dfile.encoding=UTF-8</customOption>
                        <customOption>-H:+UnlockExperimentalVMOptions</customOption>
                        <customOption>--static</customOption>
                    </customOptions>

                    <!-- image configuration -->
                    <to>ossyupiik/ldap-server:${project.version}</to>
                    <creationTimestamp>-1</creationTimestamp>
                    <labels>
                        <org.opencontainers.image.created>${maven.build.timestamp}</org.opencontainers.image.created>
                        <org.opencontainers.image.authors>Yupiik</org.opencontainers.image.authors>
                        <org.opencontainers.image.vendor>Yupiik</org.opencontainers.image.vendor>
                        <org.opencontainers.image.title>${project.artifactId}</org.opencontainers.image.title>
                        <org.opencontainers.image.description>${project.description}
                        </org.opencontainers.image.description>
                        <org.opencontainers.image.version>${project.version}</org.opencontainers.image.version>
                    </labels>
                </configuration>
            </plugin>
            <!--
                mvn package jib:dockerBuild -Ppostgres -DskipTests
            -->
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>3.4.6</version>
                <configuration>
                    <containerizingMode>packaged</containerizingMode>
                    <from>
                        <image>${image.base}</image>
                    </from>
                    <to>
                        <image>${image.name}</image>
                    </to>
                    <container>
                        <appRoot>${image.workdir}</appRoot>
                        <workingDirectory>${image.workdir}</workingDirectory>
                        <extraClasspath>${image.workdir}/${project.artifactId}/lib/*</extraClasspath>
                        <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
                        <filesModificationTime>EPOCH_PLUS_SECOND</filesModificationTime>
                        <mainClass>io.yupiik.fusion.framework.api.main.Launcher</mainClass>
                        <jvmFlags>
                            <jvmFlag>-Djava.util.logging.manager=io.yupiik.logging.jul.YupiikLogManager</jvmFlag>
                            <jvmFlag>-Dio.yupiik.logging.jul.handler.StandardHandler.formatter=json</jvmFlag>
                            <jvmFlag>-Djava.security.egd=file:/dev/./urandom</jvmFlag>
                            <jvmFlag>-Djdk.serialFilter=!*</jvmFlag>
                            <jvmFlag>-Djdk.jndi.object.factoriesFilter=!*</jvmFlag>
                            <jvmFlag>-Dcom.sun.jndi.ldap.object.trustSerialData=false</jvmFlag>
                            <jvmFlag>-Drealvat.build.timestamp=${maven.build.timestamp}</jvmFlag>
                        </jvmFlags>
                        <labels>
                            <org.opencontainers.image.created>${maven.build.timestamp}
                            </org.opencontainers.image.created>
                            <org.opencontainers.image.authors>Yupiik</org.opencontainers.image.authors>
                            <org.opencontainers.image.vendor>Yupiik</org.opencontainers.image.vendor>
                            <org.opencontainers.image.title>${project.artifactId}</org.opencontainers.image.title>
                            <org.opencontainers.image.description>${project.description}
                            </org.opencontainers.image.description>
                            <org.opencontainers.image.version>${project.version}</org.opencontainers.image.version>
                            <com.realvat.params>_JAVA_OPTIONS=...</com.realvat.params>
                            <com.realvat.cmd>docker run ${image.name} &lt;args&gt;</com.realvat.cmd>
                        </labels>
                    </container>
                    <extraDirectories>
                        <paths>
                            <path>
                                <from>${project.parent.basedir}/src/resources/yupiik/ldap/server</from>
                                <into>${image.workdir}/ldap</into>
                            </path>
                        </paths>
                    </extraDirectories>
                    <outputPaths>
                        <imageJson>${project.build.directory}/jib-image.json</imageJson>
                    </outputPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.11.3</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <source>21</source>
                            <doclint>none</doclint>
                            <encoding>UTF-8</encoding>
                            <failOnError>false</failOnError>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.7</version>
                        <configuration>
                            <gpgArguments>
                                <arg>--digest-algo=SHA512</arg>
                            </gpgArguments>
                        </configuration>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>net.nicoulaj.maven.plugins</groupId>
                        <artifactId>checksum-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>source-release-checksum</id>
                                <goals>
                                    <goal>artifacts</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <algorithms>
                                <algorithm>SHA-512</algorithm>
                            </algorithms>
                            <csvSummary>false</csvSummary>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://github.com/yupiik/ldap-server/blob/master/LICENSE</url>
            <distribution>may be downloaded from the Maven repository</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Romain Manni-Bucau</name>
            <id>rmannibucau</id>
            <roles>
                <role>Contributor</role>
            </roles>
            <timezone>+1</timezone>
        </developer>
        <developer>
            <name>Francois Papon</name>
            <id>fpapon</id>
            <roles>
                <role>Contributor</role>
            </roles>
            <timezone>+1</timezone>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/yupiik/ldap-server.git</connection>
        <developerConnection>scm:git:https://github.com/yupiik/ldap-server.git</developerConnection>
        <url>https://github.com/yupiik/ldap-server.git</url>
        <tag>ldap-server-1.0.0</tag>
    </scm>

    <organization>
        <name>Yupiik SAS</name>
        <url>https://www.yupiik.com</url>
    </organization>

    <inceptionYear>2023 / present</inceptionYear>

    <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>
</project>
