<?xml version="1.0"?>
<!--
  ~ Copyright @ 2018 - present 8x8, Inc.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<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.jitsi</groupId>
    <artifactId>jicoco-parent</artifactId>
    <version>1.1-113-g4e7ea8b</version>
    <packaging>pom</packaging>

    <name>jicoco-parent</name>
    <description>Jitsi Common Components (Module Parent)</description>
    <url>https://github.com/jitsi/jicoco</url>

    <organization>
        <name>jitsi.org</name>
        <url>https://jitsi.org</url>
    </organization>

    <developers>
        <developer>
            <id>org.jitsi</id>
            <name>Jitsi Team</name>
            <email>dev@jitsi.org</email>
        </developer>
    </developers>

    <scm>
        <url>https://github.com/jitsi/jicoco</url>
        <connection>scm:git:https://github.com/jitsi/jicoco.git</connection>
        <developerConnection>scm:git:https://github.com/jitsi/jicoco.git</developerConnection>
    </scm>

    <licenses>
        <license>
            <name>Apache-2.0</name>
            <url>https://github.com/jitsi/jicoco/blob/master/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.version>5.8.2</junit.version>
        <kotlin.version>1.6.21</kotlin.version>
        <kotest.version>5.3.0</kotest.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>${project.groupId}</groupId>
                <artifactId>jitsi-utils</artifactId>
                <version>1.0-119-ga7b23ff</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib-jdk8</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <!--
                 Dokka is not added as plugin for all projects because it randomly fails
                 for jicoco, see also https://github.com/Kotlin/dokka/issues/1599
                -->
                <plugin>
                    <groupId>org.jetbrains.dokka</groupId>
                    <artifactId>dokka-maven-plugin</artifactId>
                    <version>${kotlin.version}</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>javadocJar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M6</version>
                <configuration>
                    <systemPropertyVariables>
                        <jersey.config.test.container.port>0</jersey.config.test.container.port>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.gantsign.maven</groupId>
                <artifactId>ktlint-maven-plugin</artifactId>
                <version>1.13.1</version>
                <configuration>
                    <sourceRoots>
                        <sourceRoot>${project.basedir}/src/main/kotlin</sourceRoot>
                    </sourceRoots>
                    <testSourceRoots>
                        <testSourceRoot>${project.basedir}/src/test/kotlin</testSourceRoot>
                    </testSourceRoots>
                </configuration>
                <executions>
                    <execution>
                        <id>check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <version>6.2.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.0.0-M2</version>
            </plugin>
        </plugins>
    </build>

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

    <profiles>
        <!--
         Modules included here will be released to Maven Central and are not
         allowed to include dependencies not in Central, i.e. anything in Jitsi's
         Maven repo on GitHub.
        -->
        <profile>
            <id>central-modules</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <modules>
                <module>jicoco-config</module>
                <module>jicoco-test-kotlin</module>
            </modules>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.13</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
         Modules included here will NOT be released to Maven Central and can
         contain foreign repositories.
        -->
        <profile>
            <id>noncentral-modules</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <modules>
                <module>jicoco</module>
                <module>jicoco-config</module>
                <module>jicoco-test-kotlin</module>
            </modules>

            <repositories>
                <repository>
                    <id>jitsi-maven-repository-releases</id>
                    <layout>default</layout>
                    <name>Jitsi Maven Repository (Releases)</name>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <url>https://github.com/jitsi/jitsi-maven-repository/raw/master/releases/</url>
                </repository>
                <repository>
                    <id>jitsi-maven-repository-snapshots</id>
                    <layout>default</layout>
                    <name>Jitsi Maven Repository (Snapshots)</name>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <url>https://github.com/jitsi/jitsi-maven-repository/raw/master/snapshots/</url>
                </repository>
            </repositories>
        </profile>

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!--
                     Attach Kotlin sources so they get picked up by maven-source-plugin
                    -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/kotlin</source>
                                    </sources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>add-test-source</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>add-test-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/test/kotlin</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.2.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>signing</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>coverage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.8.8</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <!-- attached to Maven test phase -->
                            <execution>
                                <id>report</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
