<?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>de.sonallux.spotify</groupId>
    <artifactId>spotify-web-api-parent</artifactId>
    <version>2022.2.6</version>
    <packaging>pom</packaging>

    <name>spotify-web-api-parent</name>
    <description>Collection of tools for parsing the Spotify Web API</description>
    <url>https://github.com/sonallux/spotify-web-api</url>

    <modules>
        <module>json-utils</module>
        <module>spotify-web-api-open-api</module>
    </modules>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://github.com/sonallux/spotify-web-api/blob/main/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/sonallux/spotify-web-api</connection>
        <url>https://github.com/sonallux/spotify-web-api</url>
    </scm>

    <organization>
        <name>sonallux</name>
        <url>https://github.com/sonallux</url>
    </organization>

    <developers>
        <developer>
            <id>sonallux</id>
            <name>Jonas</name>
            <url>https://github.com/sonallux</url>
        </developer>
    </developers>

    <properties>
        <java.version>11</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Maven plugins -->
        <maven-compiler-plugin.version>3.9.0</maven-compiler-plugin.version>
        <maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
        <maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
        <maven-javadoc-plugin.version>3.3.1</maven-javadoc-plugin.version>
        <maven-source-plugin.version>3.2.1</maven-source-plugin.version>
        <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
        <maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
        <nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
        <moditect-maven-plugin.version>1.0.0.RC2</moditect-maven-plugin.version>

        <!-- Dependencies -->
        <lombok.version>1.18.22</lombok.version>
        <jackson.version>2.12.5</jackson.version>
        <slf4j.version>1.7.35</slf4j.version>
        <picocli.version>4.6.2</picocli.version>

        <!-- Test Dependencies -->
        <junit.version>5.8.2</junit.version>
        <assertj.version>3.22.0</assertj.version>
        <mockito-junit-jupiter.version>4.3.1</mockito-junit-jupiter.version>

        <moditect.sourceGroup>${project.groupId}</moditect.sourceGroup>
        <moditect.sourceArtifact>${project.artifactId}</moditect.sourceArtifact>
        <moditect.sourceVersion>${project.version}</moditect.sourceVersion>
        <moditect.module.name>de.sonallux.spotify</moditect.module.name>
    </properties>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.fasterxml.jackson</groupId>
                <artifactId>jackson-bom</artifactId>
                <version>${jackson.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <release>${java.version}</release>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <release>${java.version}</release>
                    <doclint>-html</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <version>${moditect-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>add-module-infos</id>
                        <phase>package</phase>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <configuration>
                            <overwriteExistingFiles>true</overwriteExistingFiles>
                            <module>
                                <moduleInfoFile>src/moditect/module-info.java</moduleInfoFile>
                            </module>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${nexus-staging-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cli</id>
        </profile>
        <profile>
            <!--
            This profile can be used to generate the module-info.java files by running `.\mvnw -Pmoditect generate-sources`
            The final module-info.java can be found in `target/generated-sources/modules/${moditect.module.name}/`
            Note: for generator-open-api this will fail because com.github.java-json-tools:jackson-coreutils-equivalence
            and com.github.java-json-tools:jackson-coreutils do export the same package `com.github.fge.jackson`.
            This is a split package which is not allowed by the module system. But the module-info.java can still be
            generated by manually executing the jdeps command without the jackson-coreutils-equivalence dependency.
            -->
            <id>moditect</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.moditect</groupId>
                        <artifactId>moditect-maven-plugin</artifactId>
                        <version>${moditect-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>generate-module-info</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>generate-module-info</goal>
                                </goals>
                                <configuration>
                                    <modules>
                                        <module>
                                            <artifact>
                                                <groupId>${moditect.sourceGroup}</groupId>
                                                <artifactId>${moditect.sourceArtifact}</artifactId>
                                                <version>${moditect.sourceVersion}</version>
                                            </artifact>
                                            <moduleInfo>
                                                <name>${moditect.module.name}</name>
                                            </moduleInfo>
                                        </module>
                                    </modules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
