<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/maven-v4_0_0.xsd">
	<parent>
		<groupId>io.imunity</groupId>
		<artifactId>unity-server-parent</artifactId>
		<version>4.4.0</version>
		<relativePath>../pom.xml</relativePath>
	</parent>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>unity-rest-api-docs</artifactId>
	<packaging>jar</packaging>
	<name>UNITY Server ${m.name} module</name>
	<description>Unity rest api docs generation</description>
	<properties>
		<m.name>unity-rest-api-docs</m.name>
	</properties>

	<scm>
		<connection>${scm.base}/${m.name}</connection>
		<developerConnection>${scm.base}/${m.name}</developerConnection>
		<tag>unity-server-parent-4.4.0</tag>
	</scm>
	<dependencies>
		<dependency>
			<groupId>io.imunity</groupId>
			<artifactId>unity-server-engine</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.imunity</groupId>
			<artifactId>unity-server-vaadin-public-shared-endpoint</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.imunity</groupId>
			<artifactId>unity-server-rest</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.imunity</groupId>
			<artifactId>unity-server-storage</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>io.imunity</groupId>
			<artifactId>unity-server-rest-admin</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>jakarta.xml.bind</groupId>
			<artifactId>jakarta.xml.bind-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.webjars</groupId>
			<artifactId>swagger-ui</artifactId>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>openapiSpec</id>
			<properties>
				<unity.protocol>http</unity.protocol>
				<unity.host>localhost</unity.host>
				<unity.port>7443</unity.port>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>Start Unity-IdM</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>pre-integration-test</phase>
							</execution>
						</executions>
						<configuration>
							<async>true</async>
							<asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
							<executable>java</executable>
							<arguments>
								<argument>-classpath</argument>
								<classpath />
								<argument>io.imunity.rest.doc.TstServer</argument>
							</arguments>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.sonatype.plugins</groupId>
						<artifactId>wait-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>Wait for Unity-IdM to start</id>
								<goals>
									<goal>wait</goal>
								</goals>
								<phase>pre-integration-test</phase>
							</execution>
						</executions>
						<configuration>
							<protocol>${unity.protocol}</protocol>
							<host>${unity.host}</host>
							<port>${unity.port}</port>
							<file>/unitygw/pub</file>
							<timeout>1000</timeout>
							<maxcount>30</maxcount>
						</configuration>
					</plugin>
					<plugin>
						<groupId>com.googlecode.maven-download-plugin</groupId>
						<artifactId>download-maven-plugin</artifactId>
						<version>1.8.0</version>
						<executions>
							<execution>
								<id>Download OpenAPI spec</id>
								<goals>
									<goal>wget</goal>
								</goals>
								<phase>integration-test</phase>
							</execution>
						</executions>
						<configuration>
							<uri>${unity.protocol}://${unity.host}:${unity.port}/rest-admin/openapi.yaml</uri>
							<outputDirectory>${project.build.directory}</outputDirectory>
							<username>a</username>
							<password>a</password>
							<preemptiveAuth>true</preemptiveAuth>
							<skipCache>true</skipCache>
							<overwrite>true</overwrite>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
