<?xml version="1.0" encoding="UTF-8"?>
<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>

    <name>avast-oss-parent</name>
    <description>Parent pom for Avast (Java and Scala) open-source projects..</description>

    <groupId>com.avast</groupId>
    <artifactId>avast-oss-parent</artifactId>
    <version>1.0.6</version>
    <packaging>pom</packaging>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>9</version>
    </parent>

    <url>https://github.com/avast/avast-oss-parent</url>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://opensource.org/licenses/Apache-2.0</url>
        </license>
    </licenses>

    <organization>
        <name>AVAST Software</name>
        <url>http://www.avast.com</url>
    </organization>

    <developers>
        <developer>
            <id>karas</id>
            <name>Lukas Karas</name>
            <email>karas@avast.com</email>
            <organization>AVAST Software</organization>
            <organizationUrl>http://www.avast.com</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:avast/avast-oss-parent.git</connection>
        <developerConnection>scm:git:git@github.com:avast/avast-oss-parent.git</developerConnection>
        <url>git@github.com:avast/avast-oss-parent.git</url>
        <tag>avast-oss-parent-1.0.6</tag>
    </scm>

    <properties>
        <source.java.version>1.6</source.java.version>

        <build.java.version>1.6</build.java.version>

        <timestamp>${maven.build.timestamp}</timestamp>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- configurtion for POM property fix-->
        <property.fix.dir>pom-property-fix</property.fix.dir>


        <repo.snapshot.id>sonatype-nexus-snapshots</repo.snapshot.id>
        <repo.snapshot.url>${sonatypeOssDistMgmtSnapshotsUrl}</repo.snapshot.url>

        <repo.release.id>sonatype-nexus-staging</repo.release.id>
        <repo.release.url>https://oss.sonatype.org/service/local/staging/deploy/maven2</repo.release.url>

        <!-- URL of the repository used to deploy artifacts to.
             It's the snapshots repository by default, overriden by the 'release' profile during release. -->
        <repo.deploy.url>${repo.snapshot.url}</repo.deploy.url>
        <repo.id>${repo.snapshot.id}</repo.id>
        <release>false</release>

        <!-- Maven gpg plugin uses default key for signing and ignores "-Dgpg.keyname=" property... -->
        <gpg.keyname>A03063C5</gpg.keyname>
        <gpg.defaultKeyring>false</gpg.defaultKeyring>
    </properties>

    <profiles>

        <!-- This profile must be active during release.
             It sets the property 'release' to true and override property 'repo.deploy.url' to release repository. -->
        <profile>
            <id>release</id>
            <properties>
                <repo.deploy.url>${repo.release.url}</repo.deploy.url>
                <repo.id>${repo.release.id}</repo.id>
                <release>true</release>
            </properties>
        </profile>

        <profile>
            <id>scala-2.9</id>
            <properties>
                <build.scala.version>2.9</build.scala.version>
                <build.scala.compiler.version>2.9.3</build.scala.compiler.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest_${build.scala.compiler.version}</artifactId>
                    <version>2.0.M5b</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.alchim31.maven</groupId>
                        <artifactId>scala-maven-plugin</artifactId>
                        <configuration>
                            <scalaVersion>${build.scala.compiler.version}</scalaVersion>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>scala-2.10</id>
            <properties>
                <build.scala.version>2.10</build.scala.version>
                <build.scala.compiler.version>2.10.4</build.scala.compiler.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest_${build.scala.version}</artifactId>
                    <version>2.2.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.alchim31.maven</groupId>
                        <artifactId>scala-maven-plugin</artifactId>
                        <configuration>
                            <scalaVersion>${build.scala.compiler.version}</scalaVersion>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>scala-2.11</id>
            <properties>
                <build.scala.version>2.11</build.scala.version>
                <build.scala.compiler.version>2.11.2</build.scala.compiler.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest_${build.scala.version}</artifactId>
                    <version>2.2.1</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>net.alchim31.maven</groupId>
                        <artifactId>scala-maven-plugin</artifactId>
                        <configuration>
                            <scalaVersion>${build.scala.compiler.version}</scalaVersion>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>


    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                </plugin>

                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <configuration>
                        <scalaVersion>${build.scala.compiler.version}</scalaVersion>
                    </configuration>
                    <version>3.1.6</version>
                    <executions>
                        <!-- Compilation in process-resources phase is necessary for mixed Java/Scala projects - Scala must be compiled before Java classes. -->
                        <execution>
                            <id>compile-first</id>
                            <phase>process-resources</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>test-compile-first</id>
                            <phase>process-test-resources</phase>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>compile</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scaladoc</id>
                            <phase>site</phase>
                            <goals>
                                <goal>doc-jar</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scala-source</id>
                            <phase>process-sources</phase>
                            <goals>
                                <goal>add-source</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>scala-test-sources</id>
                            <phase>process-test-resources</phase>
                            <goals>
                                <goal>add-source</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>test-compile</id>
                            <phase>test-compile</phase>
                            <goals>
                                <goal>testCompile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.8</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.2.1</version>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.8</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.1</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.8.1</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.4</version>
                </plugin>

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>buildnumber-maven-plugin</artifactId>
                    <version>1.3</version>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>1.3.1</version>
                </plugin>

                <plugin>
                    <groupId>com.google.protobuf.tools</groupId>
                    <artifactId>maven-protoc-plugin</artifactId>
                    <version>0.1.10</version>
                    <configuration>
                        <protoSourceRoot>src/main/proto</protoSourceRoot>
                        <outputDirectory>${project.build.directory}/generated-sources/proto</outputDirectory>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>com.avast</groupId>
                    <artifactId>syringe-maven-plugin</artifactId>
                    <version>1.2.0</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>${source.java.version}</source>
                    <target>${build.java.version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <archive>
                        <manifest>
                            <useUniqueVersions>false</useUniqueVersions>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.avast.strup.client.netty.TestMain</mainClass>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <includes>
                        <include>**/*.java</include>
                        <include>**/*.scala</include>
                    </includes>
                </configuration>

                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>attach-test-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>test-jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <preparationGoals>verify</preparationGoals>
                    <checkModificationExcludes>
                        <checkModificationExclude>pom.xml</checkModificationExclude>
                        <checkModificationExclude>*/pom.xml</checkModificationExclude>
                    </checkModificationExcludes>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <arguments>-Psonatype-oss-release</arguments>
                    <mavenExecutorId>forked-path</mavenExecutorId>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>property-fix</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${basedir}</directory>
                                    <includes>
                                        <include>pom.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                            <outputDirectory>${project.build.directory}/${property.fix.dir}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <!-- Overwrites the POM installed into local repository with POM with replaced (resolved) properties.
                         This is necessary for the Scala cross-compilation to work. -->
                    <execution>
                        <id>overwrite-installed-pom</id>
                        <phase>install</phase>
                        <goals>
                            <goal>install-file</goal>
                        </goals>
                        <configuration>
                            <packaging>pom</packaging>
                            <file>target/${property.fix.dir}/pom.xml</file>
                            <pomFile>target/${property.fix.dir}/pom.xml</pomFile>
                            <version>${project.version}</version>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.1</version>
                <executions>
                    <!-- Overwrites the deployed POM with POM with replaced (resolved) properties.
                         This is necessary for the Scala cross-compilation to work. -->
                    <execution>
                        <id>overwrite-deployed-pom</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <repositoryId>${repo.id}</repositoryId>
                            <url>${repo.deploy.url}</url>
                            <packaging>pom</packaging>
                            <file>target/${property.fix.dir}/pom.xml</file>
                            <pomFile>target/${property.fix.dir}/pom.xml</pomFile>
                            <version>${project.version}</version>
                            <updateReleaseInfo>${release}</updateReleaseInfo>
                            <uniqueVersion>false</uniqueVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

</project>
