<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>concourse-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>

	<distributionManagement>
		<repository>
			<id>distribution-repository</id>
			<name>Temporary Staging Repository</name>
			<url>file://${basedir}/dist</url>
		</repository>
	</distributionManagement>

	<dependencies>
		<!-- Yaml -->
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>commons-yaml</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<!-- spring boot -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

		<!-- Language Servers -->
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>language-server-starter</artifactId>
			<version>${dependencies.version}</version>
		</dependency>
		<!-- github client -->
		<dependency>
			<groupId>org.kohsuke</groupId>
			<artifactId>github-api</artifactId>
			<version>1.90</version>
		</dependency>
		<!-- Test harness -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.ide.vscode</groupId>
			<artifactId>language-server-test-harness</artifactId>
			<version>${dependencies.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<!-- Configure fat jar -->
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<classifier>exec</classifier>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>repackage</goal>
						</goals>
					</execution>
				</executions>
			</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>
