<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://maven.apache.org/POM/4.0.0"
	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-cloud-function-docs</artifactId>
	<parent>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-function-parent</artifactId>
		<version>2.1.0.RELEASE</version>
	</parent>
	<packaging>pom</packaging>
	<name>Spring Cloud Function Docs</name>
	<description>Spring Cloud Function Docs</description>
	<properties>
		<docs.main>index</docs.main>
		<main.basedir>${basedir}/..</main.basedir>
		<spring-doc-resources.version>0.1.1.RELEASE</spring-doc-resources.version>
		<spring-asciidoctor-extensions.version>0.1.0.RELEASE
		</spring-asciidoctor-extensions.version>
		<asciidoctorj-pdf.version>1.5.0-alpha.16</asciidoctorj-pdf.version>
		<adapters.path>${main.basedir}/spring-cloud-function-adapters</adapters.path>
	</properties>
	<profiles>
		<profile>
			<id>docs</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<version>${maven-dependency-plugin.version}</version>
						<inherited>false</inherited>
						<executions>
							<execution>
								<id>unpack-docs</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>org.springframework.cloud
											</groupId>
											<artifactId>spring-cloud-build-docs
											</artifactId>
											<version>${spring-cloud-build.version}
											</version>
											<classifier>sources</classifier>
											<type>jar</type>
											<overWrite>false</overWrite>
											<outputDirectory>${docs.resources.dir}
											</outputDirectory>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
							<execution>
								<id>unpack-docs-resources</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>io.spring.docresources</groupId>
											<artifactId>spring-doc-resources</artifactId>
											<version>${spring-doc-resources.version}</version>
											<type>zip</type>
											<overWrite>true</overWrite>
											<outputDirectory>${project.build.directory}/refdocs/</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>${project.build.directory}/refdocs/</outputDirectory>
									<resources>
										<resource>
											<directory>src/main/asciidoc</directory>
											<filtering>false</filtering>
											<excludes>
												<exclude>ghpages.sh</exclude>
											</excludes>
										</resource>
									</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.asciidoctor</groupId>
						<artifactId>asciidoctor-maven-plugin</artifactId>
						<version>${asciidoctor-maven-plugin.version}</version>
						<inherited>false</inherited>
						<dependencies>
							<dependency>
								<groupId>io.spring.asciidoctor</groupId>
								<artifactId>spring-asciidoctor-extensions</artifactId>
								<version>${spring-asciidoctor-extensions.version}</version>
							</dependency>
							<dependency>
								<groupId>org.asciidoctor</groupId>
								<artifactId>asciidoctorj-pdf</artifactId>
								<version>${asciidoctorj-pdf.version}</version>
							</dependency>
						</dependencies>
						<configuration>
							<sourceDirectory>${project.build.directory}/refdocs/</sourceDirectory>
							<attributes>
								<spring-cloud-function-version>${project.version}</spring-cloud-function-version>
								<docs-url>https://cloud.spring.io/</docs-url>
            					<docs-version></docs-version>
<!--             					<docs-url>https://cloud.spring.io/spring-cloud-static/</docs-url> -->
<!--             					<docs-version>2.1.0.RC1/</docs-version> -->
							</attributes>
						</configuration>
						<executions>
							<execution>
								<id>generate-html-documentation</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>process-asciidoc</goal>
								</goals>
								<configuration>
									<backend>html5</backend>
									<sourceHighlighter>highlight.js</sourceHighlighter>
									<doctype>book</doctype>
									<attributes>
										// these attributes are required to use the doc resources
										<docinfo>shared</docinfo>
										<stylesdir>css/</stylesdir>
										<stylesheet>spring.css</stylesheet>
										<linkcss>true</linkcss>
										<icons>font</icons>
										<highlightjsdir>js/highlight</highlightjsdir>
										<highlightjs-theme>atom-one-dark-reasonable</highlightjs-theme>
										<allow-uri-read>true</allow-uri-read>
										<nofooter />
										<toc>left</toc>
										<toc-levels>4</toc-levels>
										<spring-cloud-version>${project.version}</spring-cloud-version>
										<sectlinks>true</sectlinks>
									</attributes>
								</configuration>
							</execution>
							<execution>
								<id>generate-docbook</id>
								<phase>none</phase>
								<goals>
									<goal>process-asciidoc</goal>
								</goals>
							</execution>
							<execution>
								<id>generate-index</id>
								<phase>none</phase>
								<goals>
									<goal>process-asciidoc</goal>
								</goals>
							</execution>

						</executions>
					</plugin>

					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>${maven-antrun-plugin.version}</version>
						<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>
							<dependency>
								<groupId>org.jruby</groupId>
								<artifactId>jruby-complete</artifactId>
								<version>1.7.17</version>
							</dependency>
							<dependency>
								<groupId>org.asciidoctor</groupId>
								<artifactId>asciidoctorj</artifactId>
								<version>1.5.8</version>
							</dependency>
						</dependencies>
						<executions>
							<execution>
								<id>readme</id>
								<phase>process-resources</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<java classname="org.jruby.Main" failonerror="yes">
											<arg
												value="${docs.resources.dir}/ruby/generate_readme.sh" />
											<arg value="-o" />
											<arg value="${main.basedir}/README.adoc" />
										</java>
										<java classname="org.jruby.Main" failonerror="yes">
											<arg
												value="${docs.resources.dir}/ruby/generate_readme.sh" />
											<arg value="-o" />
											<arg
												value="${adapters.path}/spring-cloud-function-adapter-aws/README.adoc" />
											<arg
												value="${basedir}/src/main/asciidoc/adapters/aws-readme.adoc" />
										</java>
										<java classname="org.jruby.Main" failonerror="yes">
											<arg
												value="${docs.resources.dir}/ruby/generate_readme.sh" />
											<arg value="-o" />
											<arg
												value="${adapters.path}/spring-cloud-function-adapter-azure/README.adoc" />
											<arg
												value="${basedir}/src/main/asciidoc/adapters/azure-readme.adoc" />
										</java>
										<java classname="org.jruby.Main" failonerror="yes">
											<arg
												value="${docs.resources.dir}/ruby/generate_readme.sh" />
											<arg value="-o" />
											<arg
												value="${adapters.path}/spring-cloud-function-adapter-openwhisk/README.adoc" />
											<arg
												value="${basedir}/src/main/asciidoc/adapters/openwhisk-readme.adoc" />
										</java>
									</target>
								</configuration>
							</execution>
							<execution>
								<id>assert-no-unresolved-links</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<fileset id="unresolved.file"
											dir="${basedir}/target/generated-docs/" includes="**/*.html">
											<contains text="Unresolved" />
										</fileset>
										<fail message="[Unresolved] Found...failing">
											<condition>
												<resourcecount when="greater" count="0"
													refid="unresolved.file" />
											</condition>
										</fail>
									</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="BUILD-(.*)"
											replace="SNAPSHOT" />
										<stringutil string="${version-type}"
											property="spring-cloud-repo">
											<lowercase />
										</stringutil>
										<var name="github-tag" value="v${project.version}" />
										<propertyregex property="github-tag"
											override="true" input="${github-tag}" regexp=".*SNAPSHOT"
											replace="master" />
									</target>
								</configuration>
							</execution>
							<execution>
								<id>copy-css</id>
								<phase>none</phase>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
							<execution>
								<id>generate-documentation-index</id>
								<phase>none</phase>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
							<execution>
								<id>copy-generated-html</id>
								<phase>none</phase>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>

						</executions>
					</plugin>

					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>build-helper-maven-plugin</artifactId>
						<inherited>false</inherited>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
