<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>
	<artifactId>jans-core-cedarling</artifactId>
	<packaging>jar</packaging>
	<name>jans-core-cedarling</name>

	<parent>
		<groupId>io.jans</groupId>
		<artifactId>jans-core-parent</artifactId>
		<version>0.0.0-nightly</version>
	</parent>

	<properties>
		<maven.compiler.source>15</maven.compiler.source>
		<maven.compiler.target>15</maven.compiler.target>
		<maven.compiler.release>15</maven.compiler.release>
	</properties>

	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
			</resource>
		</resources>

		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
			</testResource>
		</testResources>

		<plugins>
			<!--
				Compile audit.proto to a binary descriptor set (audit.dsc).
				WireMock gRPC extension requires a compiled descriptor file
				in src/test/resources/wiremock/grpc/ to transcode proto<->JSON.
				The descriptor is regenerated on every `generate-test-resources`
				lifecycle phase, so it stays in sync with audit.proto.
				
				NOTE: audit.proto imports google/protobuf/timestamp.proto.
				      includeStdTypes=true bundles the well-known types into
				      the descriptor so WireMock can resolve them at runtime.
			-->
			<plugin>
				<groupId>com.github.os72</groupId>
				<artifactId>protoc-jar-maven-plugin</artifactId>
				<version>3.11.4</version>
				<executions>
					<execution>
						<id>generate-grpc-descriptor</id>
						<phase>generate-test-resources</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<protocVersion>3.25.1</protocVersion>
							<!-- Bundle google/protobuf/timestamp.proto into the descriptor. -->
							<includeStdTypes>true</includeStdTypes>
							<inputDirectories>
								<include>src/test/resources/grpc</include>
							</inputDirectories>
							<outputTargets>
								<!--
									type=descriptor generates a binary FileDescriptorSet (.dsc).
									WireMock gRPC scans <rootDir>/grpc/ for *.dsc / *.desc files.
								-->
								<outputTarget>
									<type>descriptor</type>
									<addSources>none</addSources>
									<outputDirectory>src/test/resources/wiremock/grpc</outputDirectory>
								</outputTarget>
							</outputTargets>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<!-- Jans -->
		<dependency>
			<groupId>io.jans</groupId>
			<artifactId>jans-core-model</artifactId>
		</dependency>
		<dependency>
			<groupId>io.jans</groupId>
			<artifactId>jans-core-service</artifactId>
		</dependency>
		<dependency>
			<groupId>io.jans</groupId>
			<artifactId>cedarling-java</artifactId>
		</dependency>

		<!-- CDI -->
		<dependency>
			<groupId>jakarta.enterprise</groupId>
			<artifactId>jakarta.enterprise.cdi-api</artifactId>
		</dependency>
		<dependency>
			<groupId>jakarta.inject</groupId>
			<artifactId>jakarta.inject-api</artifactId>
		</dependency>
		<dependency>
			<groupId>jakarta.validation</groupId>
			<artifactId>jakarta.validation-api</artifactId>
		</dependency>
		<dependency>
			<groupId>jakarta.ejb</groupId>
			<artifactId>jakarta.ejb-api</artifactId>
		</dependency>

		<!-- Servlet (production scope) -->
		<dependency>
			<groupId>jakarta.servlet</groupId>
			<artifactId>jakarta.servlet-api</artifactId>
			<scope>provided</scope>
		</dependency>

		<!-- REST -->
		<dependency>
			<groupId>jakarta.ws.rs</groupId>
			<artifactId>jakarta.ws.rs-api</artifactId>
		</dependency>

		<!-- Swagger -->
		<dependency>
			<groupId>io.swagger.core.v3</groupId>
			<artifactId>swagger-core-jakarta</artifactId>
		</dependency>

		<!-- ================================================================
		     TEST dependencies
		     ================================================================ -->

		<!-- JUnit 5 -->
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- Mockito -->
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-junit-jupiter</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- REST Assured -->
		<dependency>
			<groupId>io.rest-assured</groupId>
			<artifactId>rest-assured</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- WireMock 4 (modular layout):
		     wiremock-jetty              - embedded Jetty HTTP/2 server
		     wiremock-junit5             - JUnit 5 @RegisterExtension / @WireMockTest
		     wiremock-httpclient-apache5 - HTTP client used by the WireMock admin API
		     Duplicate wiremock-jetty entry removed from the original pom.
		-->
		<dependency>
			<groupId>org.wiremock</groupId>
			<artifactId>wiremock-jetty</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.wiremock</groupId>
			<artifactId>wiremock-junit5</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.wiremock</groupId>
			<artifactId>wiremock-httpclient-apache5</artifactId>
			<scope>test</scope>
		</dependency>

		<!--
			WireMock gRPC extension.
			Version 1.0.0-beta.4 is the latest release compatible with
			wiremock 4.0.0-beta.34 (1.0.0-beta.5 is not yet in Maven Central).
			This artifact brings grpc-stub, grpc-protobuf, and the server-side
			Netty transport, but does NOT ship a client-side gRPC transport
			suitable for ManagedChannelBuilder.  Add grpc-netty-shaded below
			to provide that transport.
		-->
		<dependency>
			<groupId>org.wiremock</groupId>
			<artifactId>wiremock-grpc-extension</artifactId>
			<scope>test</scope>
		</dependency>

		<!--
			grpc-netty-shaded bundles its own Netty so it does not conflict
			with the Netty version pulled in by WireMock / Jetty.
			Pin to the same gRPC minor version that wiremock-grpc-extension
			1.0.0-beta.4 uses internally (~1.62.x) to avoid binary
			incompatibilities between grpc-core and the transport layer.
		-->
		<dependency>
			<groupId>io.grpc</groupId>
			<artifactId>grpc-netty-shaded</artifactId>
			<version>1.62.2</version>
			<scope>test</scope>
		</dependency>

		<!-- Servlet API for tests (Jetty 12 / Jakarta EE 10) -->
		<dependency>
			<groupId>jakarta.servlet</groupId>
			<artifactId>jakarta.servlet-api</artifactId>
			<version>6.0.0</version>
			<scope>provided</scope>
		</dependency>
		
		<!-- Documentation -->
		<dependency>
			<groupId>io.jans</groupId>
			<artifactId>jans-doc</artifactId>
		</dependency>
	</dependencies>
</project>