<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.0.0</version>
	</parent>
	<artifactId>cibseven-webclient-web</artifactId>
	<packaging>war</packaging>

	<dependencies>
	    
	    <dependency>
			<groupId>org.cibseven.webapp</groupId>
			<artifactId>cibseven-webclient-core</artifactId>
			<version>${project.version}</version>
		</dependency>
		
		<dependency>
			<groupId>org.springdoc</groupId>
			<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
			<version>${version.openapi-starter-webmvc-ui}</version>
		</dependency>
		
		<!-- Without this, any controller method with parameters annotated with some jakarta.validation.* annotations, 
		such as jakarta.validation.constraints.NotNull, throws the described exception. 
		The exception is thrown by Spring and the method is not even called at all. -->
		<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>*.xml</include> -->
					<include>*.txt</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>
	              </configuration>
	            </execution>
	          </executions>
	        </plugin>
		    
			<!-- Index.html contain projectVersion variable which needs to be
			replace by the current version of the project -->
			<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>src/main/resources/banner</directory>
									<filtering>true</filtering>
									<includes>
										<include>banner.txt</include>
									</includes>
									<targetPath>.</targetPath>
								</resource>
							</resources>
						</configuration>
					</execution>
			        <!-- Add new execution for frontend resources to project root -->
			        <execution>
			            <id>copy-frontend-resources</id>
			            <phase>validate</phase>
			            <goals>
			                <goal>copy-resources</goal>
			            </goals>
			            <configuration>
			                <!-- This puts content at the root of the WAR -->
			                <outputDirectory>src/main/webapp</outputDirectory>
			                <resources>
			                    <resource>
			                        <directory>../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.boot}</version>
				<configuration>
					<fork>true</fork>
					<mainClass>org.cibseven.webapp.Application</mainClass>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
							<!-- Build info for actuator info endpoint-->
							<goal>build-info</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			
			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<configuration>
					<skip>false</skip>
					<!-- https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#extended-usage -->
					<container>
						<appRoot>/opt/bitnami/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>