<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>com.top-logic</groupId>
		<artifactId>tl-ai-parent</artifactId>
		<version>2.0.4</version>
	</parent>
	
	<artifactId>tl-chat</artifactId>

	<licenses>
	  <license>
	    <name>LicenseRef-BOS-TopLogic-1.0</name>
	    <url>https://github.com/top-logic/.github/blob/main/LICENSES/LicenseRef-BOS-TopLogic-1.0.md</url>
	  </license>
	</licenses>
	
	<properties>
		<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>
		<msgbuf.version>1.2.2</msgbuf.version>
	</properties>

	<dependencies>
		<!-- TopLogic -->
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-core</artifactId>
		</dependency>
		<!--
			The view layer is not optional: every dependent that loads this module's
			application configuration resolves AgentViewRefreshService, and that class
			needs ReactWindowRegistry from tl-layout-react. tl-layout-view pulls
			tl-layout-react in, but the React controls in `view/` use it directly, so it
			is declared here as well.
		-->
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-layout-view</artifactId>
		</dependency>
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-layout-react</artifactId>
		</dependency>
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-element</artifactId>
		</dependency>
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-ai-core</artifactId>
			<version>${project.version}</version>
		</dependency>
		<!-- Tests -->
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-ai-vector-index</artifactId>
			<version>${project.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-basic</artifactId>
			<type>test-jar</type>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.top-logic</groupId>
			<artifactId>tl-core</artifactId>
			<type>test-jar</type>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>com.github.eirslett</groupId>
				<artifactId>frontend-maven-plugin</artifactId>
				<version>1.15.4</version>
				<configuration>
					<workingDirectory>ui</workingDirectory>
					<installDirectory>ui</installDirectory>
				</configuration>
				<executions>
					<execution>
						<id>install-node</id>
						<goals>
							<goal>install-node-and-npm</goal>
						</goals>
						<configuration>
							<!--
								20.19 or newer, because jsdom 29 reaches @exodus/bytes through a
								require() of an ES module: on 20.10 that throws ERR_REQUIRE_ESM and the
								one test file that needs a DOM never loads - vitest reports it as an
								unhandled error beside 178 passing tests and the build fails with no
								test failure to look at.
							-->
							<nodeVersion>v20.20.2</nodeVersion>
						</configuration>
					</execution>
					<execution>
						<id>npm-install</id>
						<goals>
							<goal>npm</goal>
						</goals>
						<configuration>
							<arguments>install</arguments>
						</configuration>
					</execution>
					<!--
						Type errors must fail the build, not reach the browser: the Vite lib build
						strips types without checking them, so tsc runs as its own step before it.
					-->
					<execution>
						<id>npm-typecheck</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>npm</goal>
						</goals>
						<configuration>
							<arguments>run typecheck</arguments>
						</configuration>
					</execution>
					<execution>
						<id>npm-build</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>npm</goal>
						</goals>
						<configuration>
							<arguments>run build</arguments>
						</configuration>
					</execution>
					<!--
						The JS tests run in the `test` phase, after surefire, and not with the
						bundle in `generate-resources` (#450): bound before `compile`, a single
						broken frontend test aborted the module and the state of its ~190 Java
						tests was not merely unreported but unproduced - no surefire-reports
						directory existed at all. Behind surefire, both answers are always in.

						Surefire runs first because it is declared in the parent pom and this
						plugin in the child, and Maven orders executions of one phase by the
						order their plugins appear in the effective pom.

						`skipTests` is pinned to false because the frontend plugin honours
						`${skipTests}` only for an execution in a testing phase: without the pin,
						moving the execution here would have silently turned the JS tests off in
						every build that does not pass `-DskipTests=false`, which in this
						repository is the default. What switches them off is what switched them
						off before, `-Dskip.npm=true`.
					-->
					<execution>
						<id>npm-test</id>
						<phase>test</phase>
						<goals>
							<goal>npm</goal>
						</goals>
						<configuration>
							<arguments>test</arguments>
							<skipTests>false</skipTests>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>de.haumacher.msgbuf</groupId>
				<artifactId>msgbuf-generator-maven-plugin</artifactId>
				<version>${msgbuf.version}</version>
				<executions>
					<execution>
						<id>generate-protocols</id>
						<goals>
							<goal>generate</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
