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

	<artifactId>de.rcenvironment.documentation.core</artifactId>
	<name>RCE Documentation (Core)</name>
	<!-- as a preliminary workaround, the POM version is used to transport root 
		version information to the DocBook processor; it should work with normal 
		properties as well, though - misc_ro -->
	<version>10.2.1-SNAPSHOT</version>
	<packaging>pom</packaging>

	<parent>
		<groupId>de.rcenvironment</groupId>
		<artifactId>de.rcenvironment.documentation.core.defaultParent</artifactId>
		<version>1.0.0</version>
		<relativePath>../de.rcenvironment.documentation.core/maven/parent</relativePath>
	</parent>

	<properties>
		<userguide.content.prefix>user_guide/</userguide.content.prefix>
		<devguide.content.prefix>developer_guide/</devguide.content.prefix>
		<adminguide.content.prefix>admin_guide/</adminguide.content.prefix>
	</properties>

	<profiles>
		<profile>
			<id>buildDocumentation</id>
			<activation>
				<property>
					<name>!rce.maven.skipDocumentation</name>
				</property>
			</activation>
			<build>
				<plugins>
					<!-- render SVG diagrams to PNG; required for embedding in HTML - misc_ro -->
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>batik-maven-plugin</artifactId>
						<version>1.0-beta-1</version>
						<executions>
							<execution>
								<goals>
									<goal>rasterize</goal>
								</goals>
								<phase>generate-resources</phase>
								<configuration>
									<srcDir>src/docbkx/diagrams/svg</srcDir>
									<srcIncludes>*.svg</srcIncludes>
									<destDir>target/docbkx/diagrams/img-gen</destDir>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<!-- this fixes a dependency conflict; see http://stackoverflow.com/questions/714243/ -->
							<dependency>
								<groupId>batik</groupId>
								<artifactId>batik-transcoder</artifactId>
								<version>1.6-1</version>
								<scope>compile</scope>
								<exclusions>
									<exclusion>
										<artifactId>fop</artifactId>
										<groupId>fop</groupId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
					</plugin>
					<!-- generate the build qualifier as used for Tycho artifacts -->
					<plugin>
						<groupId>org.eclipse.tycho</groupId>
						<artifactId>tycho-packaging-plugin</artifactId>
						<executions>
							<execution>
								<goals>
									<goal>build-qualifier</goal>
								</goals>
								<phase>generate-resources</phase>
							</execution>
						</executions>
					</plugin>
					<!-- use Ant+JavaScript to customize the displayed build id; needs antrun 
						>=1.7 to export Maven properties -->
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.7</version>
						<executions>
							<execution>
								<id>modify-eclipse-help</id>
								<phase>process-resources</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<replace dir="target/docbkx/eclipse">
											<include name="**/user_guide/toc.xml" />
											<replacefilter token="topic=&quot;"
												value="topic=&quot;${userguide.content.prefix}" />
											<replacefilter token="href=&quot;"
												value="href=&quot;${userguide.content.prefix}" />
										</replace>
										<replace dir="target/docbkx/eclipse">
											<include name="**/developer_guide/toc.xml" />
											<replacefilter token="topic=&quot;"
												value="topic=&quot;${devguide.content.prefix}" />
											<replacefilter token="href=&quot;"
												value="href=&quot;${devguide.content.prefix}" />
										</replace>
										<replace dir="target/docbkx/eclipse">
											<include name="**/admin_guide/toc.xml" />
											<replacefilter token="topic=&quot;"
												value="topic=&quot;${adminguide.content.prefix}" />
											<replacefilter token="href=&quot;"
												value="href=&quot;${adminguide.content.prefix}" />
										</replace>
										<delete>
											<fileset dir="target/docbkx/eclipse" includes="**/plugin.xml" />
											<fileset dir="target/docbkx/eclipse" includes="**/index.xml" />
										</delete>
										<move file="target/docbkx/eclipse/windows/user_guide/toc.xml"
											toFile="target/docbkx/eclipse/windows/user_guide_toc.xml" />
										<move file="target/docbkx/eclipse/windows/developer_guide/toc.xml"
											toFile="target/docbkx/eclipse/windows/developer_guide_toc.xml" />
										<move file="target/docbkx/eclipse/windows/admin_guide/toc.xml"
											toFile="target/docbkx/eclipse/windows/admin_guide_toc.xml" />
										<move file="target/docbkx/eclipse/linux/user_guide/toc.xml"
											toFile="target/docbkx/eclipse/linux/user_guide_toc.xml" />
										<move file="target/docbkx/eclipse/linux/developer_guide/toc.xml"
											toFile="target/docbkx/eclipse/linux/developer_guide_toc.xml" />
										<move file="target/docbkx/eclipse/linux/admin_guide/toc.xml"
											toFile="target/docbkx/eclipse/linux/admin_guide_toc.xml" />
										<echo>Modified toc.xml files and deleted plugin.xml and
											index.xml files.</echo>
										<zip destfile="target/docbkx/eclipse/windows/doc.zip">
											<fileset dir="target/docbkx/eclipse/windows"
												excludes="**/*.xml" />
											<zipfileset dir="target/docbkx/html/images"
												prefix="images" />
										</zip>
										<zip destfile="target/docbkx/eclipse/linux/doc.zip">
											<fileset dir="target/docbkx/eclipse/linux" excludes="**/*.xml" />
											<zipfileset dir="target/docbkx/html/images"
												prefix="images" />
										</zip>
										<echo>Generated doc.zip files.</echo>
									</target>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- render src/docbkx/*.xml sources to various formats - misc_ro -->
					<plugin>
						<groupId>com.agilejava.docbkx</groupId>
						<artifactId>docbkx-maven-plugin</artifactId>
						<version>2.0.14</version>
						<dependencies>
							<dependency>
								<groupId>org.docbook</groupId>
								<artifactId>docbook-xml</artifactId>
								<version>4.4</version>
								<scope>runtime</scope>
							</dependency>
						</dependencies>
						<executions>
							<execution>
								<id>generate-docbook-html</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>generate-html</goal>
								</goals>
								<configuration>
									<!-- image files must be manually added to the output - misc_ro -->
									<postProcess>
										<!-- ensure directory exists -->
										<mkdir dir="target/docbkx/diagrams/img-gen" />
										<copy todir="target/docbkx/html/images" flatten="true">
											<fileset dir="src/docbkx/" includes="**/images/*" />
											<fileset dir="target/docbkx/diagrams/img-gen" />
										</copy>
									</postProcess>
									<sectionLabelIncludesComponentLabel>true</sectionLabelIncludesComponentLabel>
								</configuration>
							</execution>
							<execution>
								<id>generate-docbook-pdf-windows</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>generate-pdf</goal>
								</goals>
								<configuration>
									<!-- reuse the images assembled for HTML for PDF generation - misc_ro -->
									<imgSrcPath>file:///${basedir}/target/docbkx/html/</imgSrcPath>
									<!-- required so docbook parts in sub-folders can reference images 
										consistently - misc_ro -->
									<keepRelativeImageUris>true</keepRelativeImageUris>
									<paperType>A4</paperType>
									<profileOs>windows</profileOs>
									<targetDirectory>${basedir}/target/docbkx/pdf/windows</targetDirectory>
									<sectionLabelIncludesComponentLabel>true</sectionLabelIncludesComponentLabel>
								</configuration>
							</execution>
							<execution>
								<id>generate-docbook-pdf-linux</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>generate-pdf</goal>
								</goals>
								<configuration>
									<!-- reuse the images assembled for HTML for PDF generation - misc_ro -->
									<imgSrcPath>file:///${basedir}/target/docbkx/html/</imgSrcPath>
									<!-- required so docbook parts in sub-folders can reference images 
										consistently - misc_ro -->
									<keepRelativeImageUris>true</keepRelativeImageUris>
									<paperType>A4</paperType>
									<profileOs>linux</profileOs>
									<targetDirectory>${basedir}/target/docbkx/pdf/linux</targetDirectory>
									<sectionLabelIncludesComponentLabel>true</sectionLabelIncludesComponentLabel>
								</configuration>
							</execution>
							<execution>
								<id>generate-docbook-eclipse-windows</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>generate-eclipse</goal>
								</goals>
								<configuration>
									<profileOs>windows</profileOs>
									<targetDirectory>${basedir}/target/docbkx/eclipse/windows</targetDirectory>
									<sectionLabelIncludesComponentLabel>true</sectionLabelIncludesComponentLabel>
								</configuration>
							</execution>
							<execution>
								<id>generate-docbook-eclipse-linux</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>generate-eclipse</goal>
								</goals>
								<configuration>
									<profileOs>linux</profileOs>
									<targetDirectory>${basedir}/target/docbkx/eclipse/linux</targetDirectory>
									<sectionLabelIncludesComponentLabel>true</sectionLabelIncludesComponentLabel>
								</configuration>
							</execution>
						</executions>
						<configuration>
							<chunkedOutput>true</chunkedOutput>
							<eclipseCustomization>${basedir}/src/docbkx/stylesheets/docbkx_rce_eclipse.xsl</eclipseCustomization>
							<foCustomization>${basedir}/src/docbkx/stylesheets/docbkx_rce_pdf.xsl</foCustomization>
							<!-- activate xInclude, which is a better approach than including 
								sections via XML entities - misc_ro -->
							<xincludeSupported>true</xincludeSupported>
							<entities>
								<!-- Transfer the build id into DocBook as an entity, as accessing 
									it as a Maven property does not seem to work when exporting from Ant. Another 
									option might be to insert it via XSLT to avoid undefined entity warnings 
									in editors. - misc_ro -->
								<entity>
									<name>buildId</name>
									<value>Build ${unqualifiedVersion}.${buildQualifier}</value>
								</entity>
							</entities>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>