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

    <groupId>org.voltdb</groupId>
    <version>15.0.0</version>

    <artifactId>volt-procedure-api</artifactId>
    <name>Volt Procedure API</name>
    <description>VoltDB stored procedure API library</description>
    <url>https://github.com/VoltDB/voltdb</url>

    <packaging>jar</packaging>

    <properties>
        <voltdbclient.version>15.0.0</voltdbclient.version>
        <junit5.version>5.9.2</junit5.version>

        <!-- plugin versions -->
        <deploy-plugin.version>3.1.2</deploy-plugin.version>
        <gpg-plugin.version>3.1.0</gpg-plugin.version>
        <jar-plugin.version>3.4.2</jar-plugin.version>
        <javadoc-plugin.version>3.11.3</javadoc-plugin.version>
        <surefire-plugin.version>3.2.5</surefire-plugin.version>
        <source-plugin.version>3.3.1</source-plugin.version>

        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <!-- Required Metadata for publishing to Maven Central -->
    <developers>
        <developer>
            <name>Volt Active Data Team</name>
            <email>support@voltactivedata.com</email>
            <organization>Volt Active Data</organization>
            <organizationUrl>https://voltactivedata.com</organizationUrl>
        </developer>
    </developers>
    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://opensource.org/licenses/MIT</url>
        </license>
    </licenses>
    <scm>
        <connection>scm:git:git://github.com/VoltDB/voltdb.git</connection>
        <developerConnection>scm:git:ssh://github.com/VoltDB/voltdb.git</developerConnection>
        <url>https://github.com/VoltDB/voltdb</url>
    </scm>

    <!-- Allow dependencies to be downloaded from maven central if needed -->
    <repositories>
        <repository>
            <id>central</id>
            <name>Maven Central Repository</name>
            <url>https://repo1.maven.org/maven2</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>

        <!-- Internal modules -->
        <dependency>
            <groupId>org.voltdb</groupId>
            <artifactId>voltdbclient</artifactId>
            <version>${voltdbclient.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- test scope only -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit5.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <!-- for running JUnit 5 tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin.version}</version>
            </plugin>


            <!-- Generate source JAR -->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <version>${source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipSource>false</skipSource>
                    <attach>true</attach>
                </configuration>
            </plugin>

            <!-- Generate Javadoc JAR -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${javadoc-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skip>false</skip>

                    <!-- Generate javadoc consistent with Jave version used for compilation-->
                    <source>${maven.compiler.source}</source>

                    <sourcepath>${project.build.sourceDirectory}</sourcepath>

                    <!-- Only generate docs for customer-facing classes -->
                    <subpackages>org.voltdb</subpackages>

                    <!-- Disable most Javadoc warnings for minimal jar -->
                    <additionalJOption>-Xdoclint:none</additionalJOption>
                    <failOnError>false</failOnError>
                    <quiet>true</quiet>
                </configuration>
            </plugin>

            <!-- Enhanced JAR with manifest -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${jar-plugin.version}</version>
                <configuration>
                    <archive>
                        <manifestSections>
                            <manifestSection>
                                <name>Credits</name>
                                <manifestEntries>
                                    <Author>Volt Active Data, Inc.</Author>
                                </manifestEntries>
                            </manifestSection>
                            <manifestSection>
                                <name>Shared</name>
                                <manifestEntries>
                                    <Title>Volt Procedure API</Title>
                                    <Date>${maven.build.timestamp}</Date>
                                </manifestEntries>
                            </manifestSection>
                        </manifestSections>
                    </archive>
                </configuration>
            </plugin>

            <!-- GPG plugin for signing -->
            <!-- see <profiles> section below -->

            <!-- deploy plugin - override repository to local, for manual publishing -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>${deploy-plugin.version}</version>
                <configuration>
                    <altDeploymentRepository>local::default::file://${project.build.directory}/staging</altDeploymentRepository>
                </configuration>
            </plugin>

            <!-- See jenkins-lab/publish/Jenkinsfile-volt-procedure-api-publish for publishing details. -->

        </plugins>
    </build>

    <!-- Create a profile "release" so the GPG plugin will only sign the jars when using the command "mvn deploy -Prelease" -->
    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
