<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you 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>

    <parent>
        <groupId>org.apache.causeway</groupId>
        <artifactId>causeway-bom</artifactId>
        <version>4.0.0-M1</version>
        <relativePath>../bom/pom.xml</relativePath>
    </parent>

    <groupId>org.apache.causeway.app</groupId>
    <artifactId>causeway-app-starter-parent</artifactId>
    <packaging>pom</packaging>

    <name>Apache Causeway Starter Parent</name>
    <description>
        Parent pom providing dependency and plugin management for Apache
        Causeway applications
        built with Maven. Builds on top of spring-boot-starter-parent.
    </description>
    <url>https://causeway.apache.org</url>

    <build>
        <pluginManagement>
            <plugins>
                <!-- Compile -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <showDeprecation>false</showDeprecation>
                        <showWarnings>false</showWarnings>
                        <!-- Java compliance level, to be overridden with option
                        maven.compiler.release -->
                    </configuration>
                    <!-- goal:compile binds to phase:compile -->
                    <!-- goal:testCompile binds to phase:test-compile -->
                    <dependencies>
                        <dependency>
                            <groupId>org.ow2.asm</groupId>
                            <artifactId>asm</artifactId>
                            <version>9.9</version>
                        </dependency>
                    </dependencies>
                </plugin>

                <!-- SITE REPORT -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.21.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>3.9.0</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.rat</groupId>
                    <artifactId>apache-rat-plugin</artifactId>
                    <version>0.16.1</version>
                    <configuration>
                        <addDefaultLicenseMatchers>true</addDefaultLicenseMatchers>
                        <excludeSubProjects>true</excludeSubProjects>
                        <excludes>
                            <exclude>**/module-nav.adoc</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>com.approvaltests</groupId>
                <artifactId>approvaltests</artifactId>
                <version>${approvaltests.version}</version>
                <scope>test</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <profiles>

        <profile>
            <id>causeway-app-starter-surefire</id>
            <activation>
                <property>
                    <name>!skip.causeway-app-starter-surefire</name>
                </property>
            </activation>

            <properties>
                <!-- uses maven-surefire-plugin.version, which is declared by
                spring-boot-starter-parent -->
                <maven-surefire-report-plugin.version>3.5.4</maven-surefire-report-plugin.version>

                <skipTests>false</skipTests>
                <skipUTs>${skipTests}</skipUTs>
                <skipITs>${skipTests}</skipITs>
                <skipBDDs>${skipTests}</skipBDDs>
                <surefire-plugin.argLine></surefire-plugin.argLine>
            </properties>

            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <version>${maven-surefire-plugin.version}</version>
                            <executions>
                                <execution>
                                    <id>default-test</id>
                                    <phase>test</phase>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <configuration>
                                        <skipTests>${skipUTs}</skipTests>
                                        <includes>
                                            <include>**/*Test*.java</include>
                                        </includes>
                                        <excludes>
                                            <exclude>**/*Testing.java</exclude>
                                            <exclude>**/*IntegTest*.java</exclude>
                                            <exclude>**/*Abstract*.java</exclude>
                                        </excludes>
                                        <useFile>true</useFile>
                                        <printSummary>true</printSummary>
                                        <reportsDirectory>
                                            ${project.build.directory}/surefire-unittest-reports</reportsDirectory>
                                        <forkCount>1</forkCount>
                                        <reuseForks>true</reuseForks>
                                        <argLine>${surefire-plugin.argLine}</argLine>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>integ-test</id>
                                    <phase>integration-test</phase>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <configuration>
                                        <skipTests>${skipITs}</skipTests>
                                        <includes>
                                            <include>**/*IntegTest*.java</include>
                                        </includes>
                                        <excludes>
                                            <exclude>**/*Abstract*.java</exclude>
                                        </excludes>
                                        <useFile>true</useFile>
                                        <printSummary>true</printSummary>
                                        <reportsDirectory>
                                            ${project.build.directory}/surefire-integtest-reports</reportsDirectory>
                                        <forkCount>1</forkCount>
                                        <reuseForks>true</reuseForks>
                                        <argLine>${surefire-plugin.argLine}</argLine>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>bdd-specs</id>
                                    <phase>integration-test</phase>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <configuration>
                                        <skipTests>${skipBDDs}</skipTests>
                                        <includes>
                                            <include>**/*Spec*.java</include>
                                        </includes>
                                        <excludes>
                                            <exclude>**/*Test.java</exclude>
                                            <exclude>**/*Testing.java</exclude>
                                            <exclude>**/*IntegTest*.java</exclude>
                                            <exclude>**/*Abstract*.java</exclude>
                                        </excludes>
                                        <useFile>true</useFile>
                                        <printSummary>true</printSummary>
                                        <reportsDirectory>
                                            ${project.build.directory}/surefire-bddspecs-reports</reportsDirectory>
                                        <forkCount>1</forkCount>
                                        <reuseForks>true</reuseForks>
                                        <argLine>${surefire-plugin.argLine}</argLine>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-report-plugin</artifactId>
                            <version>${maven-surefire-report-plugin.version}</version>
                            <configuration>
                                <showSuccess>false</showSuccess>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>test</id>
                                    <phase>test</phase>
                                </execution>
                                <execution>
                                    <id>integration-test</id>
                                    <phase>integration-test</phase>
                                </execution>
                                <execution>
                                    <id>bdd-specs</id>
                                    <phase>integration-test</phase>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>causeway-app-starter-docker</id>
            <activation>
                <property>
                    <name>!skip.causeway-app-starter-docker</name>
                </property>
            </activation>
            <properties>
                <jib-maven-plugin.version>3.4.6</jib-maven-plugin.version>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>com.google.cloud.tools</groupId>
                            <artifactId>jib-maven-plugin</artifactId>
                            <version>${jib-maven-plugin.version}</version>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <!-- running: mvn spring-boot:run -->
        <profile>
            <id>causeway-app-starter-boot</id>
            <activation>
                <property>
                    <name>!skip.causeway-app-starter-boot</name>
                </property>
            </activation>
            <properties>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.springframework.boot</groupId>
                            <artifactId>spring-boot-maven-plugin</artifactId>
                            <version>${spring-boot.version}</version>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>repackage</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>

        <profile>
            <id>apache-release</id>
            <activation>
                <property>
                    <name>apache-release</name>
                </property>
            </activation>
            <properties>
                <skipTests>true</skipTests>
                <altDeploymentRepository>
                    apache.releases.https::default::https://repository.apache.org/service/local/staging/deploy/maven2</altDeploymentRepository>
            </properties>
            <build>
                <plugins>
                    <!-- We want to sign the artifact, the POM, and all attached
                    artifacts -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-release-artifacts</id>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <gpgArguments>
                                <arg>--digest-algo=SHA512</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>github</id>
            <activation>
                <property>
                    <name>github</name>
                </property>
            </activation>
            <distributionManagement>
                <repository>
                    <id>github</id>
                    <name>Github Releases</name>
                    <url>https://maven.pkg.github.com/apache/causeway</url>
                </repository>
            </distributionManagement>
        </profile>

    </profiles>
</project>
