<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>cloud.altemista.fwk.framework</groupId>
		<artifactId>cloud-altemistafwk-recommended-plugins</artifactId>
		<version>3.1.0.RELEASE</version>
		<relativePath>../cloud-altemistafwk-recommended-plugins</relativePath>
	</parent>

	<artifactId>cloud-altemistafwk-parent</artifactId>
	<packaging>pom</packaging>

	<name>cloud-altemistafwk framework: parent POM</name>
	<description>Common parent for the ACF framework projects</description>

	<properties>
		<!-- == ACF source is Java 6 == -->
		<java.source.version>1.6</java.source.version>
		
		<!-- == ACF version == -->
		<cloud-altemistafwk.version>${project.version}</cloud-altemistafwk.version>
		
		<!-- == Additional plugins versions == -->
		<asciidoctor-maven-plugin.version>1.5.5</asciidoctor-maven-plugin.version>
		<jacoco-maven-plugin.version>0.7.7.201606060606</jacoco-maven-plugin.version>
		<license-maven-plugin.version>1.12</license-maven-plugin.version>
		<sonar-maven-plugin.version>2.7.1</sonar-maven-plugin.version>
		
		<!-- == Asciidoctor versions == -->
		<asciidoctorj.version>1.5.4.1</asciidoctorj.version>
		<asciidoctorj-pdf.version>1.5.0-alpha.14</asciidoctorj-pdf.version>
	</properties>
	
	<dependencyManagement>
		<dependencies>
			
			<!-- == ACF framework: bill of materials == -->
			<dependency>
				<groupId>cloud.altemista.fwk.framework</groupId>
				<artifactId>cloud-altemistafwk-bom</artifactId>
				<version>${cloud-altemistafwk.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			
		</dependencies>
	</dependencyManagement>
	
	<build>
		<pluginManagement>
			<plugins>
			
				<!-- == Begin org.codehaus.mojo License plugin == -->
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>license-maven-plugin</artifactId>
					<version>${license-maven-plugin.version}</version>
					<configuration>
						<licenseResolver>classpath://license</licenseResolver>
						<licenseName>altemista_cloud_framework</licenseName>
						<roots>
							<root>src/main/java</root>
							<root>src/test/java</root>
						</roots>
						<includes>
							<include>**/*.java</include>
						</includes>
					</configuration>
					<dependencies>
						<dependency>
							<groupId>cloud.altemista.fwk.framework</groupId>
							<artifactId>cloud-altemistafwk-license</artifactId>
							<version>${cloud-altemistafwk.version}</version>
							<type>zip</type>
						</dependency>
					</dependencies>
				</plugin>
				<!-- == End org.codehaus.mojo License plugin == -->
				
				<!-- == End org.codehaus.mojo Sonar plugin == -->
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>sonar-maven-plugin</artifactId>
					<version>${sonar-maven-plugin.version}</version>
				</plugin>
				<!-- == End org.codehaus.mojo Sonar plugin == -->
				
				<!-- == Begin JaCoCo == -->
				<plugin>
					<groupId>org.jacoco</groupId>
					<artifactId>jacoco-maven-plugin</artifactId>
					<version>${jacoco-maven-plugin.version}</version>
				</plugin>
				<!-- == End JaCoCo == -->
				
				<!-- == Begin Asciidoctor == -->
				<plugin>
					<groupId>org.asciidoctor</groupId>
					<artifactId>asciidoctor-maven-plugin</artifactId>
					<version>${asciidoctor-maven-plugin.version}</version>
					<dependencies>
						<dependency>
							<groupId>org.asciidoctor</groupId>
							<artifactId>asciidoctorj</artifactId>
							<version>${asciidoctorj.version}</version>
						</dependency>
						<dependency>
							<groupId>org.asciidoctor</groupId>
							<artifactId>asciidoctorj-pdf</artifactId>
							<version>${asciidoctorj-pdf.version}</version>
						</dependency>
						<!-- Fixes: "asciidoctorj-pdf does not work with JRuby 1.7.23 #3496" (https://github.com/jruby/jruby/issues/3496) -->
						<dependency>
							<groupId>org.jruby</groupId>
							<artifactId>jruby-complete</artifactId>
							<version>1.7.26</version>
						</dependency>
						
					</dependencies>
				</plugin>
				<!-- == End Asciidoctor == -->
			</plugins>
		</pluginManagement>

		<plugins>

			<!-- == Begin enforcer == -->
			<plugin>
				<artifactId>maven-enforcer-plugin</artifactId>
				<configuration>
					<rules>
						<!-- Ensures the framework is being built with the proper Java and Maven versions -->
						<requireJavaVersion>
							<version>1.7</version>
						</requireJavaVersion>
						<requireMavenVersion>
							<!--
								(see "Requiring multiple profile activation conditions to be true does not work"
								https://issues.apache.org/jira/browse/MNG-4565)
							-->
							<version>3.2.2</version>
						</requireMavenVersion>
					</rules>
				</configuration>
				<executions>
					<execution>
						<id>enforce-java-maven-versions</id>
						<goals>
							<goal>enforce</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!-- == End enforcer == -->

		</plugins>
	</build>
	
	<profiles>
		
		<!-- Includes the license in the project -->
		<profile>
			<id>update-license</id>
			<activation>
				<activeByDefault>false</activeByDefault>
				<file>
					<exists>src</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>license-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>update-license</id>
								<goals>
									<goal>add-third-party</goal>
									<goal>update-project-license</goal>
								</goals>
								<configuration>
									<licenseFile>target/generated-resources/license/LICENSE.txt</licenseFile>
									<outputDirectory>target/generated-resources/license</outputDirectory>
									<generateBundle>true</generateBundle>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	
		<!-- Includes/updates the copyright notice in the source files -->
		<profile>
			<id>update-copyright</id>
			<activation>
				<!-- Disabled by default: should be triggered manually -->
				<activeByDefault>false</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>license-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>update-copyright</id>
								<phase>process-sources</phase>
								<goals>
									<goal>update-file-header</goal>
								</goals>
								<configuration>
									<canUpdateCopyright>true</canUpdateCopyright>
									<canUpdateDescription>true</canUpdateDescription>
									<canUpdateLicense>true</canUpdateLicense>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	
		<!-- Verifies the copyright notice in the source files is up to date -->
		<profile>
			<id>verify-copyright</id>
			<activation>
				<activeByDefault>false</activeByDefault>
				<file>
					<exists>src/main/java</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>license-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>verify-copyright</id>
								<phase>verify</phase>
								<goals>
									<goal>check-file-header</goal>
								</goals>
								<configuration>
									<failOnMissingHeader>false</failOnMissingHeader>
									<!-- failOnNotUptodateHeader disabled due wrong whitespace detection: -->
									<failOnNotUptodateHeader>false</failOnNotUptodateHeader>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Enable to create a jar archive of the source files of the project -->
		<profile>
			<id>with-sources</id>
			<activation>
				<!-- Disabled by default: should be triggered manually -->
				<activeByDefault>true</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-source-plugin</artifactId>
						<executions>
							<execution>
								<id>source-jar</id>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Enable sign filest -->
		<profile>
			<id>with-sign</id>
			<activation>
				<!-- Disabled by default: should be triggered manually -->
				<activeByDefault>false</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-gpg-plugin</artifactId>
							<executions>
						      <execution>
						          	<id>sign-artifacts</id>
						          	<phase>verify</phase>
						          	<goals>
						            	<goal>sign</goal>
						          	</goals>
						        </execution>
							</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Generates javadocs for the project -->
		<profile>
			<id>with-javadoc</id>
			<activation>
				<activeByDefault>false</activeByDefault>
				<file>
					<exists>src/main/java</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-javadoc-plugin</artifactId>
						<configuration>
							<!-- Ignore "reference not found" errors mainly -->
							<failOnError>false</failOnError>
							<quiet>true</quiet>
							<!-- Ignore @mbggenerated tags (MyBatis generator) -->
							<tags>
								<tag>
									<name>mbggenerated</name>
									<placement>X</placement>
								</tag>
							</tags>
						</configuration>
						<executions>
							<execution>
								<id>javadoc-jar</id>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Generates coverage reports using the JaCoCo runtime agent -->
		<profile>
			<id>with-unit-coverage</id>
			<activation>
				<activeByDefault>false</activeByDefault>
				<file>
					<exists>src/test/java</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.jacoco</groupId>
						<artifactId>jacoco-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>jacoco-for-unit</id>
								<goals>
									<goal>prepare-agent</goal>
								</goals>
								<configuration>
									<destFile>${project.build.directory}/jacoco-unit.exec</destFile>
									<propertyName>surefireArgLine</propertyName>
									<skip>${skipTests}</skip>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<argLine>${surefireArgLine}</argLine>
							<skipTests>${skipTests}</skipTests>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		
		<!-- Generates an asciidoc bundle that can be imported in the documentation project -->
		<profile>
			<id>with-asciidoc</id>
			<activation>
				<activeByDefault>false</activeByDefault>
				<file>
					<exists>src/main/asciidoc</exists>
				</file>
			</activation>
			<build>
				<plugins>
				
					<!-- Imports the common assembly descriptor for documentation fragments -->
					<plugin>
						<artifactId>maven-dependency-plugin</artifactId>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>cloud.altemista.fwk.framework</groupId>
									<artifactId>cloud-altemistafwk-documentation-fragment</artifactId>
									<version>${cloud-altemistafwk.version}</version>
									<type>zip</type>
								</artifactItem>
							</artifactItems>
						</configuration>
						<executions>
							<execution>
								<id>import-asciidoc-assembly-descriptor</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
					
					<!-- Generates the asciidoc bundle based on the common assembly descriptor -->
					<plugin>
						<artifactId>maven-assembly-plugin</artifactId>
						<executions>
							<execution>
								<id>export-asciidoc</id>
								<phase>package</phase>
								<goals>
									<goal>single</goal>
								</goals>
								<configuration>
									<descriptors>
										<descriptor>${project.build.directory}/dependency/assembly/export-asciidoc.xml</descriptor>
									</descriptors>
									<finalName>${project.artifactId}</finalName>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		
	</profiles>
	
</project>
