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

	<!-- this must come before <parent> because the version is manually updated
		in build-artifacts.sh -->
	<groupId>org.apache.causeway.app</groupId>
	<artifactId>causeway-app-starter-parent</artifactId>
	<version>3.2.0</version>
	<packaging>pom</packaging>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.4.1</version>
		<relativePath />
	</parent>

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

	<properties>

		<maven.compiler.release>17</maven.compiler.release>

		<spring-boot.version>3.4.1</spring-boot.version>
		<approvaltests.version>24.12.0</approvaltests.version>

		<!-- IMPORTANT: keep in sync with property defined in resteasy-spring-boot-starter -->
		<resteasy.version>6.0.0.Alpha2</resteasy.version>

	</properties>

	<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 -->
				</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.8.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>org.apache.causeway</groupId>
				<artifactId>causeway-bom</artifactId>
				<version>3.2.0</version>
				<scope>import</scope>
				<type>pom</type>
			</dependency>

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

		</dependencies>
	</dependencyManagement>

	<profiles>
		<profile>
			<id>causeway-app-starter-datanucleusenhance</id>
			<activation>
				<file>
					<exists>${basedir}/logging-dn-enhance.properties</exists>
				</file>
			</activation>
			<properties>

				<!-- IMPORTANT: keep in sync with versions used in Apache Causeway, see causeway-bom -->
				<datanucleus-api-jdo.version>6.0.4</datanucleus-api-jdo.version>
				<datanucleus-api-jpa.version>6.0.1</datanucleus-api-jpa.version>
				<datanucleus-core.version>6.0.9</datanucleus-core.version>
				<datanucleus-jodatime.version>6.0.1</datanucleus-jodatime.version>

				<datanucleus-maven-plugin.version>6.0.0-release</datanucleus-maven-plugin.version>

				<datanucleus-maven-plugin.log4jConfiguration>${basedir}/logging-dn-enhance.properties</datanucleus-maven-plugin.log4jConfiguration>
				<datanucleus-maven-plugin.verbose>true</datanucleus-maven-plugin.verbose>
				<datanucleus-maven-plugin.fork>false</datanucleus-maven-plugin.fork>
			</properties>
			<build>
				<plugins>
                    <plugin>
						<groupId>org.datanucleus</groupId>
						<artifactId>datanucleus-maven-plugin</artifactId>
						<version>${datanucleus-maven-plugin.version}</version>
						<configuration>
							<fork>${datanucleus-maven-plugin.fork}</fork>
							<log4jConfiguration>${datanucleus-maven-plugin.log4jConfiguration}</log4jConfiguration>
							<verbose>${datanucleus-maven-plugin.verbose}</verbose>
						</configuration>
						<executions>
							<execution>
								<id>process-classes</id>
								<phase>process-classes</phase>
								<goals>
									<goal>enhance</goal>
								</goals>
							</execution>
							<execution>
								<id>process-test-classes</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>test-enhance</goal>
								</goals>
								<configuration>
									<metadataDirectory>${project.build.testOutputDirectory}</metadataDirectory>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>org.datanucleus</groupId>
								<artifactId>datanucleus-core</artifactId>
								<version>${datanucleus-core.version}</version>
							</dependency>
							<dependency>
								<groupId>org.datanucleus</groupId>
								<artifactId>datanucleus-api-jdo</artifactId>
								<version>${datanucleus-api-jdo.version}</version>
							</dependency>
							<dependency>
								<groupId>org.datanucleus</groupId>
								<artifactId>datanucleus-jodatime</artifactId>
								<version>${datanucleus-jodatime.version}</version>
							</dependency>
						</dependencies>
					</plugin>
				</plugins>
			</build>
		</profile>

		<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.2</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.4</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.7</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>
					<plugin>
						<groupId>net.nicoulaj.maven.plugins</groupId>
						<artifactId>checksum-maven-plugin</artifactId>
						<version>1.11</version>
						<executions>
							<execution>
								<id>source-release-checksum</id>
								<goals>
									<goal>files</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<algorithms>
								<algorithm>SHA-512</algorithm>
							</algorithms>
							<csvSummary>false</csvSummary>
							<fileSets>
								<fileSet>
									<directory>${project.build.directory}</directory>
									<includes>
										<include>${project.artifactId}-${project.version}-source-release.zip</include>
										<include>${project.artifactId}-${project.version}-source-release.tar*</include>
									</includes>
								</fileSet>
							</fileSets>
							<failIfNoFiles>false</failIfNoFiles><!-- usually, no file to do checksum:
								don't consider error -->
						</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>

		<profile>
			<id>nightly-localfs-repo</id>
			<activation>
				<property>
					<name>nightly-localfs-repo</name>
				</property>
			</activation>
			<distributionManagement>
				<repository>
			        <id>nightly-localfs-repo</id>
			        <name>Temporary Local Filesystem Staging Repository</name>
			        <url>file://${MVN_SNAPSHOTS_PATH}</url>
			    </repository>
			</distributionManagement>
			<build>
				<plugins>
					<plugin>
					    <artifactId>maven-deploy-plugin</artifactId>
					    <version>3.1.3</version>
					    <configuration>
					        <altDeploymentRepository>
					            nightly-localfs-repo::file://${MVN_SNAPSHOTS_PATH}
					        </altDeploymentRepository>
					    </configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

	</profiles>
</project>
