<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>io.vilt.minium</groupId>
		<artifactId>minium-parent</artifactId>
		<version>2.3.0</version>
		<relativePath>../minium-parent</relativePath>
	</parent>

	<artifactId>minium-docs</artifactId>
	<name>Minium Docs</name>

	<properties>
		<!-- output directory with the a static version of the site -->
		<static.docs.dir>${project.build.directory}/site/static</static.docs.dir>
	</properties>

	<dependencies>
		<dependency>
			<groupId>io.vilt.minium</groupId>
			<artifactId>minium-webelements</artifactId>
		</dependency>
		<dependency>
			<groupId>io.vilt.minium</groupId>
			<artifactId>minium-actions</artifactId>
		</dependency>
		<dependency>
			<groupId>io.vilt.minium</groupId>
			<artifactId>minium-script-rhinojs</artifactId>
		</dependency>
		<dependency>
			<groupId>io.vilt.minium</groupId>
			<artifactId>minium-cucumber</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jsoup</groupId>
			<artifactId>jsoup</artifactId>
		</dependency>
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>
		<dependency>
			<groupId>args4j</groupId>
			<artifactId>args4j</artifactId>
		</dependency>
		<dependency>
			<groupId>org.freemarker</groupId>
			<artifactId>freemarker</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>log4j-over-slf4j</artifactId>
		</dependency>
		<dependency>
			<groupId>com.sun</groupId>
			<artifactId>tools</artifactId>
			<scope>system</scope>
		</dependency>
	</dependencies>

	<build>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<excludes>
					<exclude>mkdocs/mkdocs.yml</exclude>
					<exclude>logback.xml</exclude>
				</excludes>
				<targetPath>${project.build.directory}/classes</targetPath>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>generate-docs</id>
			<activation>
				<property>
					<name>performRelease</name>
				</property>
			</activation>
			<build>
				<resources>
					<resource>
						<directory>src/main/mkdocs</directory>
						<targetPath>${project.build.directory}/mkdocs</targetPath>
						<includes>
							<include>**/*</include>
						</includes>
					</resource>
				</resources>
				<plugins>
					<!-- we need ant to define maven.classpath so that we can use it in 
						javadocs plugin (for some reason docletArtifacts doesn't seem to work -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>define-javadoc-classpath</id>
								<phase>process-resources</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<exportAntProperties>true</exportAntProperties>
									<target>
										<property name="maven.classpath" refid="maven.runtime.classpath" />
									</target>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>license-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>generate-thirdparty-licenses</id>
								<phase>process-resources</phase>
								<goals>
									<goal>add-third-party</goal>
								</goals>
								<configuration>
									<licenseMerges>
										<licenseMerge>
											The Apache Software License, Version 2.0|Apache
											License, Version
											2.0|Apache Public License 2.0|
											Apache License
											Version 2.0|Apache 2|Apache License 2.0|Apache
											Software
											Licenses|Apache License, version 2.0
										</licenseMerge>
										<licenseMerge>Eclipse Public License - v 1.0|Eclipse Public
											License 1.0</licenseMerge>
										<licenseMerge>The MIT License|MIT License</licenseMerge>
									</licenseMerges>
									<sortArtifactByName>true</sortArtifactByName>
									<outputDirectory>${project.build.directory}/licenses</outputDirectory>
									<useMissingFile>true</useMissingFile>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-javadoc-plugin</artifactId>
						<executions>
							<execution>
								<id>generate-api-markdown</id>
								<phase>package</phase>
								<goals>
									<goal>javadoc</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<sourcepath>
								../minium-elements/src/main/java;
								../minium-webelements/src/main/java;
								../minium-actions/src/main/java
							</sourcepath>
							<doclet>minium.docs.DocumentationDoclet</doclet>
							<docletPath>${project.build.directory}/classes</docletPath>
							<useStandardDocletOptions>false</useStandardDocletOptions>
							<outputDirectory>${project.build.directory}/mkdocs/docs/core</outputDirectory>
							<additionalparam>-d ${project.build.directory}/mkdocs/docs/core</additionalparam>
							<!-- docletArtifacts doesn't seem to work, use it with antrun:run, 
								execution ID define-javadoc-classpath -->
							<docletPath>${maven.classpath}</docletPath>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>generate-thirdparty-licenses-md</id>
								<phase>package</phase>
								<goals>
									<goal>java</goal>
								</goals>
								<configuration>
									<mainClass>minium.docs.ArtifactLicenseGenerator</mainClass>
									<killAfter>-1</killAfter>
									<systemProperties>
										<systemProperty>
											<key>org.freemarker.loggerLibrary</key>
											<value>none</value>
										</systemProperty>
									</systemProperties>
									<arguments>
										<argument>--templateFile</argument>
										<argument>${basedir}/src/main/resources/templates/third-parties.md.ftl</argument>
										<argument>--outputFile</argument>
										<argument>${project.build.directory}/mkdocs/docs/core/third-parties.md</argument>
										<argument>--artifactLicensesFile</argument>
										<argument>${project.build.directory}/licenses/THIRD-PARTY.txt</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-assembly-plugin</artifactId>
						<executions>
							<execution>
								<id>create-distribution</id>
								<phase>package</phase>
								<goals>
									<goal>single</goal>
								</goals>
								<configuration>
									<descriptors>
										<descriptor>assembly/zip.xml</descriptor>
									</descriptors>
								</configuration>
							</execution>
						</executions>
					</plugin>
				
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
