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

	<artifactId>spring-shell-docs</artifactId>
	<name>Spring Shell Documentation</name>

	<parent>
		<groupId>org.springframework.shell</groupId>
		<artifactId>spring-shell-parent</artifactId>
		<version>2.1.2</version>
	</parent>

	<description>Spring Shell reference documentation</description>
	<properties>
		<asciidoctor.maven.plugin.version>2.2.2</asciidoctor.maven.plugin.version>
		<asciidoctorj.pdf.version>1.5.4</asciidoctorj.pdf.version>
		<asciidoctorj.epub.version>1.5.1</asciidoctorj.epub.version>
		<asciidoctorj.version>2.5.1</asciidoctorj.version>
		<jruby.version>9.2.17.0</jruby.version>
		<spring-doc-resources.version>0.2.5</spring-doc-resources.version>
	</properties>

	<!-- This project artificially depends on all others so that the javadoc plugin can consolidate everything.-->
	<dependencies>
		<dependency>
			<groupId>org.springframework.shell</groupId>
			<artifactId>spring-shell-core</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.shell</groupId>
			<artifactId>spring-shell-standard</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.shell</groupId>
			<artifactId>spring-shell-standard-commands</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.shell</groupId>
			<artifactId>spring-shell-table</artifactId>
			<scope>provided</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<!-- doc resources -->
			<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>${project.build.directory}/refdocs/</outputDirectory>
						</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>
						<inherited>false</inherited>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/refdocs/</outputDirectory>
							<resources>
								<resource>
									<directory>src/main/asciidoc</directory>
									<filtering>false</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- ASCIIDOC -->
			<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>${project.build.directory}/refdocs/</outputDirectory>
						</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>${project.build.directory}/refdocs/</outputDirectory>
							<resources>
								<resource>
									<directory>src/main/asciidoc</directory>
									<filtering>false</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
					<execution>
						<id>copy-asciidoc-snippets</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/refdocs/snippets/</outputDirectory>
							<resources>
								<resource>
									<directory>src/test/java/org/springframework/shell/docs</directory>
									<filtering>false</filtering>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.asciidoctor</groupId>
				<artifactId>asciidoctor-maven-plugin</artifactId>
				<version>${asciidoctor.maven.plugin.version}</version>
				<dependencies>
					<dependency>
						<groupId>org.asciidoctor</groupId>
						<artifactId>asciidoctorj-pdf</artifactId>
						<version>${asciidoctorj.pdf.version}</version>
					</dependency>
					<dependency>
						<groupId>org.asciidoctor</groupId>
						<artifactId>asciidoctorj-epub3</artifactId>
						<version>${asciidoctorj.epub.version}</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>generate-html</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>process-asciidoc</goal>
						</goals>
						<configuration>
							<backend>html5</backend>
							<attributes>
								<source-highlighter>highlight.js</source-highlighter>
								<project-version>${project.version}</project-version>
								<project-artifactId>${project.artifactId}</project-artifactId>
								<toc>left</toc>
								<toc-levels>4</toc-levels>
								<sectanchors>true</sectanchors>
								<sectnums />
								<docinfo>shared</docinfo>
								<stylesdir>css/</stylesdir>
								<stylesheet>spring.css</stylesheet>
								<linkcss>true</linkcss>
								<icons>font</icons>
								<highlightjsdir>js/highlight</highlightjsdir>
								<highlightjs-theme>github</highlightjs-theme>
							</attributes>
						</configuration>
					</execution>

					<execution>
						<id>generate-pdf</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>process-asciidoc</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.directory}/site/reference/pdf</outputDirectory>
							<backend>pdf</backend>
							<sourceHighlighter>coderay</sourceHighlighter>
							<attributes>
								<project-version>${project.version}</project-version>
								<project-artifactId>${project.artifactId}</project-artifactId>
								<icons>font</icons>
								<pagenums />
								<sectnums />
								<toc />
							</attributes>
						</configuration>
					</execution>
					<execution>
						<id>generate-epub</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>process-asciidoc</goal>
						</goals>
						<configuration>
							<backend>epub3</backend>
							<sourceHighlighter>coderay</sourceHighlighter>
							<attributes>
								<project-version>${project.version}</project-version>
								<project-artifactId>${project.artifactId}</project-artifactId>
								<icons>font</icons>
								<pagenums />
								<sectnums />
								<toc />
							</attributes>
						</configuration>
					</execution>
				</executions>

				<configuration>
					<sourceDirectory>${project.build.directory}/refdocs/</sourceDirectory>
					<sourceDocumentName>index.adoc</sourceDocumentName>
					<doctype>book</doctype>
					<attributes>
						<version>${project.version}</version>
						<projectName>${project.name}</projectName>
						<projectVersion>${project.version}</projectVersion>
						<snippets>${project.build.directory}/refdocs/snippets/</snippets>
						<allow-uri-read>true</allow-uri-read>
						<toclevels>4</toclevels>
						<numbered>true</numbered>
						<baseDir>${project.basedir}</baseDir>
					</attributes>
				</configuration>

			</plugin>

			<!-- API DOCS -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<executions>
					<execution>
						<id>dependency-javadocs</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<phase>prepare-package</phase>
						<configuration>
							<includeDependencySources>true</includeDependencySources>
							<dependencySourceIncludes>
								<dependencySourceInclude>${project.groupId}:*</dependencySourceInclude>
							</dependencySourceIncludes>
							<dependencySourceExcludes>
								<!-- Exclude Spring Shell 1 -->
								<dependencySourceExclude>${project.groupId}:spring-shell</dependencySourceExclude>
							</dependencySourceExcludes>
							<quiet>true</quiet>
							<attach>false</attach>
							<doclint>-missing</doclint>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- PACKAGE ASCIIDOC + API -->
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<id>zip-docs</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
						<configuration>
							<descriptors>
								<descriptor>src/assembly/docs-zip.xml</descriptor>
							</descriptors>
							<appendAssemblyId>false</appendAssemblyId>
							<attach>false</attach>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.9.1</version>
				<executions>
					<execution>
						<id>attach-zip</id>
						<phase>package</phase>
						<goals>
							<goal>attach-artifact</goal>
						</goals>
						<configuration>
							<artifacts>
								<artifact>
									<file>${project.build.directory}/${project.artifactId}-${project.version}.zip</file>
									<type>zip;zip.type=docs;zip.deployed=false</type>
								</artifact>
							</artifacts>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

</project>
