<?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>

    <groupId>eu.europa.ec.joinup.sat</groupId>
    <artifactId>jdplus-main</artifactId>
    <version>3.0.2</version>
    <packaging>pom</packaging>

    <name>${project.artifactId}</name>
    <description>JDemetra+ v3</description>
    <url>https://github.com/${x.github.user}/${x.github.repo}</url>
    <inceptionYear>2013</inceptionYear>

    <licenses>
        <license>
            <name>European Union Public Licence (EUPL)</name>
            <url>https://joinup.ec.europa.eu/page/eupl-text-11-12</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Philippe Charles</name>
            <email>philippe.charles@nbb.be</email>
            <organization>National Bank of Belgium</organization>
            <organizationUrl>https://www.nbb.be</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/${x.github.user}/${x.github.repo}.git</connection>
        <developerConnection>scm:git:ssh://github.com:${x.github.user}/${x.github.repo}.git</developerConnection>
        <url>http://github.com/${x.github.user}/${x.github.repo}/tree/master</url>
    </scm>

    <properties>
        <!-- Java 17 config -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.target>17</maven.compiler.target>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.release>17</maven.compiler.release>

        <!-- GitHub hosting -->
        <x.github.user>jdemetra</x.github.user>
        <x.github.repo>${project.artifactId}</x.github.repo>

        <!-- annotations & processors -->
        <lombok.version>1.18.28</lombok.version>
        <java-service.version>1.6.1</java-service.version>
        <java-design.version>1.4.0</java-design.version>
        <checker-qual.version>3.33.0</checker-qual.version>

        <!-- test frameworks -->
        <junit.version>5.9.2</junit.version>
        <assertj-core.version>3.24.2</assertj-core.version>

        <!-- dependencies -->
        <jd2.version>2.2.4</jd2.version>
        <protobuf.version>3.21.12</protobuf.version>
        <java-io-util.version>0.0.23</java-io-util.version>
        <java-sql-util.version>1.0.3</java-sql-util.version>
        <spreadsheet4j.version>2.5.2</spreadsheet4j.version>
    </properties>

    <modules>
        <module>jdplus-main-base</module>
        <module>jdplus-main-cli</module>
        <module>jdplus-main-desktop</module>
        <module>jdplus-main-bom</module>
    </modules>

    <dependencies>
        <!-- annotations & processors -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.nbbrd.java-design-util</groupId>
            <artifactId>java-design-processor</artifactId>
            <version>${java-design.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.nbbrd.java-service-util</groupId>
            <artifactId>java-service-processor</artifactId>
            <version>${java-service.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
            <version>${checker-qual.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- test frameworks -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</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>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj-core.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <!-- Enforce reproducible builds -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.11.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</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-site-plugin</artifactId>
                    <version>3.12.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <!-- Other plugins -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.gaul</groupId>
                    <artifactId>modernizer-maven-plugin</artifactId>
                    <version>2.6.0</version>
                </plugin>
                <plugin>
                    <groupId>de.thetaphi</groupId>
                    <artifactId>forbiddenapis</artifactId>
                    <version>3.5.1</version>
                </plugin>
                <plugin>
                    <groupId>com.github.nbbrd.heylogs</groupId>
                    <artifactId>heylogs-maven-plugin</artifactId>
                    <version>0.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.xolstice.maven.plugins</groupId>
                    <artifactId>protobuf-maven-plugin</artifactId>
                    <version>0.6.1</version>
                </plugin>
                <plugin>
                    <groupId>com.amashchenko.maven.plugin</groupId>
                    <artifactId>gitflow-maven-plugin</artifactId>
                    <version>1.20.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.simplify4u.plugins</groupId>
                    <artifactId>sign-maven-plugin</artifactId>
                    <version>1.0.1</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.6.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- 1 Configure basics -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <!-- 1.1 Enable annotation processors -->
                    <annotationProcessorPaths combine.children="append">
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                        <path>
                            <groupId>com.github.nbbrd.java-service-util</groupId>
                            <artifactId>java-service-processor</artifactId>
                            <version>${java-service.version}</version>
                        </path>
                        <path>
                            <groupId>com.github.nbbrd.java-design-util</groupId>
                            <artifactId>java-design-processor</artifactId>
                            <version>${java-design.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <configuration>
                            <!-- 1.2 Disable module path for unit tests -->
                            <useModulePath>false</useModulePath>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <!-- 1.2 Disable module path for unit tests -->
                    <useModulePath>false</useModulePath>
                </configuration>
            </plugin>
            <plugin>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.7.1</version>
                <executions>
                    <!-- 1.3 Detect OS properties for protoc -->
                    <!-- Not used as an extension since NetBeans doesn't support extensions -->
                    <!-- Must define os.detected.classifier property in settings so NetBeans can use it -->
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>detect</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <configuration>
                    <!-- 1.4 Configure protoc -->
                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}
                    </protocArtifact>
                    <!-- 1.5 Avoid compilation of unchanged proto definitions -->
                    <checkStaleness>true</checkStaleness>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.amashchenko.maven.plugin</groupId>
                <artifactId>gitflow-maven-plugin</artifactId>
                <configuration>
                    <!-- 1.6 Configure Git branching model -->
                    <gitFlowConfig>
                        <productionBranch>main</productionBranch>
                        <versionTagPrefix>v</versionTagPrefix>
                    </gitFlowConfig>
                </configuration>
            </plugin>

            <!-- 2 Enforce rules -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>extra-enforcer-rules</artifactId>
                        <version>1.6.2</version>
                    </dependency>
                    <dependency>
                        <groupId>org.kordamp.maven</groupId>
                        <artifactId>pomchecker-enforcer-rules</artifactId>
                        <version>1.9.0</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <!-- 2.1 Built-In Rules -->
                                <banDuplicatePomDependencyVersions/>
                                <dependencyConvergence/>
                                <reactorModuleConvergence/>
                                <requireMavenVersion>
                                    <version>3.6.0</version>
                                </requireMavenVersion>
                                <requireNoRepositories>
                                    <allowSnapshotRepositories>true</allowSnapshotRepositories>
                                </requireNoRepositories>
                                <requirePluginVersions/>
                                <requireProperty>
                                    <property>project.artifactId</property>
                                    <message>Project artifactId must follow JD3 pattern</message>
                                    <regex>^(jdplus)-(\w+)(?:-(base|cli|desktop|bom)(?:-(\w+))?)?$</regex>
                                </requireProperty>
                                <requireReleaseDeps>
                                    <onlyWhenRelease>true</onlyWhenRelease>
                                </requireReleaseDeps>
                                <requireUpperBoundDeps/>
                                <!-- 2.2 extra-enforcer-rules -->
                                <banCircularDependencies/>
                                <banDuplicateClasses/>
                                <enforceBytecodeVersion>
                                    <maxJdkVersion>${maven.compiler.release}</maxJdkVersion>
                                    <ignoredScopes>
                                        <ignoreScope>test</ignoreScope>
                                    </ignoredScopes>
                                </enforceBytecodeVersion>
                                <!-- 2.3 pomchecker-enforcer-rules -->
                                <checkMavenCentral
                                        implementation="org.kordamp.maven.enforcer.checker.CheckMavenCentral">
                                    <release>false</release>
                                    <strict>false</strict>
                                </checkMavenCentral>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>check-project</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <inherited>false</inherited>
                        <configuration>
                            <rules>
                                <!-- 2.4 required project files -->
                                <requireFilesExist>
                                    <files>
                                        <file>${project.basedir}/.gitignore</file>
                                        <file>${project.basedir}/CHANGELOG.md</file>
                                        <file>${project.basedir}/LICENSE</file>
                                        <file>${project.basedir}/lombok.config</file>
                                        <file>${project.basedir}/README.md</file>
                                    </files>
                                </requireFilesExist>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.gaul</groupId>
                <artifactId>modernizer-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>modernizer</goal>
                        </goals>
                        <configuration>
                            <!-- 2.5 upgradable source code -->
                            <javaVersion>${maven.compiler.release}</javaVersion>
                            <!-- 2.6 forbidden source code -->
                            <exclusionPatterns>
                                <!--<exclusionPattern>com/google/common/base/Optional.*</exclusionPattern>-->
                            </exclusionPatterns>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>de.thetaphi</groupId>
                <artifactId>forbiddenapis</artifactId>
                <configuration>
                    <failOnUnsupportedJava>false</failOnUnsupportedJava>
                    <bundledSignatures>
                        <!-- 2.7 forbidden APIs -->
                        <bundledSignature>jdk-unsafe</bundledSignature>
                        <bundledSignature>jdk-deprecated</bundledSignature>
                        <bundledSignature>jdk-internal</bundledSignature>
                        <bundledSignature>jdk-non-portable</bundledSignature>
                        <bundledSignature>jdk-reflection</bundledSignature>
                    </bundledSignatures>
                    <suppressAnnotations>
                        <suppressAnnotation>javax.annotation.processing.Generated</suppressAnnotation>
                        <suppressAnnotation>lombok.Generated</suppressAnnotation>
                    </suppressAnnotations>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                            <goal>testCheck</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.nbbrd.heylogs</groupId>
                <artifactId>heylogs-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <inherited>false</inherited>
                        <configuration>
                            <semver>true</semver>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Disable some plugins to accelerate the build -->
        <profile>
            <id>fast-build</id>
            <properties>
                <enforcer.skip>true</enforcer.skip>
                <modernizer.skip>true</modernizer.skip>
                <heylogs.skip>true</heylogs.skip>
            </properties>
        </profile>

        <!-- Base deploy -->
        <profile>
            <id>base-deploy</id>
            <build>
                <plugins>
                    <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-empty-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <sourcepath>${project.build.directory}/no-source</sourcepath>
                            <quiet>true</quiet>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.simplify4u.plugins</groupId>
                        <artifactId>sign-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Deploy SNAPSHOTS to OSSRH -->
        <profile>
            <id>snapshot-deploy</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
                </snapshotRepository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Deploy RELEASES to OSSRH -->
        <profile>
            <id>release-deploy</id>
            <distributionManagement>
                <repository>
                    <id>ossrh</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>jdemetra-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>
