<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2023 The original authors

     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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  
  <groupId>dev.morling.demos</groupId>
  <artifactId>average</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  
  <properties>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <maven.compiler.release>21</maven.compiler.release>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

  <name>My OSS Project</name>
  <description>My Latest OSS Project</description>
  <inceptionYear>2021</inceptionYear>
  <url>tbd.</url>

  <licenses>
    <license>
      <name>Apache-2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.8.1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.21.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <!-- Keep alphabetic order -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>4.1</version>
        </plugin>
        <plugin>
          <groupId>net.revelc.code.formatter</groupId>
          <artifactId>formatter-maven-plugin</artifactId>
          <version>2.16.0</version>
          <configuration>
            <configFile>etc/eclipse-formatter-config.xml</configFile>
            <directories>
              <directory>${project.build.sourceDirectory}</directory>
              <directory>${project.basedir}/src/main/java-22</directory>
            </directories>
          </configuration>
        </plugin>
        <plugin>
          <groupId>net.revelc.code</groupId>
          <artifactId>impsort-maven-plugin</artifactId>
          <version>1.9.0</version>
          <configuration>
            <groups>java.,javax.,org.,com.</groups>
            <removeUnused>true</removeUnused>
            <staticAfter>true</staticAfter>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.12.1</version>
          <configuration>
            <parameters>true</parameters>
            <compilerArgs>
              <!--
                IntelliJ does not yet support the enablePreview configuration option.
                Therefore, we use a compiler argument.
                See https://youtrack.jetbrains.com/issue/IDEA-296303
              -->
              <compilerArg>--enable-preview</compilerArg>
              <compilerArg>--add-modules</compilerArg>
              <compilerArg>java.base,jdk.incubator.vector</compilerArg>
              <compilerArg>--add-opens=java.base/java.lang=ALL-UNNAMED</compilerArg>
              <compilerArg>--add-opens=java.base/jdk.internal.util=ALL-UNNAMED</compilerArg>
            </compilerArgs>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.1.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.1.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.12.1</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.2.3</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-wrapper-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>

  </build>
  <profiles>
    <profile>
      <id>ci</id>
      <build>
        <plugins>
          <plugin>
            <groupId>net.revelc.code.formatter</groupId>
            <artifactId>formatter-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>validate-format</id>
                <goals>
                  <goal>validate</goal>
                </goals>
                <phase>validate</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>qa</id>
      <activation>
        <property>
          <name>!quick</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <configuration>
              <header>etc/license.txt</header>
              <strictCheck>true</strictCheck>
              <aggregate>true</aggregate>
              <excludes>
                <exclude>LICENSE.txt</exclude>
                <exclude>**/.dontdelete</exclude>
                <exclude>**/measurements*.txt</exclude>
                <exclude>**/measurements*.out</exclude>
                <exclude>out_expected.txt</exclude>
                <exclude>github_users.txt</exclude>
                <!-- Cliff asked to be named as the copyright holder for his entry; -->
                <exclude>src/main/java/dev/morling/onebrc/CalculateAverage_cliffclick.java</exclude>
                <exclude>.sdkmanrc</exclude>
              </excludes>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>check</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>net.revelc.code.formatter</groupId>
            <artifactId>formatter-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>format</id>
                <goals>
                  <goal>format</goal>
                </goals>
                <phase>process-sources</phase>
              </execution>
            </executions>
          </plugin>
<!--          <plugin>-->
<!--            <groupId>net.revelc.code</groupId>-->
<!--            <artifactId>impsort-maven-plugin</artifactId>-->
<!--            <executions>-->
<!--              <execution>-->
<!--                <id>sort-imports</id>-->
<!--                <goals>-->
<!--                  <goal>sort</goal>-->
<!--                </goals>-->
<!--                <phase>process-sources</phase>-->
<!--              </execution>-->
<!--            </executions>-->
<!--          </plugin>-->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <id>enforce-plugin-versions</id>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requireJavaVersion>
                      <version>${maven.compiler.release}</version>
                    </requireJavaVersion>
                    <requirePluginVersions>
                       <banLatest>true</banLatest>
                       <banRelease>true</banRelease>
                       <banSnapshots>true</banSnapshots>
                       <phases>clean,deploy,site</phases>
                    </requirePluginVersions>
                  </rules>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>quick</id>
      <activation>
        <property>
          <name>quick</name>
        </property>
      </activation>
      <properties>
        <skipTests>true</skipTests>
      </properties>
    </profile>
    <profile>
      <id>jdk22</id>
      <activation>
        <jdk>22</jdk>
      </activation>
      <properties>
      </properties>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                <release>22</release>
                <compileSourceRoots>
                  <compileSourceRoot>${project.basedir}/src/main/java-22</compileSourceRoot>
                  <!--
                    Uncomment the next line to build the entire project with jdk22.
                    Currently, some classes fail to compile under jdk22.
                  -->
                  <!-- <compileSourceRoot>${project.build.sourceDirectory}</compileSourceRoot> -->
                </compileSourceRoots>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>
</project>
