<?xml version="1.0"?>
<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>fr.gouv.vitam</groupId>
		<artifactId>ihm-demo</artifactId>
		<version>8.0.3</version>
	</parent>
	<artifactId>ihm-demo-web-application</artifactId>
	<name>ihm-demo-web-application</name>

	<properties>
		<!-- Activate javascript sonar analysis -->
		<sonar.sources>src/main</sonar.sources>
		<sonar.exclusions>**/bower_components/**</sonar.exclusions>
		<unix.name>ihm-demo</unix.name>
		<unix.user>vitam</unix.user>
		<unix.group>vitam</unix.group>
		<jib.skip>true</jib.skip>
	</properties>

	<dependencies>
		<!-- FXME : remove when refactor private/public finished -->
		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>common-public-client</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>common-private</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>ihm-core</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>ihm-demo-common</artifactId>
			<version>${project.version}</version>
		</dependency>

		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>ihm-demo-front</artifactId>
			<version>${project.version}</version>
			<classifier>bundle</classifier>
			<type>zip</type>
			<scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>ingest-external-client</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-web</artifactId>
		</dependency>

		<!-- Jetty -->
		<dependency>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-webapp</artifactId>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-all -->
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-all</artifactId>
			<type>pom</type>
		</dependency>


		<!-- Servlet API -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
		</dependency>

		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
            <groupId>io.rest-assured</groupId>
			<artifactId>rest-assured</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>fr.gouv.vitam</groupId>
			<artifactId>common-junit</artifactId>
			<version>${project.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
			<!-- Include static resources (from ihm-demo-front) -->
			<resource>
				<directory>target/front</directory>
			</resource>
		</resources>

		<plugins>
			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<configuration>
                    <from>
                            <image>gcr.io/distroless/java17</image>
                        </from>
                        <allowInsecureRegistries>true</allowInsecureRegistries>
                        <container>
                            <labels>
                                <git.commit.id>${git.commit.id}</git.commit.id>
                                <mvn.build.version>${project.version}</mvn.build.version>
                            </labels>
                        </container>
				 <to>
				 <image>${env.SERVICE_DOCKER_PUSH_URL}/vitam/ihm-demo</image>
				 <tags>
				    <tag>${git.commit.id.describe-short}</tag>
				 	<tag>${project.version}</tag>
				 </tags>
				</to>
				</configuration>
			</plugin>
			<plugin>
				<!-- Dependency manipulation (copy, unpack) and analysis. -->
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<!-- Extract static ressources into target/front/static folder -->
					<execution>
						<id>unpack-static-resources</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>unpack-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/front/static</outputDirectory>
							<includeGroupIds>fr.gouv.vitam</includeGroupIds>
							<includeArtifactIds>ihm-demo-front</includeArtifactIds>
							<classifier>bundle</classifier>
							<type>zip</type>
							<failOnMissingClassifierArtifact>true</failOnMissingClassifierArtifact>
						</configuration>
					</execution>
					<execution>
						<id>copy-dependencies</id>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
							<includeTypes>jar</includeTypes>
							<includeScope>compile</includeScope>
							<overWriteReleases>false</overWriteReleases>
							<overWriteSnapshots>false</overWriteSnapshots>
							<overWriteIfNewer>true</overWriteIfNewer>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-config-resources</id>
						<phase>validate</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/conf/sysconfig</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}/src/main/conf</directory>
									<filtering>true</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
					<!-- Debian -->
					<execution>
						<id>copy-debian-controlFiles</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/control</outputDirectory>
							<overwrite>true</overwrite>
							<resources>
								<resource>
									<directory>${basedir}/src/deb/control</directory>
									<filtering>true</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<mainClass>fr.gouv.vitam.ihmdemo.appserver.IhmDemoMain</mainClass>
						</manifest>
					</archive>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>rpm-maven-plugin</artifactId>
				<configuration>
					<disabled>false</disabled>
					<license>CeCILL 2.1</license>
					<distribution>Vitam Project</distribution>
					<group>Application/Archiving</group>
					<packager>Vitam Package Team</packager>
					<defineStatements/>
					<targetOS>linux</targetOS>
					<requires>
						<require>systemd</require>
						<require>${jdk.version.rpm}</require>
						<require>vitam-user-${unix.user}</require>
					</requires>
					<defaultDirmode>750</defaultDirmode>
					<defaultFilemode>640</defaultFilemode>
					<defaultUsername>${unix.user}</defaultUsername>
					<defaultGroupname>${unix.group}</defaultGroupname>
					<mappings>
						<mapping>
							<!-- Caution : keep the artifact & dependency copy in the first mapping element ; or else they will be copied in every mapping before... -->
							<directory>/vitam/lib/${unix.name}</directory>
							<!-- Special marker to exclude non-default artefacts (we only need the jar to be packaged) -->
							<artifact>
								<classifiers>
									<classifier/>
								</classifiers>
							</artifact>
							<!-- Exclude ihm-demo-front zip artefact-->
							<dependency>
								<excludes>
									<exclude>fr.gouv.vitam:ihm-demo-front:zip</exclude>
								</excludes>
							</dependency>
						</mapping>
						<mapping>
							<directory>/vitam/conf/${unix.name}</directory>
							<sources>
								<source>
									<location>${project.build.directory}/conf</location>
								</source>
							</sources>
						</mapping>
					</mappings>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.eclipse.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>${jetty.version}</version>
			</plugin>

			<plugin>
				<artifactId>jdeb</artifactId>
				<groupId>org.vafer</groupId>
				<configuration>
					<snapshotExpand>true</snapshotExpand>
					<skip>false</skip>
					<controlDir>${project.build.directory}/control</controlDir>
					<dataSet>

						<!-- Artifacts -->
						<data>
							<src>${project.build.directory}/${project.build.finalName}.jar</src>
							<type>file</type>
							<mapper>
								<type>perm</type>
								<user>${unix.user}</user>
								<group>${unix.group}</group>
								<filemode>0644</filemode>
								<prefix>/vitam/lib/${unix.name}/</prefix>
							</mapper>
						</data>

						<data>
							<src>${project.build.directory}/dependencies</src>
							<type>directory</type>
							<missingSrc>ignore</missingSrc>
							<mapper>
								<type>perm</type>
								<user>${unix.user}</user>
								<group>${unix.group}</group>
								<filemode>0644</filemode>
								<prefix>/vitam/lib/${unix.name}</prefix>
							</mapper>
						</data>
						<data>
							<src>${project.build.directory}/conf</src>
							<type>directory</type>
							<missingSrc>ignore</missingSrc>
							<mapper>
								<type>perm</type>
								<user>${unix.user}</user>
								<group>${unix.group}</group>
								<filemode>0750</filemode>
								<prefix>/vitam/conf/${unix.name}</prefix>
							</mapper>
						</data>
						<!-- Additional templates -->
						<data>
							<type>template</type>
							<paths>
								<path>/vitam/tmp/${unix.name}</path>
								<path>/vitam/log/${unix.name}</path>
							</paths>
							<mapper>
								<type>perm</type>
								<user>${unix.user}</user>
								<group>${unix.group}</group>
							</mapper>
						</data>

					</dataSet>
				</configuration>
			</plugin>

			<plugin>
				<groupId>com.mycila</groupId>
				<artifactId>license-maven-plugin</artifactId>
				<version>3.0</version>
				<configuration>
					<header>../../licenses/cecill21.txt</header>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>

</project>
