<?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>io.spring.initializr</groupId>
		<artifactId>initializr-parent</artifactId>
		<version>${revision}</version>
		<relativePath>../initializr-parent</relativePath>
	</parent>
	<artifactId>initializr-docs</artifactId>
	<name>Spring Initializr :: Docs</name>

	<properties>
		<main.basedir>${basedir}/..</main.basedir>
		<maven.test.skip>true</maven.test.skip>
		<spring-doc-resources.version>0.2.2.RELEASE</spring-doc-resources.version>
	</properties>
	<scm>
		<url>${git.url}</url>
		<connection>${git.connection}</connection>
		<developerConnection>${git.developerConnection}</developerConnection>
	</scm>

	<dependencies>
		<dependency>
			<groupId>io.spring.initializr</groupId>
			<artifactId>initializr-actuator</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>io.spring.initializr</groupId>
			<artifactId>initializr-generator</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>io.spring.initializr</groupId>
			<artifactId>initializr-generator-spring</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>io.spring.initializr</groupId>
			<artifactId>initializr-generator-test</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>io.spring.initializr</groupId>
			<artifactId>initializr-metadata</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>io.spring.initializr</groupId>
			<artifactId>initializr-web</artifactId>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>javax.cache</groupId>
			<artifactId>cache-api</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-contract-stub-runner</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>**</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<systemPropertyVariables>
						<project.version>${project.version}</project.version>
					</systemPropertyVariables>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<profiles>
		<profile>
			<id>full</id>
			<activation>
				<property>
					<name>full</name>
				</property>
			</activation>
			<properties>
				<maven.test.skip>false</maven.test.skip>
				<snippets.location>${project.build.directory}/snippets</snippets.location>
				<refdocs.build.directory>${project.build.directory}/refdocs/</refdocs.build.directory>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>com.googlecode.maven-download-plugin</groupId>
						<artifactId>download-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>unpack-doc-resources</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>wget</goal>
								</goals>
								<configuration>
									<url>https://repo.spring.io/release/io/spring/docresources/spring-doc-resources/${spring-doc-resources.version}/spring-doc-resources-${spring-doc-resources.version}.zip</url>
									<unpack>true</unpack>
									<outputDirectory>${refdocs.build.directory}</outputDirectory>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<executions>
							<execution>
								<id>unpack-restdocs-snippets</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>io.spring.initializr</groupId>
											<artifactId>initializr-web</artifactId>
											<version>${project.version}</version>
											<classifier>snippets</classifier>
											<type>zip</type>
											<outputDirectory>${snippets.location}</outputDirectory>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-resources-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-asciidoc-resources</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>copy-resources</goal>
								</goals>
								<configuration>
									<outputDirectory>${refdocs.build.directory}</outputDirectory>
									<resources>
										<resource>
											<directory>src/main/asciidoc</directory>
											<filtering>false</filtering>
										</resource>
									</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.asciidoctor</groupId>
						<artifactId>asciidoctor-maven-plugin</artifactId>
						<configuration>
							<sourceDirectory>${refdocs.build.directory}</sourceDirectory>
							<sourceDocumentName>index.adoc</sourceDocumentName>
							<outputDirectory>${project.build.directory}/generated-docs/reference/html</outputDirectory>
							<attributes>
								<spring-initializr-version>${project.version}</spring-initializr-version>
								<spring-initializr-docs-version>${project.version}</spring-initializr-docs-version>
								<spring-boot-docs-version>${spring-boot.version}</spring-boot-docs-version>
								<snippets>${snippets.location}</snippets>
								<github-tag>${github-tag}</github-tag>
								<sources-root>${project.basedir}/src</sources-root>
							</attributes>
						</configuration>
						<executions>
							<execution>
								<id>generate-html-documentation</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>process-asciidoc</goal>
								</goals>
								<configuration>
									<backend>html5</backend>
									<doctype>book</doctype>
									<attributes>
										<highlightjsdir>js/highlight</highlightjsdir>
										<highlightjs-theme>github</highlightjs-theme>
										<source-highlighter>highlight.js</source-highlighter>
										<linkcss>true</linkcss>
										<imagesdir>./images</imagesdir>
										<icons>font</icons>
										<stylesdir>css/</stylesdir>
										<stylesheet>spring.css</stylesheet>
									</attributes>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-javadoc-plugin</artifactId>
						<executions>
							<execution>
								<id>attach-javadocs</id>
								<goals>
									<goal>jar</goal>
								</goals>
								<phase>prepare-package</phase>
								<configuration>
									<doctitle>Spring Initializr ${project.version} API</doctitle>
									<includeDependencySources>true</includeDependencySources>
									<dependencySourceIncludes>
										<dependencySourceInclude>${project.groupId}:*</dependencySourceInclude>
									</dependencySourceIncludes>
									<sourceFileExcludes>io/spring/initializr/doc/**/*.java</sourceFileExcludes>
									<detectOfflineLinks>false</detectOfflineLinks>
									<attach>false</attach>
									<quiet>true</quiet>
									<stylesheetfile>${basedir}/src/main/javadoc/spring-javadoc.css</stylesheetfile>
									<links>
										<link>https://docs.oracle.com/javase/8/docs/api</link>
										<link>https://docs.oracle.com/javaee/7/api</link>
										<link>https://docs.spring.io/spring-boot/docs/${spring-boot.version}/api</link>
										<link>https://www.javadoc.io/doc/javax.cache/cache-api/1.0.0</link>
									</links>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<dependencies>
							<dependency>
								<groupId>ant-contrib</groupId>
								<artifactId>ant-contrib</artifactId>
								<version>1.0b3</version>
								<exclusions>
									<exclusion>
										<groupId>ant</groupId>
										<artifactId>ant</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
							<dependency>
								<groupId>org.apache.ant</groupId>
								<artifactId>ant-nodeps</artifactId>
								<version>1.8.1</version>
							</dependency>
							<dependency>
								<groupId>org.tigris.antelope</groupId>
								<artifactId>antelopetasks</artifactId>
								<version>3.2.10</version>
							</dependency>
						</dependencies>
						<executions>
							<execution>
								<id>package-and-attach-docs-zip</id>
								<phase>package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<zip destfile="${project.build.directory}/${project.artifactId}-${project.version}.zip">
											<zipfileset
													src="${project.build.directory}/${project.artifactId}-${revision}-javadoc.jar"
													prefix="api" />
											<fileset dir="${project.build.directory}/generated-docs" />
										</zip>
									</target>
								</configuration>
							</execution>
							<execution>
								<id>setup-maven-properties</id>
								<phase>validate</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<exportAntProperties>true</exportAntProperties>
									<target>
										<taskdef resource="net/sf/antcontrib/antcontrib.properties" />
										<taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" />
										<var name="version-type" value="${project.version}" />
										<propertyregex property="version-type" override="true" input="${version-type}" regexp=".*\.(.*)" replace="\1" />
										<propertyregex property="version-type" override="true" input="${version-type}" regexp="(M)\d+" replace="MILESTONE" />
										<propertyregex property="version-type" override="true" input="${version-type}" regexp="(RC)\d+" replace="MILESTONE" />
										<propertyregex property="version-type" override="true" input="${version-type}" regexp="(SNAPSHOT)\d+" replace="SNAPSHOT" />
										<stringutil string="${version-type}" property="initializr-repo">
											<lowercase />
										</stringutil>
										<var name="github-tag" value="v${project.version}" />
										<propertyregex property="github-tag" override="true" input="${github-tag}" regexp=".*SNAPSHOT" replace="main" />
									</target>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>build-helper-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>attach-zip</id>
								<goals>
									<goal>attach-artifact</goal>
								</goals>
								<configuration>
									<artifacts>
										<artifact>
											<file>${project.build.directory}/${project.artifactId}-${project.version}.zip</file>
											<type>zip</type>
										</artifact>
									</artifacts>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
