<?xml version="1.0" encoding="utf-8"?>
<!--

    Copyright © 2017-2021 Dominic Heutelbeck (dominic@heutelbeck.com)

    Licensed 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>io.sapl</groupId>
		<artifactId>sapl-policy-engine</artifactId>
		<version>2.0.1</version>
	</parent>
	<artifactId>sapl-maven-plugin</artifactId>
	<name>SAPL Maven Plugin</name>
	<packaging>maven-plugin</packaging>

	<properties>
		<maven.version>3.8.1</maven.version>
	</properties>

	<dependencies>
		<!-- Maven Plugin Dependencies -->
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-plugin-api</artifactId>
			<version>${maven.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-core</artifactId>
			<version>${maven.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.plugin-tools</groupId>
			<artifactId>maven-plugin-annotations</artifactId>
			<version>3.6.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api</artifactId>
		</dependency>
		<dependency>
			<groupId>javax.activation</groupId>
			<artifactId>activation</artifactId>
			<version>1.1.1</version>
		</dependency>
		<dependency>
			<groupId>org.glassfish.jaxb</groupId>
			<artifactId>jaxb-runtime</artifactId>
		</dependency>


		<!-- SAPL -->
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>sapl-coverage-api</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.sapl</groupId>
			<artifactId>sapl-lang</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.sapl</groupId>
			<artifactId>sapl-web</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.11.0</version>
		</dependency>
		<!-- Sapl Plugin Dependencies -->
		<dependency>
			<groupId>com.j2html</groupId>
			<artifactId>j2html</artifactId>
			<version>1.4.0</version>
		</dependency>

		<!-- Testing -->
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.plugin-testing</groupId>
			<artifactId>maven-plugin-testing-harness</artifactId>
			<scope>test</scope>
			<version>3.3.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.maven</groupId>
			<artifactId>maven-compat</artifactId>
			<version>3.8.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-inline</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-plugin-plugin</artifactId>
				<version>3.6.0</version>
			</plugin>

			<plugin>
				<groupId>org.eclipse.sisu</groupId>
				<artifactId>sisu-maven-plugin</artifactId>
				<version>0.3.3</version>
				<executions>
					<execution>
						<id>generate-index</id>
						<goals>
							<goal>main-index</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

        	<!--
        		The CSS and JS resources of the xtext web dependency have to copied
				to the matching frontend folder CSS and images are hard coded into the HTML
				template of the webcomponent JS file
			 -->

			<!-- First unpack the files from the JAR -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>unpack-sapl</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>unpack</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>${project.groupId}</groupId>
									<artifactId>sapl-web</artifactId>
									<version>${project.version}</version>
									<overWrite>true</overWrite>
									<outputDirectory>${project.build.directory}/sapl</outputDirectory>
									<includes>static/**/*</includes>
								</artifactItem>
							</artifactItems>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- Second, copy the files into the frontend folder to be accessible -->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<id>copy-resources-sapl</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/classes/dependency-resources</outputDirectory>
							<resources>
								<resource>
									<directory>${project.build.directory}/sapl/static</directory>
									<includes>
										<include>sapl-mode.js</include>
									</includes>
									<filtering>false</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
