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

    Copyright © 2015 The Gravitee team (http://gravitee.io)

    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>

    <parent>
        <groupId>io.gravitee</groupId>
        <artifactId>gravitee-parent</artifactId>
        <version>22.5.1</version>
    </parent>

    <groupId>io.gravitee.fetcher</groupId>
    <artifactId>gravitee-fetcher-git</artifactId>
    <version>2.1.2</version>

    <name>Gravitee.io APIM - Fetcher - GIT</name>

    <properties>
        <gravitee-bom.version>6.0.60</gravitee-bom.version>
        <gravitee-fetcher-api.version>2.1.0</gravitee-fetcher-api.version>
        <org.eclipse.jgit.version>6.10.1.202505221210-r</org.eclipse.jgit.version>

        <maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version>
        <maven-exec-plugin.version>3.4.1</maven-exec-plugin.version>
        <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
        <!-- Property used by the publication job in CI-->
        <publish-folder-path>graviteeio-apim/plugins/fetchers</publish-folder-path>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Import bom to properly inherit all dependencies -->
            <dependency>
                <groupId>io.gravitee</groupId>
                <artifactId>gravitee-bom</artifactId>
                <version>${gravitee-bom.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Gravitee.io -->
        <dependency>
            <groupId>io.gravitee.fetcher</groupId>
            <artifactId>gravitee-fetcher-api</artifactId>
            <version>${gravitee-fetcher-api.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jgit</groupId>
            <artifactId>org.eclipse.jgit</artifactId>
            <version>${org.eclipse.jgit.version}</version>
        </dependency>

        <!-- Spring dependencies -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test scope -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <!-- Force version of the plugin to avoid a bug: https://issues.apache.org/jira/browse/MRESOURCES-237 -->
            <!-- https://stackoverflow.com/questions/40346225/maven-resources-plugin-symbolic-link-handling -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin.version}</version>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${maven-assembly-plugin.version}</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/assembly/fetcher-assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-resource-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.hubspot.maven.plugins</groupId>
                <artifactId>prettier-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>CircleCI</id>
            <activation>
                <property>
                    <name>env.CI</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <!-- ⚠️ This plugin in used to remove a Git section forcing SSH connection instead of HTTPS  -->
                        <!-- on CircleCI, for extra info see https://discuss.circleci.com/t/github-forced-through-ssh-protocol/5332 -->
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>${maven-exec-plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <executable>git</executable>
                            <arguments>
                                <argument>config</argument>
                                <argument>--global</argument>
                                <argument>--remove-section</argument>
                                <argument>url.ssh://git@github.com</argument>
                            </arguments>
                            <successCodes>
                                <successCode>0</successCode>
                                <successCode>1</successCode>
                            </successCodes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
