<?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>com.github.codeteapot.maven.plugin-testing</groupId>
    <artifactId>maven-plugin-testing-harness</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    
    <name>Maven Plugin Testing Harness</name>
    <description>Mechanisms to manage tests on Mojo</description>
    <url>https://github.com/codeteapot/maven-plugin-testing-harness</url>
    
    <organization>
        <name>CodeTeapot</name>
        <url>https://github.com/codeteapot</url>
    </organization>
    
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    
    <developers>
        <developer>
            <name>Miquel A. Ferran Gonzalez</name>
            <email>miquel.ferran.gonzalez@gmail.com</email>
            <organization>CodeTeapot</organization>
            <url>https://github.com/codeteapot</url>
        </developer>
    </developers>
    
    <scm>
        <connection>scm:git:git://github.com/codeteapot/maven-plugin-testing-harness.git</connection>
        <developerConnection>scm:git:ssh//github.com:codeteapot/maven-plugin-testing-harness.git</developerConnection>
        <url>https://github.com/codeteapot/maven-plugin-testing-harness/tree/main</url>
    </scm>
    
    <modules>
        <module>maven-plugin-testing-harness-api</module>
        <module>maven-plugin-testing-harness-junit-jupiter</module>
        <module>maven-plugin-testing-harness-plexus</module>
    </modules>
    
    <build>
        <plugins>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.9.1</version>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <!-- mvn antrun:run@release-commit -->
                    <execution>
                        <id>release-commit</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <inherited>false</inherited>
                        <configuration>
                            <target>
                                <exec executable="git">
                                    <arg value="commit"/>
                                    <arg value="-m"/>
                                    <arg value="Release ${release.tag}"/>
                                </exec>
                            </target>
                        </configuration>
                    </execution>
                    <!-- mvn antrun:run@release-tag -->
                    <execution>
                        <id>release-tag</id>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <inherited>false</inherited>
                        <configuration>
                            <target>
                                <exec executable="git" failonerror="true">
                                    <arg value="tag"/>
                                    <arg value="${release.tag}"/>
                                </exec>
                                <exec executable="git">
                                    <arg value="push"/>
                                    <arg value="${release.remoteName}"/>
                                    <arg value="${release.tag}"/>
                                </exec>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
        </plugins>
    </build>
    
    <reporting>
        <plugins>
        
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.1.1</version>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>index</report>
                            <report>summary</report>
                            <report>dependency-info</report>
                            <report>dependencies</report>
                            <!-- Avoiding plugin-management -->
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
            
        </plugins>
    </reporting>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <release.remoteName>origin</release.remoteName>
        <release.tag>v${project.version}</release.tag>
        <checkstyle.configLocation>https://raw.githubusercontent.com/checkstyle/checkstyle/cd9cf0081ef295b9902c8c7074d3fb46a1e4d408/src/main/resources/google_checks.xml</checkstyle.configLocation>
    </properties>
    
    <profiles>
        <profile>
        
            <id>gpg-signer</id>
            
            <build>
                <plugins>
                
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>gpg-sign</id>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <gpgArguments>--pinentry-mode=loopback</gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    
                </plugins>
            </build>
        </profile>
        <profile>
        
            <id>ossrh-deployer</id>
            
            <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>
            
            <build>
                <plugins>
                
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                    
                </plugins>
            </build>
            
        </profile>
        <profile>
        
            <id>gh-pages-deployer</id>
            
            <distributionManagement>
                <site>
                    <id>github</id>
                    <url>scm:git:https://github.com/codeteapot/maven-plugin-testing-harness</url>
                </site>
            </distributionManagement>
            
            <build>
                <plugins>
                
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-deploy</id>
                                <configuration>
                                    <skip>true</skip>
                                </configuration>
                            </execution>
                            <execution>
                                <id>site-stage</id>
                                <goals>
                                    <goal>stage</goal>
                                </goals>
                                <phase>post-site</phase>
                                <configuration>
                                    <stagingDirectory>${project.build.directory}/staging/${release.tag}</stagingDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    
                    <!--
                        It has some prerequisites
                        
                        * Properties "user.name" and "user.email" of GIT configuration must be
                          defined
                        * Branch "gh-pages" must exist on remote
                    -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-publish-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>site-deploy</id>
                                <goals>
                                    <goal>publish-scm</goal>
                                </goals>
                                <phase>site-deploy</phase>
                                <inherited>false</inherited>
                                <configuration>
                                    <checkinComment>Site checkin on ${release.tag}</checkinComment>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <serverId>github.codeteapot</serverId>
                            <scmBranch>gh-pages</scmBranch>
                            <siteOutputEncoding>UTF-8</siteOutputEncoding>
                            <skipDeletedFiles>true</skipDeletedFiles>
                        </configuration>
                    </plugin>
                    
                </plugins>
                <pluginManagement>
                    <plugins>
                        
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-scm-publish-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>site-deploy</id>
                                    <goals>
                                        <goal>publish-scm</goal>
                                    </goals>
                                    <phase>site-deploy</phase>
                                    <configuration>
                                        <checkinComment>Site checkin on ${release.tag} for module ${project.artifactId}</checkinComment>
                                        <pubScmUrl>scm:git:https://github.com/codeteapot/maven-plugin-testing-harness</pubScmUrl>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        
                    </plugins>
                </pluginManagement>
            </build>
            
        </profile>
    </profiles>
    
</project>
