<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>org.alfresco.integrations</groupId>
    <artifactId>alfresco-googledrive</artifactId>
    <name>Alfresco / Google Drive Parent</name>
    <version>5.0.0-A1</version>
    <packaging>pom</packaging>

    <scm>
        <connection>scm:git:https://github.com/Alfresco/googledrive.git</connection>
        <developerConnection>scm:git:https://github.com/Alfresco/googledrive.git
        </developerConnection>
        <url>https://github.com/Alfresco/googledrive</url>
        <tag>5.0.0-A1</tag>
    </scm>

    <distributionManagement>
        <repository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>alfresco-public-snapshots</id>
            <url>https://artifacts.alfresco.com/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <!-- Target Java 21 so the AMP also runs on the ACS 25.x family(JRE 17). Switch to 21 once 25.x support ends. -->
        <java.version>17</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <buildnumber>local</buildnumber>
        
        <!-- TEMPORARY (ACS-12297 transition): pinned to RELEASED ACS artifacts so gdrive builds in CI
             before the SDK-move ACS is published. END STATE after the SDK-carrying ACS is released:
             bump this to that release, DELETE the libraries-bom bridge below + the explicit
             google-api-services-* versions in repo-base, and let ACS manage ALL SDK versions (the
             goal of this ticket - ACS as the single source of truth). -->
        <dependency.community.repo.version>26.3.0.11</dependency.community.repo.version>
        <dependency.share.version>26.3.0.5</dependency.share.version>
        <!-- TEMPORARY bridge - remove once the SDK-carrying ACS release manages the Drive SDK. Until
             then released ACS does not manage it, so gdrive supplies the versions here (aligned with
             the version the SDK-carrying platform / GCS connector use). -->
        <google-cloud-libraries-bom.version>26.84.0</google-cloud-libraries-bom.version>

        <!-- Single source of truth for the ACS platform base-image tag the -gd / -share-gd images
             are built FROM (and therefore the ACS version E2E runs against). -->
        <acs.version>latest</acs.version>

        <org.springframework.social-google-version>1.0.0.RELEASE</org.springframework.social-google-version>
        <alfresco.min.version>6.2.0</alfresco.min.version>

        <alfresco.google.config.version>1.0.1</alfresco.google.config.version>

        <app.filtering.enabled>true</app.filtering.enabled>
        <app.amp.folder>src/main/amp</app.amp.folder>
        <app.amp.output.folder>../${project.build.finalName}</app.amp.output.folder>

        <!-- Dual-AMP build; default AMPs leave the SDK "provided"(shipped by ACS); 
        the "bundled" profile flips this to "compile" to self-contain the SDK. -->
        <googledrive.bundled.dependency.scope>provided</googledrive.bundled.dependency.scope>
        <amp.classifier />
        <gdrive.repo.dockerfile>Dockerfile</gdrive.repo.dockerfile>
    </properties>
    
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.alfresco</groupId>
                <artifactId>alfresco-community-repo</artifactId>
                <version>${dependency.community.repo.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- TEMPORARY bridge (ACS-12297): released ACS does not yet manage the Drive SDK, so this
                 supplies those versions. Imported AFTER the ACS BOM so platform libraries (guava,
                 jackson, httpclient, ...) keep the ACS-managed versions. DELETE once the SDK-carrying
                 ACS release manages the SDK -> then ACS is the single source of truth. -->
            <dependency>
                <groupId>com.google.cloud</groupId>
                <artifactId>libraries-bom</artifactId>
                <version>${google-cloud-libraries-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <!-- Platform libraries ACS always ships, kept 'provided' reactor-wide. In the 'bundled' build the
         SDK turns 'compile', so these direct 'provided' declarations (inherited by the packaging
         modules) stop the SDK's transitive copies being bundled. Versions come from the community-repo
         BOM above. -->
    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Explicit versions: not managed by the community-repo BOM. -->
        <dependency>
            <groupId>com.google.j2objc</groupId>
            <artifactId>j2objc-annotations</artifactId>
            <version>3.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.errorprone</groupId>
            <artifactId>error_prone_annotations</artifactId>
            <version>2.28.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    
    <repositories>
        <repository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>${maven.compiler.source}</source>
                        <target>${maven.compiler.target}</target>
                        <encoding>${project.build.sourceEncoding}</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                    <configuration>
                        <tagNameFormat>@{project.version}</tagNameFormat>
                        <useReleaseProfile>false</useReleaseProfile>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.alfresco.maven.plugin</groupId>
                    <artifactId>alfresco-maven-plugin</artifactId>
                    <version>2.0.0</version>
                    <extensions>true</extensions>
                    <configuration>
                        <snapshotToTimestamp>true</snapshotToTimestamp>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>0.48.1</version>
                    <configuration>
                        <!--<verbose>true</verbose>-->
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M4</version>
                    <configuration>
                        <forkCount>1</forkCount>
                        <reuseForks>true</reuseForks>
                    </configuration>
                    <executions>
                        <execution>
                            <id>default-test</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                            <phase>test</phase>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.0.0-M4</version>
                    <configuration>
                        <forkCount>1</forkCount>
                        <reuseForks>true</reuseForks>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>${app.filtering.enabled}</filtering>
            </resource>
            <resource>
                <directory>${app.amp.folder}</directory>
                <targetPath>${app.amp.output.folder}</targetPath>
                <filtering>${app.filtering.enabled}</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>2.0.1.alfresco-1</version>
                <executions>
                    <execution>
                        <id>third-party-licenses</id>
                        <goals>
                            <goal>add-third-party</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <failOnMissing>true</failOnMissing>
                            <excludedScopes>provided,test</excludedScopes>
                            <excludedGroups>org.alfresco</excludedGroups>
                            <failIfWarning>true</failIfWarning>
                            <includedLicenses>https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/includedLicenses.txt</includedLicenses>
                            <licenseMergesUrl>https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/licenseMerges.txt</licenseMergesUrl>
                            <overrideUrl>https://raw.githubusercontent.com/Alfresco/third-party-license-overrides/master/override-THIRD-PARTY.properties</overrideUrl>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <modules>
        <module>alfresco-googledrive-repo-base</module>
        <module>alfresco-googledrive-repo-enterprise</module>
        <module>alfresco-googledrive-repo-community</module>
        <module>alfresco-googledrive-share</module>
        <module>alfresco-googledrive-end-to-end-tests</module>
    </modules>

    <profiles>
        <!-- Builds the self-contained AMPs (SDK bundled, named "+bundled") for ACS versions that do
             not ship the Drive SDK. -->
        <profile>
            <id>bundled</id>
            <properties>
                <googledrive.bundled.dependency.scope>compile</googledrive.bundled.dependency.scope>
                <amp.classifier>+bundled</amp.classifier>
                <gdrive.repo.dockerfile>Dockerfile-bundled</gdrive.repo.dockerfile>
                <acs.version>26.2.1</acs.version>
            </properties>
            <build>
                <plugins>
                    <!-- The zero-dependency guard asserts the AMP bundles nothing; it must not run for the
                         bundled variant, which ships the SDK on purpose. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>**/AmpAddsNoThirdPartyLibrariesTest.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
