<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.green-code-initiative</groupId>
    <artifactId>creedengo-rules-specifications</artifactId>
    <version>3.1.0</version>

    <name>creedengo Rules Specifications repository</name>
    <description>Repository that contains the specifications of every static-analysis rules available in creedengo plugins.</description>
    <url>https://github.com/green-code-initiative/creedengo-rules-specifications</url>

    <inceptionYear>2024</inceptionYear>
    <organization>
        <name>green-code-initiative</name>
        <url>https://github.com/green-code-initiative</url>
    </organization>
    <licenses>
        <license>
            <name>GPL v3</name>
            <url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Gilles GROUSSET</name>
            <email>zippy1978@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Maxime MALGORN</name>
            <email>utarwyn@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Geoffrey LALLOUÉ</name>
            <email>glalloue@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>David DE CARVALHO</name>
            <email>dedece35@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Olivier LE GOAËR</name>
            <email>olegoaer@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Julien HERTOUT</name>
            <email>jhertout@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Jules DELECOUR</name>
            <email>jules-delecour-dav@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Maxime DUBOIS</name>
            <email>mdubois81@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Vianney DE BELLABRE</name>
            <email>Djoums@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Jérôme CARDON</name>
            <email>jay-79@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Justin BERQUE</name>
            <email>JBerque@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Johanna DUIGOU</name>
            <email>jduigoudev@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
        <developer>
            <name>Jean-Yves CRONIER</name>
            <email>jycr@users.noreply.github.com</email>
            <organization>green-code-initiative</organization>
            <organizationUrl>https://github.com/green-code-initiative</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/green-code-initiative/creedengo-rules-specifications</connection>
        <developerConnection>scm:git:https://github.com/green-code-initiative/creedengo-rules-specifications</developerConnection>
        <url>https://github.com/green-code-initiative/creedengo-rules-specifications</url>
        <tag>HEAD</tag>
    </scm>
    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/green-code-initiative/creedengo-rules-specifications/issues</url>
    </issueManagement>

    <properties>
        <!--
            Default version when disabling Maven `maven-git-versioning-extension` extension
            cf. https://github.com/qoomon/maven-git-versioning-extension#intellij&#45;&#45;-multi-modules-projects
        -->
        <revision>current-SNAPSHOT</revision>

        <!-- Helps ensure build reproducibility (cf. https://maven.apache.org/guides/mini/guide-reproducible-builds.html) -->
        <!--suppress UnresolvedMavenProperty -->
        <project.build.outputTimestamp>${git.commit.timestamp.datetime}</project.build.outputTimestamp>

        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <!-- to prevent message: system modules path not set in conjunction with -source 11 -->
        <maven.compiler.release>${java.version}</maven.compiler.release>

        <encoding>UTF-8</encoding>
        <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
        <project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>6.1.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-bom</artifactId>
                <version>3.27.7</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- dependencies used by build code (cf. ${project.basedir}/build/java} -->
        <dependency>
            <groupId>jakarta.json</groupId>
            <artifactId>jakarta.json-api</artifactId>
            <version>2.1.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.json</artifactId>
            <version>2.0.1</version>
            <classifier>module</classifier>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <!-- TO KEEP : to fix sonar plugin version for CICD and execute sonar:sonar on github CI -->
                <plugin>
                    <groupId>org.sonarsource.scanner.maven</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>5.5.0.6356</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.6.3</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <!-- Do not specify version upper maven wrapper (cf. ./.mvn/wrapper/maven-wrapper.properties#line=19 -->
                                    <version>3.9.9</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--
                    This plugin convert ASCIIDOC rule specification in HTML format
                    ASCIIDOC format is used with custom features such as :
                    - syntax highlighting (see code blocks on ASCIIDOC rules)
                    - inclusions (see: php/EC74.asciidoc)
                    - table data generation from CSV (see: php/EC69.asciidoc)
                -->
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>convert-to-html</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${project.basedir}/src/main/rules</sourceDirectory>
                            <outputDirectory>${project.build.directory}/rules-html</outputDirectory>
                            <attributes>
                                <source-highlighter>coderay</source-highlighter>
                                <coderay-css>style</coderay-css>
                            </attributes>
                            <preserveDirectories>true</preserveDirectories>
                            <embedAssets>true</embedAssets>
                            <standalone>false</standalone>
                            <relativeBaseDir>true</relativeBaseDir>
                            <logHandler>
                                <failIf>
                                    <severity>ERROR</severity>
                                </failIf>
                            </logHandler>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.6.1</version>
                <executions>
                    <execution>
                        <id>add-build-code-source</id>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.basedir}/maven-build/main/java</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-build-code-resource</id>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/maven-build/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-test-build-code-source</id>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.basedir}/maven-build/test/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.5.0</version>
				<configuration>
					<excludes>
						<exclude>org/greencodeinitiative/mavenbuildtool/**</exclude>
					</excludes>
				</configuration>
			</plugin>
            <plugin>
                <!--
                    Prepare resources tree needed by language.
                    Each metadata JSON file must be in the same folder as the HTML description file for the corresponding language.
                -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.3</version>
                <executions>
                    <execution>
                        <id>run-build-code</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.greencodeinitiative.mavenbuild.ruleexporter.Main</mainClass>
                            <arguments>
                                <argument>${project.build.directory}/rules-html</argument>
                                <argument>${project.build.outputDirectory}/org/green-code-initiative/rules</argument>
                                <argument>${project.build.outputDirectory}/rules.json</argument>
                            </arguments>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.build.directory}/maven-build-classes</additionalClasspathElement>
                            </additionalClasspathElements>
                            <classpathScope>provided</classpathScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--
                    This module produce one artifact by language (with corresponding classifier)
                -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.8.0</version>
                <executions>
                    <execution>
                        <id>assembly-java</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/java.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-php</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/php.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-python</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/python.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-javascript</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/javascript.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-swift</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/swift.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-xml</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/xml.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-csharp</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/csharp.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                    <execution>
                        <id>assembly-html</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>${project.basedir}/src/main/assembly/html.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <appendAssemblyId>true</appendAssemblyId>
                </configuration>
            </plugin>
            <plugin>
                <!--
                Plugin to configure reading sonar-project.properties (via Maven Properties Plugin)
                because SonarQube Scanner for Maven does not support reading sonar-project.properties
                -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.3.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>sonar-project.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.15</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <formats>
                                <format>XML</format>
                            </formats>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>maven-central-publishing</id>
            <!--
                For publishing in Maven Central.
                For more information:
                - https://central.sonatype.org/publish/publish-guide/#deployment
                - https://central.sonatype.org/publish/release/#login-into-ossrh
            -->

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.4.0</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.12.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <stylesheet>java</stylesheet>
                            <doclint>none</doclint>
                        </configuration>
                    </plugin>
                    <plugin>
                        <!--
                            For publishing in Maven Central, GPG key must be published to one of following servers:
                            - keyserver.ubuntu.com
                            - keys.openpgp.org
                            - pgp.mit.edu

                            For more informatino: https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key
                        -->
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.10.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
