<project xmlns="https://maven.apache.org/POM/4.0.0"
	xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">

	<modelVersion>4.0.0</modelVersion>
	<artifactId>spring-boot-language-server</artifactId>
	<packaging>jar</packaging>

	<parent>
		<groupId>org.springframework.ide.vscode</groupId>
		<artifactId>commons-parent</artifactId>
		<version>1.13.0-SNAPSHOT</version>
		<relativePath>../commons/pom.xml</relativePath>
	</parent>

	<properties>
		<dependencies.version>${project.version}</dependencies.version>
	</properties>

	<repositories>
		<repository>
			<id>${project.name}-repo</id>
			<url>file://${project.basedir}/repo</url>
		</repository>

<!-- 		<repository>
			<id>oss-jfrog-snapshots</id>
			<url>https://oss.jfrog.org/artifactory/libs-snapshot</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
-->

		<repository>
			<id>lsp4xml-releases</id>
			<url>https://dl.bintray.com/lsp4xml/releases</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<releases>
				<enabled>true</enabled>
			</releases>
		</repository>
	</repositories>

	<dependencies>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>commons-yaml</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<!-- spring boot -->
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>language-server-starter</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<!-- other -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-configuration-processor</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<!-- Local modified JSON lib packaged to support order in maps -->
			<groupId>org.springframework.ide.eclipse</groupId>
			<artifactId>org.json</artifactId>
			<version>1.0.0-SNAPSHOT</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>java-properties</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>commons-maven</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>commons-gradle</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>commons-language-server</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.jdt</groupId>
			<artifactId>org.eclipse.jdt.core</artifactId>
			<version>3.19.0</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>${commons-io-version}</version>
		</dependency>
		<dependency>
			<groupId>org.json</groupId>
			<artifactId>json</artifactId>
			<version>20160810</version>
		</dependency>
		<dependency>
			<groupId>org.lsp4xml</groupId>
			<artifactId>org.eclipse.lsp4xml</artifactId>
			<version>0.9.1</version>
			<exclusions>
				<exclusion>
					<groupId>org.eclipse.lsp4j</groupId>
					<artifactId>org.eclipse.lsp4j</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.eclipse.lsp4j</groupId>
					<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<!-- Test harness -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>com.vaadin.external.google</groupId>
					<artifactId>android-json</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>language-server-test-harness</artifactId>
			<version>${dependencies.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-all</artifactId>
			<version>${mockito-version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<id>tools-jar-profile</id>
			<activation>
				<file>
					<exists>${java.home}/../lib/tools.jar</exists>
				</file>
			</activation>

			<dependencies>
				<dependency>
					<groupId>com.sun</groupId>
					<artifactId>tools</artifactId>
					<version>1.8.0</version>
					<scope>system</scope>
					<systemPath>${java.home}/../lib/tools.jar</systemPath>
				</dependency>
			</dependencies>
		</profile>
	</profiles>

	<build>
		<plugins>
			<!-- Configure fat jar -->
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<layout>ZIP</layout>
					<classifier>exec</classifier>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!-- Ignore test classes from test projects -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<trimStackTrace>false</trimStackTrace>
					<excludes>
						<exclude>test-projects/**</exclude>
					</excludes>
				</configuration>
			</plugin>

			<!-- generate and package license information for included dependencies -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>license-maven-plugin</artifactId>
				<version>1.20</version>
				<executions>
					<execution>
						<id>download-licenses</id>
						<phase>process-classes</phase>
						<goals>
							<goal>download-licenses</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<licenseUrlReplacements>
						<licenseUrlReplacement>
							<regexp>http://(.*)</regexp>
							<replacement>https://$1</replacement>
						</licenseUrlReplacement>
					</licenseUrlReplacements>
					<licenseContentSanitizers>
						<licenseContentSanitizer>
							<id>all-http</id>
							<urlRegexp>http(.*)</urlRegexp>
							<contentRegexp>http://(.*)</contentRegexp>
							<contentReplacement>https://$1</contentReplacement>
						</licenseContentSanitizer>
					</licenseContentSanitizers>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>xml-maven-plugin</artifactId>
				<executions>
					<execution>
						<phase>process-classes</phase>
						<goals>
							<goal>transform</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<transformationSets>
						<transformationSet>
							<dir>${basedir}/target/generated-resources/</dir>
							<includes>*.xml</includes>
							<stylesheet>${basedir}/license-format-stylesheet.xsl</stylesheet>
							<outputDir>${project.build.directory}/generated-license-information</outputDir>
						</transformationSet>
					</transformationSets>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-own-license</id>
						<phase>process-classes</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.outputDirectory}</outputDirectory>
							<resources>
								<resource>
									<directory>${basedir}</directory>
									<filtering>true</filtering>
									<include>LICENSE</include>
								</resource>
							</resources>
						</configuration>
					</execution>

					<execution>
						<id>copy-license-files</id>
						<phase>process-classes</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.outputDirectory}/META-INF/third-party-open-source-licenses/</outputDirectory>
							<resources>
								<resource>
									<directory>${project.build.directory}/generated-resources/licenses</directory>
									<filtering>false</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.coderplus.maven.plugins</groupId>
				<artifactId>copy-rename-maven-plugin</artifactId>
				<version>1.0</version>
				<executions>
					<execution>
						<id>copy-and-rename-license-summary</id>
						<phase>process-classes</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<sourceFile>${project.build.directory}/generated-license-information/licenses.xml</sourceFile>
							<destinationFile>${project.build.outputDirectory}/META-INF/third-party-open-source-licenses.txt</destinationFile>
						</configuration>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>
</project>
