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

   <!-- ********************************************** -->
   <!-- ****************** BASE POM ****************** -->
   <!-- ********************************************** -->

   <parent>
      <groupId>com.bernardomg.maven</groupId>
      <artifactId>base-pom</artifactId>
      <version>1.5.3</version>
   </parent>

   <!-- ********************************************** -->
   <!-- **************** PROJECT INFO **************** -->
   <!-- ********************************************** -->

   <groupId>com.bernardomg.maven.skins</groupId>
   <artifactId>docs-maven-skin</artifactId>
   <version>2.3.2</version>

   <name>Docs Maven Skin</name>
   <description>A Maven skin for using Maven Site as a documentation site</description>
   <url>https://github.com/Bernardo-MG/docs-maven-skin</url>
   <inceptionYear>2015</inceptionYear>

   <licenses>
      <license>
         <name>MIT License</name>
         <url>http://www.opensource.org/licenses/mit-license.php</url>
         <distribution>repo</distribution>
      </license>
   </licenses>

   <!-- ********************************************** -->
   <!-- ************ RESOURCES AND SERVICES ********** -->
   <!-- ********************************************** -->

   <scm>
      <connection>scm:git:https://github.com/Bernardo-MG/docs-maven-skin.git</connection>
      <developerConnection>scm:git:https://github.com/Bernardo-MG/docs-maven-skin.git</developerConnection>
      <tag>head</tag>
      <url>https://github.com/Bernardo-MG/docs-maven-skin</url>
   </scm>

   <issueManagement>
      <system>GitHub</system>
      <url>https://www.github.com/bernardo-mg/docs-maven-skin/issues</url>
   </issueManagement>

   <ciManagement>
      <system>GitHub workflow</system>
      <url>https://github.com/Bernardo-MG/docs-maven-skin/actions</url>
      <notifiers />
   </ciManagement>

   <!-- ********************************************** -->
   <!-- ****************** PROFILES ****************** -->
   <!-- ********************************************** -->

   <profiles>
      <!-- ============================================== -->
      <!-- ============ DEPLOYMENT PROFILES ============= -->
      <!-- ============================================== -->
      <profile>
         <!-- Site deployment profile -->
         <!-- Sets the site repository to point to the releases repo -->
         <id>deployment-site</id>
         <activation>
            <!-- Active by default so the repository appears in the reports -->
            <activeByDefault>true</activeByDefault>
         </activation>
         <distributionManagement>
            <site>
               <id>site</id>
               <name>Project Documentation Site</name>
               <!-- The URL should be set externally -->
               <url>${site.url}</url>
            </site>
         </distributionManagement>
      </profile>
      <profile>
         <!-- GitHub deployment profile. -->
         <id>deployment-github</id>
         <distributionManagement>
            <repository>
               <!-- GitHub repository -->
               <id>github</id>
               <name>GitHub Packages</name>
               <url>https://maven.pkg.github.com/Bernardo-MG/docs-maven-skin</url>
            </repository>
         </distributionManagement>
      </profile>
      <profile>
         <!-- OSSRH deployment profile. -->
         <id>deployment-ossrh</id>
         <distributionManagement>
            <repository>
               <!-- OSSRH repository -->
               <id>ossrh</id>
               <name>Central Repository OSSRH</name>
               <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
            </repository>
            <snapshotRepository>
               <!-- OSSRH snapshots repository -->
               <id>ossrh</id>
               <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            </snapshotRepository>
         </distributionManagement>
         <build>
            <plugins>
               <plugin>
                  <!-- GPG -->
                  <!-- Signs the artifacts -->
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-gpg-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                           <goal>sign</goal>
                        </goals>
                     </execution>
                  </executions>
                  <configuration>
                     <!-- Prevent gpg from using pinentry programs -->
                     <gpgArguments>
                        <arg>--pinentry-mode</arg>
                        <arg>loopback</arg>
                     </gpgArguments>
                  </configuration>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>

   <!-- ********************************************** -->
   <!-- *********** ORGANIZATION AND MEMBERS ********* -->
   <!-- ********************************************** -->

   <organization>
      <name>Bernardo Martínez Garrido</name>
      <url>https://github.com/Bernardo-MG</url>
   </organization>

   <developers>
      <developer>
         <id>bmg</id>
         <name>Bernardo Martínez Garrido</name>
         <email>programming@bernardomg.com</email>
         <url>https://github.com/Bernardo-MG</url>
         <roles>
            <role>Developer</role>
         </roles>
         <timezone>+1</timezone>
         <properties />
      </developer>
   </developers>

   <contributors>
      <contributor>
         <name>Collin Doyle Brooks</name>
         <email>collin.brooks@gmail.com</email>
         <url>https://github.com/cobhimself</url>
         <roles>
            <role>Developer</role>
         </roles>
         <timezone>-6</timezone>
      </contributor>
      <contributor>
         <name>Hunter Anderson</name>
         <email>ghunteranderson@gmail.com</email>
         <url>https://github.com/ghunteranderson</url>
         <roles>
            <role>Developer</role>
         </roles>
         <timezone>-6</timezone>
      </contributor>
      <contributor>
         <name>Oscar Korz</name>
         <email>okorz001@gmail.com</email>
         <url>https://github.com/okorz001</url>
         <roles>
            <role>Developer</role>
         </roles>
         <timezone>-6</timezone>
      </contributor>
   </contributors>

   <!-- ********************************************** -->
   <!-- **************** PROPERTIES ****************** -->
   <!-- ********************************************** -->

   <properties>
      <!-- ============================================== -->
      <!-- =============== MAVEN VERSION ================ -->
      <!-- ============================================== -->
      <maven.version>3.6.0</maven.version>
      <!-- ============================================== -->
      <!-- =============== MANIFEST DATA ================ -->
      <!-- ============================================== -->
      <manifest.name>com/bernardomg/maven/skins/docs-maven-skin</manifest.name>
      <!-- ============================================== -->
      <!-- =========== DEPENDENCIES VERSIONS ============ -->
      <!-- ============================================== -->
      <hamcrest.version>1.3</hamcrest.version>
      <jsoup.version>1.15.3</jsoup.version>
      <siteFixer.version>1.3.1</siteFixer.version>
      <velocity.configTool.version>1.3.1</velocity.configTool.version>
      <!-- ============================================== -->
      <!-- ============== PLUGINS VERSIONS ============== -->
      <!-- ============================================== -->
      <plugin.frontend.node.version>v18.12.1</plugin.frontend.node.version>
      <plugin.frontend.npm.version>8.19.2</plugin.frontend.npm.version>
      <plugin.frontend.version>1.12.1</plugin.frontend.version>
      <plugin.invoker.version>3.4.0</plugin.invoker.version>
      <plugin.minify.version>1.7.6</plugin.minify.version>
      <!-- ============================================== -->
      <!-- ================= MAVEN SITE ================= -->
      <!-- ============================================== -->
      <site.skin.version>2.3.1</site.skin.version>
      <mavenURL>https://mvnrepository.com/artifact/${project.groupId}/${project.artifactId}</mavenURL>
      <githubArtifactURL><![CDATA[https://github.com/Bernardo-MG?tab=packages&amp;repo_name=docs-maven-skin]]></githubArtifactURL>
   </properties>

   <!-- ********************************************** -->
   <!-- *************** DEPENDENCIES ***************** -->
   <!-- ********************************************** -->

   <dependencies>
      <dependency>
         <!-- Maven Site Fixer -->
         <groupId>com.bernardomg.velocity</groupId>
         <artifactId>maven-site-fixer</artifactId>
         <version>${siteFixer.version}</version>
      </dependency>
      <dependency>
         <!-- Velocity config tool -->
         <groupId>com.bernardomg.velocity</groupId>
         <artifactId>velocity-config-tool</artifactId>
         <version>${velocity.configTool.version}</version>
      </dependency>
   </dependencies>

   <!-- ********************************************** -->
   <!-- ******************* BUILD ******************** -->
   <!-- ********************************************** -->

   <build>
      <defaultGoal>clean package install</defaultGoal>
      <resources>
         <resource>
            <directory>src/main/resources/</directory>
         </resource>
         <resource>
            <!-- Filter skin template to add generator version -->
            <directory>src/main/resources/</directory>
            <includes>
               <include>META-INF/maven/*</include>
            </includes>
            <filtering>true</filtering>
         </resource>
      </resources>
      <pluginManagement>
         <plugins>
            <plugin>
               <!-- Frontend Plugin -->
               <!-- Manages frontend dependencies -->
               <groupId>com.github.eirslett</groupId>
               <artifactId>frontend-maven-plugin</artifactId>
               <version>${plugin.frontend.version}</version>
            </plugin>
            <plugin>
               <!-- Maven Invoker -->
               <!-- Runs the IT test -->
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-invoker-plugin</artifactId>
               <version>${plugin.invoker.version}</version>
            </plugin>
         </plugins>
      </pluginManagement>
      <plugins>
         <plugin>
            <!-- Changes -->
            <!-- Takes care of the changes log -->
            <!-- It is set to also validate the changes log file -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-changes-plugin</artifactId>
            <executions>
               <!-- Changes plugin is bound to the pre-site phase -->
               <execution>
                  <id>check-changes</id>
                  <phase>pre-site</phase>
                  <goals>
                     <goal>changes-check</goal>
                  </goals>
               </execution>
               <execution>
                  <id>validate-changes</id>
                  <phase>pre-site</phase>
                  <goals>
                     <goal>changes-validate</goal>
                  </goals>
                  <configuration>
                     <failOnError>true</failOnError>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <!-- Clean -->
            <!-- Deletes the Maven project generated files -->
            <artifactId>maven-clean-plugin</artifactId>
            <configuration>
               <filesets>
                  <fileset>
                     <directory>/</directory>
                     <includes>
                        <include>node_modules/**/*</include>
                     </includes>
                     <followSymlinks>false</followSymlinks>
                  </fileset>
               </filesets>
            </configuration>
         </plugin>
         <plugin>
            <!-- Site -->
            <!-- Generates the Maven Site -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <dependencies>
               <dependency>
                  <!-- Docs Maven Skin -->
                  <groupId>com.bernardomg.maven.skins</groupId>
                  <artifactId>docs-maven-skin</artifactId>
                  <version>${site.skin.version}</version>
               </dependency>
            </dependencies>
         </plugin>
         <plugin>
            <!-- Resources -->
            <!-- Handles the project resources. -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
               <!-- Variables to to override will be delimited with a @. -->
               <!-- This avoids collisions with Velocity variables. -->
               <!-- So instead of replacing ${project.name} Maven will replace @project.name@. -->
               <useDefaultDelimiters>false</useDefaultDelimiters>
               <delimiters>
                  <delimiter>@</delimiter>
               </delimiters>
            </configuration>
            <executions>
               <execution>
                  <!-- Frontend dependencies are acquired with npm and copied to the libs folder -->
                  <id>copy-site-dependencies</id>
                  <phase>process-resources</phase>
                  <goals>
                     <goal>copy-resources</goal>
                  </goals>
                  <configuration>
                     <outputDirectory>${basedir}/target/classes/lib/</outputDirectory>
                     <resources>
                        <resource>
                           <!-- Copies frontend libraries -->
                           <directory>node_modules/</directory>
                           <includes>
                              <include>bootstrap/dist/js/bootstrap.min.js</include>
                              <include>bootswatch/dist/*/bootstrap.min.css</include>
                           </includes>
                        </resource>
                        <resource>
                           <!-- Copies Font Awesome into a custom folder -->
                           <directory>node_modules/@fortawesome/fontawesome-free</directory>
                           <targetPath>font-awesome</targetPath>
                           <includes>
                              <include>css/all.min.css</include>
                              <include>webfonts/*.*</include>
                           </includes>
                        </resource>
                        <resource>
                           <!-- Copies popperjs into a custom folder -->
                           <directory>node_modules/@popperjs</directory>
                           <targetPath>popperjs</targetPath>
                           <includes>
                              <include>core/dist/umd/popper.min.js</include>
                           </includes>
                        </resource>
                     </resources>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <!-- Maven Invoker -->
            <!-- Runs the IT test -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <configuration>
               <projectsDirectory>src/test/resources/it</projectsDirectory>
               <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
               <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
               <postBuildHookScript>verify</postBuildHookScript>
               <parallelThreads>1.5C</parallelThreads>
               <goals>
                  <goal>site</goal>
               </goals>
            </configuration>
            <dependencies>
               <dependency>
                  <!-- Hamcrest -->
                  <groupId>org.hamcrest</groupId>
                  <artifactId>hamcrest-all</artifactId>
                  <version>${hamcrest.version}</version>
               </dependency>
               <dependency>
                  <!-- JSoup -->
                  <groupId>org.jsoup</groupId>
                  <artifactId>jsoup</artifactId>
                  <version>${jsoup.version}</version>
               </dependency>
            </dependencies>
            <executions>
               <execution>
                  <id>verify-sites</id>
                  <goals>
                     <goal>install</goal>
                     <goal>run</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <!-- Frontend Plugin -->
            <!-- Manages frontend dependencies -->
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <configuration>
               <installDirectory>target</installDirectory>
            </configuration>
            <executions>
               <execution>
                  <!-- Installs the frontend frameworks -->
                  <!-- Installs Node and npm -->
                  <id>frontend-framework</id>
                  <goals>
                     <goal>install-node-and-npm</goal>
                  </goals>
                  <configuration>
                     <nodeVersion>${plugin.frontend.node.version}</nodeVersion>
                     <npmVersion>${plugin.frontend.npm.version}</npmVersion>
                  </configuration>
               </execution>
               <execution>
                  <!-- Installs the frontend dependencies -->
                  <!-- Installs npm dependencies -->
                  <id>frontend-dependencies</id>
                  <goals>
                     <goal>npm</goal>
                  </goals>
                  <configuration>
                     <arguments>install</arguments>
                  </configuration>
               </execution>
               <execution>
                  <!-- Validate CSS -->
                  <id>validate-css</id>
                  <goals>
                     <goal>npm</goal>
                  </goals>
                  <phase>test</phase>
                  <configuration>
                     <arguments>run validate-css</arguments>
                  </configuration>
               </execution>
               <execution>
                  <!-- Minify CSS -->
                  <id>minify-css</id>
                  <goals>
                     <goal>npm</goal>
                  </goals>
                  <phase>process-resources</phase>
                  <configuration>
                     <arguments>run minify-css</arguments>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>

   <!-- ********************************************** -->
   <!-- ****************** REPORTS ******************* -->
   <!-- ********************************************** -->

   <reporting>
      <plugins>
         <plugin>
            <!-- Maven Invoker -->
            <!-- IT tests report -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
         </plugin>
      </plugins>
   </reporting>

</project>
