<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://maven.apache.org/POM/4.0.0"
    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>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>9</version>
    </parent>

    <name>codbex - platform - parent</name>

    <groupId>com.codbex.platform</groupId>
    <artifactId>codbex-platform-parent</artifactId>
    <version>13.6.0</version>
    <packaging>pom</packaging>

    <inceptionYear>2024</inceptionYear>

    <properties>
        <!-- Encoding -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <dirigible.version>13.6.0</dirigible.version>
        <codbex-platform-settings.version>1.0.0</codbex-platform-settings.version>

        <!-- Java -->
        <java.version>21</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <!-- Maven -->
        <maven-compiler-plugin.version>3.15.0</maven-compiler-plugin.version>
        <maven-surefire-plugin.version>3.5.6</maven-surefire-plugin.version>
        <maven-failsafe-plugin.version>3.5.6</maven-failsafe-plugin.version>
        <maven-jacoco-plugin.version>0.8.15</maven-jacoco-plugin.version>
        <maven-git-commit-id-plugin.version>4.9.10</maven-git-commit-id-plugin.version>
        <maven-license-plugin.version>5.0.0</maven-license-plugin.version>
        <maven-spring-boot-plugin.version>4.1.0</maven-spring-boot-plugin.version>
        <maven-formatter-plugin.version>2.29.0</maven-formatter-plugin.version>
        <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
        <maven-dependency-plugin.version>3.11.0</maven-dependency-plugin.version>

        <formatter.java.version>${java.version}</formatter.java.version>

        <!-- Default configurations -->
        <skipTests>false</skipTests>
        <skipITs>true</skipITs>
        <skip.code.formatting>false</skip.code.formatting>
        <maven.javadoc.skip>false</maven.javadoc.skip>
        <license.skip>false</license.skip>

    </properties>

    <licenses>
        <license>
            <name>Eclipse Public License - v 2.0</name>
            <url>https://www.eclipse.org/legal/epl-v20.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <url>https://codbex.com</url>

    <scm>
        <url>https://github.com/codbex/codbex-platform-parent</url>
    </scm>
    <issueManagement>
        <url>https://github.com/codbex/codbex-platform-parent/issues</url>
    </issueManagement>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://ossrh-staging-api.central.sonatype.com/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2</url>
        </repository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>mvnrepository</id>
            <url>https://repo1.maven.org/maven2</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>

    <organization>
        <name>codbex</name>
        <url>https://www.codbex.com</url>
    </organization>

    <developers>
        <developer>
            <id>office</id>
            <name>Office</name>
            <email>office@codbex.com</email>
            <url>https://github.com/codbex</url>
            <organization>codbex</organization>
            <organizationUrl>https://www.codbex.com</organizationUrl>
        </developer>
    </developers>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.eclipse.dirigible</groupId>
                <artifactId>dirigible-dependencies</artifactId>
                <version>${dirigible.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.eclipse.dirigible</groupId>
                <artifactId>dirigible-tests</artifactId>
                <version>${dirigible.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.eclipse.dirigible</groupId>
                <artifactId>dirigible-tests-integrations</artifactId>
                <version>${dirigible.version}</version>
                <scope>test</scope>
                <exclusions>
                    <exclusion>
                        <groupId>org.eclipse.dirigible</groupId>
                        <artifactId>dirigible-application</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.eclipse.dirigible</groupId>
                <artifactId>dirigible-tests-framework</artifactId>
                <version>${dirigible.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.dirigible</groupId>
            <artifactId>dirigible-commons-resources</artifactId>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>dirigible.properties</include>
                    <include>dirigible-commons.properties</include>
                </includes>
            </resource>

        </resources>
        <plugins>
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.cyclonedx</groupId>
                    <artifactId>cyclonedx-maven-plugin</artifactId>
                    <version>2.9.1</version>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>makeAggregateBom</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <!--                        https://cyclonedx.org/docs/1.6/json/-->
                        <schemaVersion>1.6</schemaVersion>
                        <projectType>application</projectType>
                        <verbose>false</verbose>

                        <includeBomSerialNumber>true</includeBomSerialNumber>
                        <includeCompileScope>true</includeCompileScope>
                        <includeProvidedScope>true</includeProvidedScope>
                        <includeRuntimeScope>true</includeRuntimeScope>
                        <includeSystemScope>true</includeSystemScope>
                        <includeTestScope>false</includeTestScope>
                        <includeLicenseText>false</includeLicenseText>

                        <outputReactorProjects>true</outputReactorProjects>
                        <outputFormat>all</outputFormat>
                        <outputName>bom</outputName>
                        <outputDirectory>${project.build.outputDirectory}/META-INF/sbom</outputDirectory>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                    <configuration>
                        <skipTests>${skipTests}</skipTests>
                        <failIfNoTests>false</failIfNoTests>
                        <failIfNoSpecifiedTests>false</failIfNoSpecifiedTests>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>${maven-failsafe-plugin.version}</version>
                    <configuration>
                        <skipITs>${skipITs}</skipITs>
                        <failIfNoTests>false</failIfNoTests>
                        <failIfNoSpecifiedTests>false</failIfNoSpecifiedTests>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <version>${maven-git-commit-id-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>get-the-git-infos</id>
                            <goals>
                                <goal>revision</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <dotGitDirectory>../.git</dotGitDirectory>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${maven-jacoco-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <rules>
                            <rule>
                                <element>SOURCEFILE</element>
                                <excludes>
                                    <exclude>*src/test/*</exclude>
                                </excludes>
                            </rule>
                        </rules>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                        <debug>true</debug>
                        <debuglevel>lines,vars,source</debuglevel>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>${maven-license-plugin.version}</version>
                    <inherited>true</inherited>
                    <configuration>
                        <header>
                            ${project.build.directory}/unpacked-dependencies/licensing-header.txt</header>
                        <aggregate>true</aggregate>
                        <properties>
                            <inceptionYear>${project.inceptionYear}</inceptionYear>
                            <currentYear>${currentYear}</currentYear>
                        </properties>
                        <includes>
                            <include>src/**/*.java</include>
                            <include>src/**/*.xml</include>
                            <include>src/**/*.js</include>
                        </includes>
                        <excludes>
                            <exclude>**/logback.xml</exclude>
                            <exclude>**/logback-test.xml</exclude>
                            <exclude>**/src/test/resources/**</exclude>
                            <exclude>resources/resources-neo-sdk/**</exclude>
                        </excludes>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.codbex.platform</groupId>
                            <artifactId>codbex-platform-settings</artifactId>
                            <version>${codbex-platform-settings.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>com.mycila</groupId>
                            <artifactId>license-maven-plugin-git</artifactId>
                            <version>${maven-license-plugin.version}</version>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <id>format-license</id>
                            <phase>initialize</phase>
                            <goals>
                                <goal>format</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.6.1</version>
                    <executions>
                        <execution>
                            <id>extract-fat-jar-name</id>
                            <goals>
                                <goal>regex-property</goal>
                            </goals>
                            <phase>validate</phase>
                            <configuration>
                                <name>fat.jar.name</name>
                                <regex>(.+)-application(.+)</regex>
                                <replacement>$1$2</replacement>
                                <value>${project.artifactId}-${project.version}</value>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${maven-spring-boot-plugin.version}</version>
                    <configuration>
                        <finalName>${fat.jar.name}</finalName>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>net.revelc.code.formatter</groupId>
                    <artifactId>formatter-maven-plugin</artifactId>
                    <version>${maven-formatter-plugin.version}</version>
                    <configuration>
                        <skip>${skip.code.formatting}</skip>
                        <configFile>codbex-formatter.xml</configFile>
                        <compilerSource>${formatter.java.version}</compilerSource>
                        <compilerCompliance>${formatter.java.version}</compilerCompliance>
                        <compilerTargetPlatform>${formatter.java.version}</compilerTargetPlatform>
                    </configuration>
                    <executions>
                        <execution>
                            <id>format-java-code</id>
                            <phase>process-sources</phase>
                            <goals>
                                <goal>format</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>com.codbex</groupId>
                            <artifactId>platform-settings</artifactId>
                            <version>${codbex-platform-settings.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${maven-javadoc-plugin.version}</version>
                    <configuration>
                        <source>${java.version}</source>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${maven-dependency-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>initialize</phase>
                            <goals>
                                <goal>unpack</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${project.build.directory}/unpacked-dependencies</outputDirectory>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>com.codbex</groupId>
                                        <artifactId>platform-settings</artifactId>
                                        <version>${codbex-platform-settings.version}</version>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.11.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>ossrh</publishingServerId>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <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>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Prevent gpg from using pinentry
                                            programs -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>tests</id>
            <properties>
                <skipTests>false</skipTests>
                <skipITs>false</skipITs>
                <maven.javadoc.skip>true</maven.javadoc.skip>
                <license.skip>true</license.skip>
                <skip.code.formatting>true</skip.code.formatting>
            </properties>
        </profile>
        <profile>
            <id>unit-tests</id>
            <properties>
                <skipTests>false</skipTests>
                <skipITs>true</skipITs>
                <maven.javadoc.skip>true</maven.javadoc.skip>
                <license.skip>true</license.skip>
                <skip.code.formatting>true</skip.code.formatting>
            </properties>
        </profile>
        <profile>
            <id>integration-tests</id>
            <properties>
                <skipITs>false</skipITs>
                <maven.javadoc.skip>true</maven.javadoc.skip>
                <license.skip>true</license.skip>
                <skip.code.formatting>true</skip.code.formatting>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>quick-build</id>
            <properties>
                <skipTests>true</skipTests>
                <skipITs>true</skipITs>
                <maven.javadoc.skip>true</maven.javadoc.skip>
                <license.skip>true</license.skip>
                <skip.code.formatting>true</skip.code.formatting>
            </properties>
        </profile>
        <profile>
            <id>format</id>
            <properties>
                <skipTests>true</skipTests>
                <skipITs>true</skipITs>
                <maven.javadoc.skip>true</maven.javadoc.skip>
                <license.skip>true</license.skip>
                <skip.code.formatting>false</skip.code.formatting>
            </properties>
        </profile>
    </profiles>

</project>
