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

    <parent>
        <groupId>org.simplejavamail</groupId>
        <artifactId>maven-master-project</artifactId>
        <version>9.3.5</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>batch-module</artifactId>
    <packaging>jar</packaging>
    <name>Simple Java Mail - Batch module</name>
    <description>Simple API, Complex Emails. High performance.</description>

    <properties>
        <automaticModuleName>org.simplejavamail.batch</automaticModuleName>
    </properties>

    <dependencies>

        <!-- core dependencies -->
        <dependency>
            <groupId>org.simplejavamail</groupId>
            <artifactId>core-module</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- needed for pooling SMTP (JavaMail Transport) connections -->
        <dependency>
            <groupId>org.simplejavamail</groupId>
            <artifactId>smtp-connection-pool</artifactId>
            <version>4.2.0</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>verify-jpms-module-path</id>
            <activation>
                <jdk>[9,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.11.0</version>
                        <executions>
                            <execution>
                                <id>build-jpms-module-path</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>build-classpath</goal>
                                </goals>
                                <configuration>
                                    <includeArtifactIds>jakarta.mail-api,jakarta.activation-api,generic-object-pool,clustered-object-pool,smtp-connection-pool</includeArtifactIds>
                                    <includeScope>compile</includeScope>
                                    <outputFile>${project.build.directory}/jpms-module-path.txt</outputFile>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>verify-jpms-module-path</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <loadfile property="dependencyModulePath"
                                                  srcFile="${project.build.directory}/jpms-module-path.txt" />
                                        <mkdir dir="${project.build.directory}/jpms-consumer-classes" />
                                        <javac srcdir="${project.basedir}/src/test/jpms"
                                               destdir="${project.build.directory}/jpms-consumer-classes"
                                               modulepath="${project.build.directory}/${project.build.finalName}.jar${path.separator}${dependencyModulePath}"
                                               release="9"
                                               includeantruntime="false" />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
