<?xml version="1.0" encoding="iso-8859-1"?>
<!--

    Copyright (c) 1997, 2024 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<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">
    <parent>
        <groupId>org.eclipse.angus</groupId>
        <artifactId>all</artifactId>
        <version>2.0.4</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>jakarta.mail</artifactId>
    <packaging>jar</packaging>
    <name>Angus Mail default provider</name>

    <properties>
        <mail.version>${project.version}</mail.version>

        <mail.extensionName>jakarta.mail</mail.extensionName>
        <mail.specificationTitle>Jakarta Mail API Design Specification</mail.specificationTitle>
        <mail.implementationTitle>jakarta.mail</mail.implementationTitle>
        <mail.probeFile>META-INF/gfprobe-provider.xml</mail.probeFile>
        <findbugs.skip>false</findbugs.skip>
        <findbugs.exclude>${project.basedir}/exclude.xml</findbugs.exclude>
        <dep.sources>${project.build.directory}/generated-sources/dependencies</dep.sources>
        <dep.sources.version>${project.build.directory}/generated-sources/version</dep.sources.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>provided</includeScope>
                            <classifier>sources</classifier>
                            <excludeArtifactIds>graal-sdk</excludeArtifactIds>
                            <excludeTransitive>true</excludeTransitive>
                            <excludes>
                                module-info.*,META-INF/versions/**,META-INF/MANIFEST.MF,jakarta/mail/Version.java
                            </excludes>
                            <outputDirectory>${dep.sources}</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-version-sources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeArtifactIds>jakarta.mail-api</includeArtifactIds>
                            <includeScope>provided</includeScope>
                            <classifier>sources</classifier>
                            <excludeTransitive>true</excludeTransitive>
                            <includes>jakarta/mail/Version.java</includes>
                            <outputDirectory>${dep.sources}/../version-resources</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-resource</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${dep.sources}</directory>
                                    <excludes>
                                        <exclude>**/*.java</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${dep.sources}</source>
                            </sources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-version-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${dep.sources.version}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>fix-default-provider</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <replace
                                        file="${project.build.directory}/generated-sources/dependencies/jakarta/mail/package-info.java">
                                    <replacefilter>
                                        <replacetoken><![CDATA[com.sun.mail]]></replacetoken>
                                        <replacevalue><![CDATA[org.eclipse.angus.mail]]></replacevalue>
                                    </replacefilter>
                                </replace>
                                <replace
                                        file="${project.build.directory}/generated-sources/dependencies/jakarta/mail/Session.java">
                                    <replacefilter>
                                        <replacetoken><![CDATA[com.sun.mail]]></replacetoken>
                                        <replacevalue><![CDATA[org.eclipse.angus.mail]]></replacevalue>
                                    </replacefilter>
                                </replace>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${dep.sources.version}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${dep.sources}/../version-resources</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Import-Package>
                            org.glassfish.hk2.osgiresourcelocator;resolution:=optional,
                            sun.security.util;resolution:=optional,
                            *
                        </Import-Package>
                        <Require-Capability><![CDATA[
                          osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.processor)
                            (version>=1.0.0)(!(version>=2.0.0)))";resolution:=optional,
                          osgi.serviceloader;filter:="(osgi.serviceloader=jakarta.mail.Provider)";
                            osgi.serviceloader="jakarta.mail.Provider";
                              cardinality:=multiple;resolution:=optional,
                          osgi.serviceloader;filter:="(osgi.serviceloader=jakarta.mail.util.StreamProvider)";
                            osgi.serviceloader="jakarta.mail.util.StreamProvider";
                              cardinality:=multiple;resolution:=optional,
                          osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
                            ]]>
                        </Require-Capability>
                        <Provide-Capability><![CDATA[
                            osgi.serviceloader;
                              osgi.serviceloader="jakarta.mail.util.StreamProvider",
                            osgi.serviceloader;
                              osgi.serviceloader="jakarta.mail.Provider",
                            ]]>
                        </Provide-Capability>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <header><![CDATA[<br>Jakarta Mail API v${mail-api.version}]]></header>
                    <bottom><![CDATA[
Comments to : <a href="mailto:angus-dev@eclipse.org">angus-dev@eclipse.org</a>.<br>
Copyright &#169; 2019, ${current.year} Eclipse Foundation. All rights reserved.<br>
Use is subject to <a href="{@docRoot}/doc-files/speclicense.html" target="_top">license terms</a>.]]>
                    </bottom>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-activation</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Provided dependencies -->
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-mail</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.graalvm.sdk</groupId>
            <artifactId>graal-sdk</artifactId>
            <optional>true</optional>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
