<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.4.1</version>
		<relativePath /> <!-- lookup parent from repository --> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.sipios</groupId>
	<artifactId>spring-search</artifactId>
	<version>0.2.2</version>
	<name>spring-search</name>
	<description>API for generating spring boot database queries</description>

	<properties>
		<java.version>1.8</java.version>
		<kotlin.version>1.4.10</kotlin.version>
		<antl4.version>4.9</antl4.version>
		<grammar.package>com.sipios.springsearch.grammar</grammar.package>
		<grammar.directory>com/sipios/springsearch/grammar</grammar.directory>
		<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
		<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-rest</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.module</groupId>
			<artifactId>jackson-module-kotlin</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-reflect</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-stdlib-jdk8</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.antlr</groupId>
			<artifactId>antlr4-runtime</artifactId>
			<version>${antl4.version}</version>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-stdlib-jdk8</artifactId>
			<version>${kotlin.version}</version>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-test</artifactId>
			<version>${kotlin.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-stdlib-jdk8</artifactId>
			<version>${kotlin.version}</version>
		</dependency>
	</dependencies>

	<build>
		<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
		<testSourceDirectory>src/test/kotlin</testSourceDirectory>
		<plugins>
			<plugin>
				<groupId>org.antlr</groupId>
				<artifactId>antlr4-maven-plugin</artifactId>
				<version>${antl4.version}</version>
				<executions>
					<execution>
						<id>antlr</id>
						<goals>
							<goal>antlr4</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<listener>true</listener>
					<visitor>true</visitor>
					<arguments>
						<argument>-package</argument>
						<argument>${grammar.package}</argument>
					</arguments>
					<outputDirectory>${project.build.directory}/generated-sources/antlr4/${grammar.directory}</outputDirectory>
				</configuration>
			</plugin>
			<plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
			<plugin>
				<groupId>org.jetbrains.kotlin</groupId>
				<artifactId>kotlin-maven-plugin</artifactId>
				<version>${kotlin.version}</version>
				<executions>
					<execution>
						<id>compile</id>
						<phase>compile</phase>
						<goals>
							<goal>compile</goal>
						</goals>
						<configuration>
							<sourceDirs>
								<source>src/main/kotlin</source>
								<source>target/generated-sources/antlr4</source>
							</sourceDirs>
						</configuration>
					</execution>
					<execution>
						<id>test-compile</id>
						<phase>test-compile</phase>
						<goals>
							<goal>test-compile</goal>
						</goals>
						<configuration>
							<sourceDirs>
								<source>src/main/kotlin</source>
								<source>src/test/kotlin</source>
								<source>target/generated-sources/antlr4</source>
							</sourceDirs>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<args>
						<arg>-Xjsr305=strict</arg>
					</args>
					<compilerPlugins>
						<plugin>spring</plugin>
						<plugin>jpa</plugin>
					</compilerPlugins>
					<sourceDirs>
						<sourceDir>src/main/kotlin</sourceDir>
						<sourceDir>target/generated-sources/antlr4</sourceDir>
					</sourceDirs>
					<jvmTarget>1.8</jvmTarget>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>org.jetbrains.kotlin</groupId>
						<artifactId>kotlin-maven-allopen</artifactId>
						<version>${kotlin.version}</version>
					</dependency>
					<dependency>
						<groupId>org.jetbrains.kotlin</groupId>
						<artifactId>kotlin-maven-noarg</artifactId>
						<version>${kotlin.version}</version>
					</dependency>
				</dependencies>
			</plugin>
			<plugin>
				<artifactId>maven-release-plugin</artifactId>
				<version>2.5.3</version>
				<configuration>
					<useReleaseProfile>false</useReleaseProfile>
					<releaseProfiles>release</releaseProfiles>
					<autoVersionSubmodules>true</autoVersionSubmodules>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.8</version>
				<executions>
					<execution>
						<id>ktlint</id>
						<phase>compile</phase>
						<configuration>
							<target name="ktlint">
								<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
									  classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
									<arg value="src/**/*.kt"/>
								</java>
							</target>
						</configuration>
						<goals><goal>run</goal></goals>
					</execution>
					<execution>
						<id>ktlint-format</id>
						<configuration>
							<target name="ktlint">
								<java taskname="ktlint" dir="${basedir}" fork="true" failonerror="true"
									  classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
									<arg value="-F"/>
									<arg value="src/**/*.kt"/>
								</java>
							</target>
						</configuration>
						<goals><goal>run</goal></goals>
					</execution>
				</executions>
				<dependencies>
					<dependency>
						<groupId>com.pinterest</groupId>
						<artifactId>ktlint</artifactId>
						<version>0.34.2</version>
					</dependency>
					<!-- additional 3rd party ruleset(s) can be specified here -->
				</dependencies>
			</plugin>
			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>${jacoco-maven-plugin.version}</version>
				<configuration>
					<excludes>
						<exclude>${grammar.directory}/**/*</exclude>
						<exclude>com/sipios/springsearch/configuration/**/*</exclude>
					</excludes>
				</configuration>
				<executions>
					<execution>
						<id>pre-unit-tests</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
						<configuration>
							<!-- Sets the path to the file which contains the execution data. -->
							<destFile>${project.testresult.directory}/coverage/jacoco/jacoco.exec</destFile>
						</configuration>
					</execution>
					<!-- Ensures that the code coverage report for unit tests is created after unit tests have been run -->
					<execution>
						<id>post-unit-test</id>
						<phase>test</phase>
						<goals>
							<goal>report</goal>
						</goals>
						<configuration>
							<dataFile>${project.testresult.directory}/coverage/jacoco/jacoco.exec</dataFile>
							<outputDirectory>${project.testresult.directory}/coverage/jacoco</outputDirectory>
						</configuration>
					</execution>
					<execution>
						<id>jacoco-check</id>
						<phase>test</phase>
						<goals>
							<goal>check</goal>
						</goals>
						<configuration>
							<dataFile>${project.testresult.directory}/coverage/jacoco/jacoco.exec</dataFile>
							<rules>
								<rule implementation="org.jacoco.maven.RuleConfiguration">
									<element>BUNDLE</element>
									<limits>
										<limit implementation="org.jacoco.report.check.Limit">
											<counter>INSTRUCTION</counter>
											<value>COVEREDRATIO</value>
											<minimum>0.80</minimum>
										</limit>
										<limit implementation="org.jacoco.report.check.Limit">
											<counter>BRANCH</counter>
											<value>COVEREDRATIO</value>
											<minimum>0.75</minimum>
										</limit>
									</limits>
								</rule>
							</rules>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<executions>
					<execution>
						<id>compile</id>
						<phase>compile</phase>
						<goals>
							<goal>compile</goal>
						</goals>
					</execution>
					<execution>
						<id>testCompile</id>
						<phase>test-compile</phase>
						<goals>
							<goal>testCompile</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<phase>package</phase>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-javadoc-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<phase>package</phase>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<failOnError>false</failOnError>
				</configuration>
			</plugin>
			<plugin>
				<!-- explicitly define maven-deploy-plugin after other to force exec order -->
				<artifactId>maven-deploy-plugin</artifactId>
				<executions>
					<execution>
						<id>deploy</id>
						<phase>deploy</phase>
						<goals>
							<goal>deploy</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-gpg-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>sign-artifacts</id>
						<phase>verify</phase>
						<goals>
							<goal>sign</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<scm>
		<connection>scm:git:https://github.com/sipios/spring-search.git</connection>
		<developerConnection>scm:git:git@github.com:sipios/spring-search.git</developerConnection>
		<url>https://github.com/sipios/spring-search</url>
		<tag>HEAD</tag>
	</scm>

	<distributionManagement>
		<repository>
			<id>ossrh</id>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
		</repository>
	</distributionManagement>
</project>
