<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2012 The Finnish Board of Education - Opetushallitus
  ~
  ~ This program is free software:  Licensed under the EUPL, Version 1.1 or - as
  ~ soon as they will be approved by the European Commission - subsequent versions
  ~ of the EUPL (the "Licence");
  ~
  ~ You may not use this work except in compliance with the Licence.
  ~ You may obtain a copy of the Licence at: http://www.osor.eu/eupl/
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ European Union Public Licence for more details.
  -->
<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>

	<!-- default build configuration for all projects and modules, can be overridden -->
	<groupId>fi.vm.sade.generic</groupId>
	<artifactId>build-parent</artifactId>
	<version>7.2</version>
	<packaging>pom</packaging>
	
	<properties>

		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

		<jetty.module>${project.artifactId}</jetty.module>
		<jetty.webApp>../${jetty.module}/target/${jetty.module}.war</jetty.webApp>
        <jetty.version>8.1.0.RC5</jetty.version>
		<daemon>false</daemon>
		<daemon>false</daemon>

		<!-- UI libraries -->
		<vaadin.version>6.8.12</vaadin.version>
		<gwt.version>2.3.0</gwt.version>
		<gwt.plugin.version>2.2.0</gwt.plugin.version>
		<servlet.version>3.0.1</servlet.version>
		<vaadin.formbinder.version>2.1.1</vaadin.formbinder.version>
		<portlet.api.version>2.0</portlet.api.version>
		<google.map.widget.version>0.9.13</google.map.widget.version>

		<!-- ServiceMix components / frameworks -->
		<cxf.version>2.5.1</cxf.version>
        <cxf.codegen.version>2.4.6</cxf.codegen.version>
        <wss4j.version>1.6.4</wss4j.version>
		<camel.version>2.8.3</camel.version>
		<spring.version>3.1.3.RELEASE</spring.version>
        <spring.security.version>${spring.version}</spring.security.version>
		<activemq.version>5.5.1</activemq.version>

		<!-- Logging -->
		<slf4j.version>1.6.1</slf4j.version>
        <slf4j-api.scope>compile</slf4j-api.scope>

		<!-- Database -->
		<jpa-api.version>2.0.0</jpa-api.version>
		<atomikos.version>3.6.6</atomikos.version>
		<jta.version>1.1</jta.version>
		<postgresql.version>9.3-1100.jdbc4</postgresql.version>
		<hsqldb.version>2.0.0</hsqldb.version>
		<hibernate.version>4.1.0.Final</hibernate.version>
		<commons-dbcp.version>1.4_1</commons-dbcp.version>
		<commons-lang.version>2.6</commons-lang.version>
        <querydsl.version>2.6.0</querydsl.version>
        
		<!-- Utils -->
        <commons-codec.version>1.6</commons-codec.version>
        <jodatime.version>2.1</jodatime.version>
		<log4j.version>1.2.14</log4j.version>
		<aopalliance.version>1.0</aopalliance.version>
		<aspectj.version>1.6.3</aspectj.version>
		<antisamy.version>1.4.5</antisamy.version>

		<!-- Testing -->
		<junit.version>4.10</junit.version>
		<selenium.version>2.37.0</selenium.version>
		<dbunit.version>2.4.8</dbunit.version>
		<mockito.version>1.9.0</mockito.version>

		<!-- Plugins versions -->
		<compiler.plugin.version>2.3.2</compiler.plugin.version>
		<enforcer.plugin.version>1.0.1</enforcer.plugin.version>
		<surefire.plugin.version>2.12</surefire.plugin.version>
		<failsafe.plugin.version>2.12</failsafe.plugin.version>
		<deploy.plugin.version>2.7</deploy.plugin.version>
		<release.plugin.version>2.2.1</release.plugin.version>
		<source.plugin.version>2.1.2</source.plugin.version>
		<checkstyle.plugin.version>2.9.1</checkstyle.plugin.version>
		<jar.plugin.version>2.4</jar.plugin.version>
		<resources.plugin.version>2.5</resources.plugin.version>
		<findbugs.plugin.version>2.3.3</findbugs.plugin.version>
		<jrebel.plugin.version>1.1.3</jrebel.plugin.version>
		<xml.plugin.version>1.0</xml.plugin.version>
			
		<project.svn.base>https://penaali.hard.ware.fi/svn/generic/${project.artifactId}</project.svn.base>

		<embedService.serviceArtifactId>${project.parent.artifactId}-service</embedService.serviceArtifactId>

		<checkstyle.excludes>**/generated/**/*,**/com/**/*,**/org/**/*,**/net/**/*,**/*Mock.java</checkstyle.excludes>
		<checkstyle.skip>false</checkstyle.skip>
		<checkstyle.failsOnError>true</checkstyle.failsOnError>
		<checkstyle.consoleOutput>true</checkstyle.consoleOutput>
		<checkstyle.configLocation><![CDATA[http://pulpetti.hard.ware.fi:9000/sonar/profiles/export?format=checkstyle&amp;language=java&amp;name=SonarWayWithFindbugsAndOPHCheckstyle]]></checkstyle.configLocation>

		<surefire.reportsDirectory>${project.build.directory}/surefire-reports</surefire.reportsDirectory>
		<surefire.testFailureIgnore>false</surefire.testFailureIgnore>
		<compiler.debug>false</compiler.debug>

        <mongo.version>2.7.1</mongo.version>

        <ant-contrib.version>1.0b3</ant-contrib.version>
        <ant-jsch.version>1.8.1</ant-jsch.version>
        <jsch.version>0.1.48</jsch.version>

        <!-- common clover properties -->
        <!-- OLD
        <clover.base>/data00/atlassian/application-data/bamboo/clover</clover.base>
		<clover.outputDirectory>${clover.base}/output/${project.groupId}-${project.artifactId}</clover.outputDirectory>
		-->
        <clover.version>3.1.8</clover.version>
        <clover.outputDirectory>${bamboo.data.home}/www/clover/${project.groupId}</clover.outputDirectory>
        <clover.base>${bamboo.data.home}/clover/${project.groupId}</clover.base>

        <!--<ehcache.version>2.6.3</ehcache.version>-->
        <ehcache.version>2.4.8</ehcache.version> <!-- sallii monta samannimista cachemanageria -->

        <tomcat.version>7.0.26</tomcat.version>
        <webapp.port>8180</webapp.port>
        <portlet.scope>provided</portlet.scope>

        <blackboard.version>2.1.1</blackboard.version>

        <buildversion_prefix />

        <httpcomponents.version>4.2.5</httpcomponents.version>
        <gson.version>2.2.2</gson.version>
        <jetty.embed.version>6.1.26</jetty.embed.version>
        <jersey.version>1.17.1</jersey.version>

    </properties>

    <scm>
        <connection>scm:git:git@github.com:Opetushallitus/build-parent.git</connection>
        <developerConnection>scm:git:git@github.com:Opetushallitus/build-parent.git</developerConnection>
        <url>http://github.com/Opetushallitus/build-parent</url>
    </scm>

	<distributionManagement>
		<repository>
			<id>oph-sade-artifactory</id>
			<name>oph-sade-artifactory-releases</name>
			<url>http://penaali.hard.ware.fi/artifactory/oph-sade-release-local</url>
		</repository>
		 <snapshotRepository>
			<id>oph-sade-artifactory</id>
			<name>oph-sade-artifactory-snapshots</name>
             <url>http://penaali.hard.ware.fi/artifactory/oph-sade-snapshot-local</url>
		</snapshotRepository>
	</distributionManagement>

	<repositories>
		<repository>
		    <id>oph-sade-artifactory-snapshots</id>
            <url>http://penaali.hard.ware.fi/artifactory/oph-sade-snapshot-local</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
		</repository>
		<repository>
			<id>oph-sade-artifactory-releases</id>
			<url>http://penaali.hard.ware.fi/artifactory/oph-sade-release-local</url>
		</repository>
		<repository>
			<id>vaadin-addons</id>
			<name>Vaadin addons</name>
			<url>http://penaali.hard.ware.fi/artifactory/vaadin-addons</url>
		</repository>
		<repository>
			<id>com.springsource.repository.bundles.release</id>
			<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
			<url>http://penaali.hard.ware.fi/artifactory/springsource-ebr/</url>
		</repository>
		<repository>
			<id>com.springsource.repository.bundles.external</id>
			<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
			<url>http://penaali.hard.ware.fi/artifactory/spring-ebr/</url>
		</repository>
		<repository>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
			<id>com.springsource.repository.maven.snapshot</id>
			<name>SpringSource Enterprise Bundle Maven Repository - SpringSource Snapshot Releases</name>
			<url>http://penaali.hard.ware.fi/artifactory/com.springsource.repository.maven.snapshot/</url>
		</repository>
		<repository>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<id>com.springsource.repository.maven.milestone</id>
			<name>Spring Framework Maven Milestone Releases (Maven Central Format)</name>
			<url>http://penaali.hard.ware.fi/artifactory/com.springsource.repository.maven.milestone/</url>
		</repository>
		<repository>
			<id>atomikos</id>
			<name>Atomikos repository</name>
			<url>http://penaali.hard.ware.fi/artifactory/atomikos/</url>
		</repository>
		<repository>
			<id>shibboleth</id>
			<name>Shibboleth</name>
			<url>http://penaali.hard.ware.fi/artifactory/shibboleth/</url>
		</repository>
		<repository>
			<id>libs-3rd-party</id>
			<name>libs-3rd-party</name>
			<url>http://penaali.hard.ware.fi/artifactory/libs-3rd-party</url>
		</repository>
		<repository>
			<id>bedatadriven</id>
			<name>bedatadriven</name>
			<url>http://penaali.hard.ware.fi/artifactory/bedatadriven/</url>
		</repository>
		<repository>
			<id>cpdetector</id>
			<name>cpdetector</name>
			<url>http://penaali.hard.ware.fi/artifactory/cpdetector</url>
		</repository>

		
				<!--
		<repository>
			<id>mysema</id>
			<name>Mysema source</name>
			<url>http://penaali.hard.ware.fi/artifactory/mysema/</url>
		</repository>-->

	</repositories>
	
	<pluginRepositories>
        <pluginRepository>
            <id>plugin-local-release</id>
            <name>Plugin local release</name>
            <url>http://penaali.hard.ware.fi/artifactory/plugins-release-local</url>
        </pluginRepository>
        <pluginRepository>
            <id>libs-3rd-party</id>
            <name>libs-3rd-party</name>
            <url>http://penaali.hard.ware.fi/artifactory/libs-3rd-party</url>
        </pluginRepository>
		<!--<pluginRepository>
			<id>com.springsource.repository.bundles.release</id>
			<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
			<url>http://penaali.hard.ware.fi/artifactory/springsource-ebr/</url>
		</pluginRepository>
		<pluginRepository>
			<id>com.springsource.repository.bundles.external</id>
			<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
			<url>http://penaali.hard.ware.fi/artifactory/spring-ebr/</url>
		</pluginRepository>
		<pluginRepository>
			<id>com.springsource.repository.bundles.milestone</id>
			<name>SpringSource Enterprise Bundle Repository - External Bundle Milestones</name>
			<url>http://penaali.hard.ware.fi/artifactory/com.springs    ource.repository.bundles.milestone/</url>
		</pluginRepository>-->
	</pluginRepositories>

	<build>

		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
				<includes>
					<include>**/*</include>
				</includes>
			</resource>
			<!-- profiilikohtaiset resurssit tassa etta ne ylikirjoittavat oletusresurssit -->
			<resource>
				<directory>src/main/profile/${env}</directory>
				<includes>
					<include>**/*</include>
				</includes>
			</resource>
			<resource>
				<directory>src/main/profile/${profileEnv}</directory>
				<includes>
					<include>**/*</include>
				</includes>
			</resource>
		</resources>

		<!--<extensions> -->
		<!--<extension> -->
		<!--<groupId>fi.vm.sade.generic</groupId> -->
		<!--<artifactId>generic-maven-extension</artifactId> -->
		<!--<version>1.0-SNAPSHOT</version> -->
		<!--</extension> -->
		<!--</extensions> -->

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.7</version>
                </plugin>
            </plugins>
        </pluginManagement>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
					<debug>${compiler.debug}</debug>
				</configuration>
			</plugin>
			<!--
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-enforcer-plugin</artifactId>
				<executions>
					<execution>
						<id>enforce-java</id>
                        <phase>clean</phase>
						<goals>
							<goal>enforce</goal>
						</goals>
						<configuration>
							<rules>
								<requireJavaVersion>
									<version>[1.6,1.6.1]</version>
								</requireJavaVersion>
							</rules>
						</configuration>
					</execution>
				</executions>
			</plugin>
			-->

			<!-- Attach sources with distribute package -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<executions>
					<execution>
						<id>attach-sources</id>
						<phase>verify</phase>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- separate unit tests and integration/system tests -->
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<reportsDirectory>${surefire.reportsDirectory}</reportsDirectory>
					<alwaysGenerateFailsafeReport>true</alwaysGenerateFailsafeReport>
					<testFailureIgnore>${surefire.testFailureIgnore}</testFailureIgnore>
					<excludes>
						<exclude>**/selenium/**/*</exclude>
						<exclude>**/it/**/*</exclude>
						<exclude>**/itest/**/*</exclude>
						<exclude>**/integrationtest/**/*</exclude>
						<exclude>**/stest/**/*</exclude>
						<exclude>**/systemtest/**/*</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-failsafe-plugin</artifactId>
				<configuration>
					<reportsDirectory>${surefire.reportsDirectory}</reportsDirectory>
					<alwaysGenerateFailsafeReport>true</alwaysGenerateFailsafeReport>
					<includes>
						<include>**/selenium/**/*Test*</include>
						<include>**/it/**/*Test*</include>
						<include>**/itest/**/*Test*</include>
						<include>**/integrationtest/**/*Test*</include>
						<include>**/stest/**/*Test*</include>
						<include>**/systemtest/**/*Test*</include>
					</includes>
					<argLine>-XX:MaxPermSize=256M -Xmx512m</argLine>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<!-- explicitly define maven-deploy-plugin after other to force exec
					order -->
				<artifactId>maven-deploy-plugin</artifactId>
				<!--<executions>--> <!--otin tämän pois, koska se aiheutti artifactien deployn kahteen kertaan - wuoti -->
					<!--<execution>-->
						<!--<id>deploy</id>-->
						<!--<phase>deploy</phase>-->
						<!--<goals>-->
							<!--<goal>deploy</goal>-->
						<!--</goals>-->
					<!--</execution>-->
				<!--</executions>-->
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<configuration>
					<!--<tagBase>${project.svn.base}/releases</tagBase>-->
				</configuration>
			</plugin>

			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<configuration>
					<overwrite>true</overwrite>
				</configuration>
			</plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>write buildversion.txt</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="writing target/${project.build.finalName}/${buildversion_prefix}buildversion.txt" />
                                <echo file="target/${project.build.finalName}/${buildversion_prefix}buildversion.txt">
                                    <![CDATA[artifactId=${project.artifactId}
version=${project.version}
buildNumber=${project.build}
branchName=${branch}
vcsRevision=${revision}
buildTtime=${maven.build.timestamp}
]]>
                                </echo>
                                <loadfile property="buildversiontxt" srcFile="target/${project.build.finalName}/${buildversion_prefix}buildversion.txt" />
                                <echo message="${buildversiontxt}" />
                                <echo file="target/mavenversion.txt">${project.version}</echo>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

		</plugins>
	</build>

	<reporting>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-report-plugin</artifactId>
				<version>${surefire.plugin.version}</version>
				<configuration>
					<reportsDirectory>${surefire.reportsDirectory}</reportsDirectory>
					<alwaysGenerateFailsafeReport>true</alwaysGenerateFailsafeReport>
				</configuration>
			</plugin>
		</plugins>
	</reporting>

	
		
	<profiles>
		<profile>
			<id>jrebel</id>
			<activation>
				<property>
					<name>!skipJrebel</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.zeroturnaround</groupId>
						<artifactId>jrebel-maven-plugin</artifactId>
						<version>${jrebel.plugin.version}</version>
						<executions>
							<execution>
								<id>generate-rebel-xml</id>
								<phase>clean</phase>
								<goals>
									<goal>generate</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>checkstyle</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-checkstyle-plugin</artifactId>
						<configuration>
							<excludes>${checkstyle.excludes}</excludes>
							<skip>${checkstyle.skip}</skip>
							<configLocation>${checkstyle.configLocation}</configLocation>
							<failsOnError>${checkstyle.failsOnError}</failsOnError>
							<consoleOutput>${checkstyle.consoleOutput}</consoleOutput>
						</configuration>
						<executions>
							<execution>
								<id>check</id>
								<phase>verify</phase>
								<goals>
									<goal>check</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<reporting>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-checkstyle-plugin</artifactId>
						<version>${checkstyle.plugin.version}</version>
						<configuration>
							<excludes>${checkstyle.excludes}</excludes>
							<skip>${checkstyle.skip}</skip>
							<configLocation>${checkstyle.configLocation}</configLocation>
							<failsOnError>${checkstyle.failsOnError}</failsOnError>
							<consoleOutput>${checkstyle.consoleOutput}</consoleOutput>
						</configuration>
					</plugin>
				</plugins>
			</reporting>
		</profile>
		<profile>
			<id>findbugs</id>
			<properties>
				<compiler.debug>true</compiler.debug>
				<findbugs.version>1.3.2</findbugs.version>
			</properties>
			<build>
				<plugins>
					<plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
						<executions>
							<execution>
								<id>antrun-findbugs</id>
								<phase>verify</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
										<if>
											<available file="${project.build.directory}/classes/fi" />
											<then>
												<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="maven.plugin.classpath" />

												<property name="findbugsclasspath" refid="maven.plugin.classpath" />
												<property name="runtime_classpath" refid="maven.runtime.classpath" />
												<property name="compile_classpath" refid="maven.compile.classpath" />

												<mkdir dir="${project.build.directory}/findbugs" />
												<echo>Using localRepository: ${settings.localRepository}</echo>
												<findbugs output="html" outputFile="${project.build.directory}/findbugs/findbugs.html" classpath="${findbugsclasspath}" pluginlist="${settings.localRepository}/net/sourceforge/findbugs/coreplugin/${findbugs.version}/coreplugin-${findbugs.version}.jar" jvmargs="-Xmx256m" reportLevel="medium" effort="default" failOnError="true">
													<sourcePath location="${project.basedir}/src/main/java" />
													<class location="${project.build.directory}/classes" />
													<auxClasspath>
														<path refid="maven.compile.classpath" />
														<path refid="maven.runtime.classpath" />
														<path refid="maven.plugin.classpath" />
													</auxClasspath>
												</findbugs>
											</then>
											<else>
												<echo>Skip findbugs, because directory
													'${project.build.directory}/classes/fi' not found.</echo>
											</else>
										</if>
									</target>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>net.sourceforge.findbugs</groupId>
								<artifactId>coreplugin</artifactId>
								<version>${findbugs.version}</version>
							</dependency>
							<dependency>
								<groupId>net.sourceforge.findbugs</groupId>
								<artifactId>findbugs</artifactId>
								<version>${findbugs.version}</version>
							</dependency>
							<dependency>
								<groupId>jaxen</groupId>
								<artifactId>jaxen</artifactId>
								<version>1.1</version>
							</dependency>
							<dependency>
								<groupId>ant-contrib</groupId>
								<artifactId>ant-contrib</artifactId>
								<version>${ant-contrib.version}</version>
								<exclusions>
									<exclusion>
										<groupId>ant</groupId>
										<artifactId>ant</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
					</plugin>
				</plugins>
			</build>
		</profile>

        <profile>
            <id>javadoc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.8.1</version>
                        <executions>
                            <execution>
                                <phase>install</phase>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

		<profile><!-- Update build artifacts from artifactory to local maven repository.
					  Used on Bamboo deployment plans update before calloing 'deploy.remote'. -->
			<id>update.artifacts</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<version>2.8</version>
						<executions>
							<execution>
								<id>copy</id>
								<phase>package</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>${project.groupId}</groupId>
											<artifactId>${project.artifactId}</artifactId>
											<version>${project.version}</version>
											<type>${project.packaging}</type>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<dependencies>
				<dependency>
					<groupId>${project.groupId}</groupId>
					<artifactId>${project.artifactId}</artifactId>
					<version>${project.version}</version>
					<type>${project.packaging}</type>
					<scope>validate</scope>
				</dependency>
			</dependencies>
		</profile>
	
		<profile><!-- Set default ant file for -Pdeploy.remote if -Dant.file=xxx is not spesified. -->
			<id>default-ant-file</id>
			<activation>
				<property>
					<name>!ant.file</name>
				</property>
			</activation>
			<properties>
				<ant.file>build.xml</ant.file>
			</properties>
		</profile>
		<profile><!-- Deploy artifacts to remote server. Used on Bamboo deployment plans. -->
			<id>deploy.remote</id>
			<build>
				<plugins>
					<plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
						<executions>
							<execution>
								<phase>validate</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<echo>Deploy: ${project.version} to ${tomcat-host}</echo>
										
										<ant antfile="${project.basedir}\${ant.file}">
											<property name="pom.version" value="${project.version}" />
										</ant>
									</target>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>org.apache.ant</groupId>
								<artifactId>ant-jsch</artifactId>
								<version>1.8.1</version>
							</dependency>
							<dependency>
								<groupId>com.jcraft</groupId>
								<artifactId>jsch</artifactId>
								<version>0.1.50</version>
							</dependency>
						</dependencies>
					</plugin>
				</plugins>
				
			</build>
		</profile>
        <profile>
            <id>clover-clean-post</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>clean-clover-post</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <delete includeemptydirs="true" failonerror="false">
                                            <fileset dir="${clover.outputDirectory}_old">
                                                <include name="**/**" />
                                            </fileset>
                                        </delete>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <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>
            </dependencies>
        </profile>

        <profile>
            <id>clover-clean-pre</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>clean-clover-pre</id>
                                <phase>clean</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo>Clean clover output directory from ${clover.base}.</echo>
                                        <delete includeemptydirs="true" failonerror="false">
                                            <fileset dir="${clover.base}">
                                                <include name="**/**" />
                                                <exclude name="history/**" />
                                            </fileset>
                                        </delete>
                                        <move failonerror="false" file="${clover.outputDirectory}" tofile="${clover.outputDirectory}_old" />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <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>
            </dependencies>
        </profile>
        <profile>
            <!--
           How-to build with Clover and Sonar:

           1. clean:
               $ mvn clean -N -Pclover-clean-pre -Dbamboo.data.home=/my/path/to/bamboo
           2. test ja clover:
               $ mvn clean install -Pclover -Dbamboo.data.home=/my/path/to/bamboo
           3. deploy and test WITHOUT clover:
               $ mvn clean deploy -DscreenshotMode=true -Pjavadoc -DskipITs
           4. Sonar reports:
               $ mvn sonar:sonar -Psonar -Dsonar.jdbc.password=XXXxxxXxx -Dbamboo.data.home=/my/path/to/bamboo
           5. cleanup after successfully build:
               $ mvn clean -N -Pclover-clean-pre -Dbamboo.data.home=/my/path/to/bamboo

           On windows machine you must user following syntax on bamboo.data.home property
               -Dbamboo.data.home=c:\\\\my\\path\\to\\bamboo
           and in linux
               -Dbamboo.data.home=/my/path/to/bamboo
           -->
            <id>clover</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.maven.plugins</groupId>
                        <artifactId>maven-clover2-plugin</artifactId>
                        <version>${clover.version}</version>

                        <configuration>
                            <licenseLocation>${bamboo.data.home}/clover/clover.license</licenseLocation>
                            <outputDirectory>${clover.outputDirectory}</outputDirectory>
                            <snapshot>${clover.base}/snapshot/clover.snapshot</snapshot>
                            <cloverDatabase>${clover.base}/db/clover.db</cloverDatabase>
                            <historyDir>${clover.base}/history</historyDir>

                            <singleCloverDatabase>true</singleCloverDatabase>
                            <generateHistorical>true</generateHistorical>
                            <alwaysReport>true</alwaysReport>
                            <generateXml>true</generateXml>
                            <includesAllSourceRoots>true</includesAllSourceRoots>
                            <!--<copyExcludedFiles>false</copyExcludedFiles>-->
							<!--<includes>
								  <include>**/api/**/*.java</include>
								  <include>some/path/MyFile.java</include>
								  [...]
							  </includes>  -->
                            <excludes>
                                <exclude>**/*Mock.java</exclude>
                                <exclude>**/*.scala</exclude>
                                <!-- TODO, FIXME: exclude "**/*-api/**" modules. -->
                            </excludes>
                            <!--  <targetPercentage>50%</targetPercentage>  -->
                        </configuration>
                        <executions>
                            <execution>
                                <id>clover</id>
                                <goals>
                                    <goal>setup</goal>
                                    <!--<goal>optimize</goal>-->
                                    <goal>snapshot</goal>
                                </goals>
                            </execution>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>clover</goal>
                                    <goal>log</goal>
                                    <!-- <goal>check</goal> disable!-->
                                    <goal>save-history</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>clean-scala-files</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo>Remove Scala files from target/clover directory.</echo>
                                        <delete failonerror="false" verbose="true">
                                            <fileset dir="target/clover">
                                                <include name="**/*.scala" />
                                            </fileset>
                                        </delete>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
				
            </build>
            <dependencies>
                <dependency>
                    <groupId>com.cenqua.clover</groupId>
                    <artifactId>clover</artifactId>
                    <version>${clover.version}</version>
                </dependency>
				<dependency>
                    <groupId>ant-contrib</groupId>
                    <artifactId>ant-contrib</artifactId>
                    <version>1.0b3</version>
                    <exclusions>
                        <exclusion>
                            <groupId>ant</groupId>
                            <artifactId>ant</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>sonar</id>
            <properties>
                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
                <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
                <sonar.core.codeCoveragePlugin>clover</sonar.core.codeCoveragePlugin>
                <sonar.clover.reportPath>${clover.outputDirectory}/clover.xml</sonar.clover.reportPath>

                <sonar.exclusions>**/*generated*/**,com/**,org/**,net/**,**/*Mock.java</sonar.exclusions>

                <sonar.jdbc.url>jdbc:mysql://pulpetti.hard.ware.fi:3306/sonar?useUnicode=true&amp;characterEncoding=utf8</sonar.jdbc.url>
                <sonar.jdbc.driverClassName>com.mysql.jdbc.Driver</sonar.jdbc.driverClassName>
                <sonar.jdbc.username>sonar</sonar.jdbc.username>
                <sonar.jdbc.password>${sonar.jdbc.password}</sonar.jdbc.password>
                <sonar.host.url>http://pulpetti.hard.ware.fi:9000/sonar</sonar.host.url>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.sonar-plugins</groupId>
                    <artifactId>sonar-clover-plugin</artifactId>
                    <version>2.9</version>
                </dependency>
            </dependencies>
        </profile>

		<profile><!-- profile to embed service dependency inside war in app module -->
			<id>embedService</id>
			<properties>
				<profileEnv>embedService</profileEnv>
			</properties>
			<dependencies>
				<dependency>
					<groupId>${project.groupId}</groupId>
					<artifactId>${embedService.serviceArtifactId}</artifactId>
					<version>${project.version}</version>
				</dependency>
			</dependencies>
		</profile>
		<profile>
			<id>development</id>
			<properties>
				<env>development</env>
			</properties>
		</profile>
		<profile>
			<id>ui-development</id>
			<properties>
				<env>ui-development</env>
			</properties>
		</profile>
		<profile>
			<id>integration-test</id>
			<properties>
				<env>integration-test</env>
			</properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemProperties>
                                <property>
                                    <name>ophServerUrl</name>
                                    <!-- TODO: lue build propseista -->
                                    <value>http://luokka.hard.ware.fi</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>system-test</id>
            <properties>
                <env>system-test</env>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemProperties>
                                <property>
                                    <name>ophServerUrl</name>
                                    <!-- TODO: lue build propseista -->
                                    <value>http://reppu.hard.ware.fi</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
			<id>QA</id>
			<properties>
				<env>QA</env>
			</properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemProperties>
                                <property>
                                    <name>ophServerUrl</name>
                                    <!-- TODO: lue build propseista -->
                                    <value>https://testi.virkailija.opintopolku.fi</value>
                                </property>
                                <property>
                                    <name>ophServerPort</name>
                                    <value>443</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
		</profile>
		<profile>
			<id>PRODUCTION</id>
			<properties>
				<env>PRODUCTION</env>
			</properties>
		</profile>
        <profile>
            <id>attach-schema-artifact</id>
            <activation>
                <file><exists>src/main/resources/META-INF/persistence.xml</exists></file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.7</version>
                        <executions>
                            <execution>
                                <id>attach-artifacts</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>target/hibernate3/sql/schema.ddl</file>
                                            <type>ddl</type>
                                            <classifier>schema</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jetty</id>
            <properties>
                <slf4j-api.scope>test</slf4j-api.scope>
            </properties>
        </profile>
        
        <profile><!-- Generate db diagram on Bamboo master branch builds -->
			<id>generate-db-diagram</id>
			<activation>
				<property>
					<name>branch</name>
					<value>master</value>
				</property>
			</activation>
			<properties>
				<schema.file>${project.basedir}/target/hibernate3/sql/schema.ddl</schema.file>
				<dbdiagram.generator>/usr/sbin/sql2diagram</dbdiagram.generator>
				<dbdiagram.output>${project.basedir}/target/sql2diagram/</dbdiagram.output>
				<dbdiagram.filename>${project.artifactId}-${project.version}</dbdiagram.filename>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.7</version>
						<executions>
							<execution>
								<phase>install</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
										<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
										<if>
											<available file="${schema.file}" />
											<then>
												<echo>Generate DB Diagrams fom file '${schema.file}'.</echo>
												<mkdir dir="${dbdiagram.output}" />
												<exec executable="${dbdiagram.generator}">
													<arg value="${schema.file}" />
													<arg value="${dbdiagram.output}/${dbdiagram.filename}" />
												</exec>
												<scp todir="bamboo@pulpetti:/var/www/html/db/" trust="true"
													 keyfile="${user.home}/.ssh/id_rsa" passphrase="">
													<fileset dir="${dbdiagram.output}">
														<include name="**/*" />
													</fileset>
												</scp>
											</then>
											<else>
												<echo>Skip DBDiagramGenerator, because file '${schema.file}' not found.</echo>
											</else>
										</if>
									</target>
								</configuration>
							</execution>
						</executions>
						<dependencies>
							<dependency>
								<groupId>org.apache.ant</groupId>
								<artifactId>ant-jsch</artifactId>
								<version>1.8.1</version>
							</dependency>
							<dependency>
								<groupId>com.jcraft</groupId>
								<artifactId>jsch</artifactId>
								<version>0.1.50</version>
							</dependency>
							<dependency>
								<groupId>ant-contrib</groupId>
								<artifactId>ant-contrib</artifactId>
								<version>${ant-contrib.version}</version>
								<exclusions>
									<exclusion>
										<groupId>ant</groupId>
										<artifactId>ant</artifactId>
									</exclusion>
								</exclusions>
							</dependency>
						</dependencies>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
