<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>
	<parent>
		<groupId>org.cibseven.webapp</groupId>
		<artifactId>cibseven-webclient</artifactId>
		<version>2.2.0</version>
	</parent>
	<artifactId>cibseven-webclient-web-spring-boot-4</artifactId>
	<packaging>war</packaging>
	<name>CIB seven webclient web (Spring Boot 4)</name>
	<description>Web application module for the CIB seven webclient platform (Spring Boot 4.x).</description>

	<!-- All version numbers live in the parent pom's <properties>; this flavour selects the
	     SB4 variants (version.spring.boot4, version.openapi-starter-webmvc-ui4, version.tomcat). -->

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-dependencies</artifactId>
				<version>${version.spring.boot4}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<!--
				Apache Tomcat 11.x line for Spring Boot 4. The SB4 BOM pins 11.0.21, which is
				affected by the same CVEs as 10.1.54 (fixed in 11.0.22). These entries override the
				parent's SB3 tomcat-embed management (10.1.55) for this module — see CVE-2026-41293,
				-43512, -43515, -41284, -43513, -42498, -43514.
			-->
			<dependency>
				<groupId>org.apache.tomcat.embed</groupId>
				<artifactId>tomcat-embed-core</artifactId>
				<version>${version.tomcat}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.tomcat.embed</groupId>
				<artifactId>tomcat-embed-el</artifactId>
				<version>${version.tomcat}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.tomcat.embed</groupId>
				<artifactId>tomcat-embed-websocket</artifactId>
				<version>${version.tomcat}</version>
			</dependency>
			<!--
				Force convergence between the version brought by common-auth
				(2.2.36) and the one brought by springdoc 3.0.2 (2.2.43).
				The SB4 BOM doesn't pin swagger-annotations-jakarta itself.
			-->
			<dependency>
				<groupId>io.swagger.core.v3</groupId>
				<artifactId>swagger-annotations-jakarta</artifactId>
				<version>2.2.43</version>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>

		<dependency>
			<groupId>org.cibseven.webapp</groupId>
			<artifactId>cibseven-webclient-core</artifactId>
			<version>${project.version}</version>
			<!--
				cibseven-webclient-core compiles against Jackson 2 (com.fasterxml.jackson.*).
				SB4 ships Jackson 3 (tools.jackson.*) by default; we add Jackson 2
				back explicitly below so the shared code still works at runtime.
			-->
		</dependency>

		<!--
			Spring Boot 4 renamed spring-boot-starter-web to spring-boot-starter-webmvc.
			Also pulls in tools.jackson (Jackson 3) for the wire layer.
		-->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-webmvc</artifactId>
		</dependency>
		
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>

		<!-- New in SB4: replaces RestTemplate idiom -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-restclient</artifactId>
		</dependency>

		<!--
			Jackson 2 (com.fasterxml.jackson.*) — added explicitly because SB4 no
			longer bundles it. cibseven-webclient-core's REST providers / model
			classes use Jackson 2 ObjectMapper / JsonNode directly; this keeps them
			working. Coexists with Jackson 3 (tools.jackson.*) since they're in
			different top-level packages.
		-->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${version.jackson2}</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.datatype</groupId>
			<artifactId>jackson-datatype-jsr310</artifactId>
			<version>${version.jackson2}</version>
		</dependency>

		<dependency>
			<groupId>org.springdoc</groupId>
			<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
			<version>${version.openapi-starter-webmvc-ui4}</version>
			<exclusions>
				<exclusion>
					<groupId>org.apache.commons</groupId>
					<artifactId>commons-lang3</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
			<version>${version.commons-lang3}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-validation</artifactId>
		</dependency>

		<dependency>
			<groupId>jakarta.servlet</groupId>
			<artifactId>jakarta.servlet-api</artifactId>
			<scope>provided</scope>
		</dependency>

	</dependencies>

	<build>
		<finalName>webapp</finalName>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>false</filtering>
				<includes>
					<include>application*.yaml</include>
					<include>*.jpg</include>
					<include>*.txt</include>
					<include>**/*.scss</include>
					<include>META-INF/**</include>
				</includes>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<executions>
					<execution>
						<id>create-jar</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<phase>package</phase>
						<configuration>
							<classifier>classes</classifier>
							<excludes>
							    <!-- Do not pack the public/ folder into the classes jar, as that causes trouble when embedding the engine. -->
								<exclude>public/**</exclude>
							</excludes>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<id>clean-webapp-folder</id>
						<phase>validate</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target>
								<delete includeemptydirs="true">
									<fileset dir="${project.basedir}/src/main/webapp">
										<exclude name="README.md"/>
									</fileset>
								</delete>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<version>${maven-resources-plugin.version}</version>
				<executions>
					<execution>
						<id>replace-data-banner</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<overwrite>true</overwrite>
							<outputDirectory>${project.basedir}/src/main/resources</outputDirectory>
							<resources>
								<resource>
									<directory>${project.parent.basedir}/banner</directory>
									<filtering>true</filtering>
									<includes>
										<include>banner.txt</include>
									</includes>
									<targetPath>.</targetPath>
								</resource>
							</resources>
						</configuration>
					</execution>
					<execution>
						<id>copy-frontend-resources</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>src/main/webapp</outputDirectory>
							<resources>
								<resource>
									<directory>../frontend/dist</directory>
									<includes>
										<include>**/*</include>
									</includes>
									<targetPath>.</targetPath>
								</resource>
							</resources>
						</configuration>
					</execution>
					<execution>
						<id>copy-cibseven-webclient-npm-resources</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/classes/public</outputDirectory>
							<overwrite>true</overwrite>
							<resources>
								<resource>
									<directory>${project.parent.basedir}/frontend/dist</directory>
									<includes>
										<include>**/*</include>
									</includes>
									<targetPath>.</targetPath>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<warSourceExcludes>**/README.md</warSourceExcludes>
				</configuration>
			</plugin>

			<plugin>
				<groupId>io.github.git-commit-id</groupId>
				<artifactId>git-commit-id-maven-plugin</artifactId>
				<version>${git-commit-id-maven-plugin.version}</version>
				<configuration>
					<skip>false</skip>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<version>${version.spring.boot4}</version>
				<configuration>
					<fork>true</fork>
					<mainClass>org.cibseven.webapp.SevenWebclientApplication</mainClass>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
							<goal>build-info</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<configuration>
					<skip>false</skip>
					<container>
						<appRoot>/usr/local/tomcat/webapps/seven</appRoot>
					</container>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<executions>
					<execution>
						<id>wildfly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>assembly-war-wildfly.xml</descriptor>
							</descriptors>
							<classifier>wildfly</classifier>
							<attach>true</attach>
							<outputDirectory>target/</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>

	</build>
</project>
