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

    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch-license</artifactId>
    <packaging>pom</packaging>
    <version>1.0.0-beta2</version>
    <modules>
        <module>core-shaded</module>
        <module>core</module>
        <module>licensor</module>
        <module>plugin</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <elasticsearch.version>1.4.0</elasticsearch.version>
        <lucene.version>4.10.2</lucene.version>
        <tests.jvms>auto</tests.jvms>
        <tests.shuffle>true</tests.shuffle>
        <tests.output>onerror</tests.output>
        <tests.bwc.path>${project.basedir}/backwards</tests.bwc.path>
        <es.logger.level>INFO</es.logger.level>
        <tests.heap.size>512m</tests.heap.size>
        <tests.topn>5</tests.topn>
        <execution.hint.file>.local-${project.version}-execution-hints.log</execution.hint.file>
        <license.basedir combine.self="override">${project.basedir}</license.basedir>
    </properties>

    <dependencies>

        <!-- test deps -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-test-framework</artifactId>
            <version>${lucene.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>${elasticsearch.version}</version>
            <scope>test</scope>
            <type>test-jar</type>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.carrotsearch.randomizedtesting</groupId>
            <artifactId>randomizedtesting-runner</artifactId>
            <version>2.1.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>test</scope>
        </dependency>

        <!-- actual deps -->
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>${elasticsearch.version}</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <fork>true</fork>
                    <maxmem>512m</maxmem>
                    <!-- REMOVE WHEN UPGRADE:
                         see https://jira.codehaus.org/browse/MCOMPILER-209 it's a bug where
                         incremental compilation doesn't work unless it's set to false causeing
                         recompilation of the entire codebase each time without any changes. Should
                         be fixed in version > 3.1
                     -->
                    <useIncrementalCompilation>false</useIncrementalCompilation>
                    <compilerArgs>
                        <arg>-XDignore.symbol.file</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <!-- we skip surefire to work with randomized testing above -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>de.thetaphi</groupId>
                <artifactId>forbiddenapis</artifactId>
                <version>1.6.1</version>

                <executions>
                    <execution>
                        <id>check-forbidden-apis</id>
                        <configuration>
                            <targetVersion>1.7</targetVersion>
                            <!-- disallow undocumented classes like sun.misc.Unsafe: -->
                            <internalRuntimeForbidden>true</internalRuntimeForbidden>
                            <!-- if the used Java version is too new, don't fail, just do nothing: -->
                            <failOnUnsupportedJava>false</failOnUnsupportedJava>
                            <excludes>
                                <exclude>jsr166e/**</exclude>
                                <!-- start excludes for valid system-out -->
                                <exclude>org/elasticsearch/shield/support/cli/Terminal*</exclude>
                                <exclude>org/elasticsearch/common/logging/log4j/ConsoleAppender*</exclude>
                                <exclude>org/elasticsearch/plugins/PluginManager.class</exclude>
                                <exclude>org/elasticsearch/bootstrap/Bootstrap.class</exclude>
                                <exclude>org/elasticsearch/Version.class</exclude>
                                <exclude>
                                    org/elasticsearch/common/lucene/search/Queries$QueryWrapperFilterFactory.class
                                </exclude>
                                <!-- end excludes for valid system-out -->
                                <!-- start excludes for Unsafe -->
                                <exclude>org/elasticsearch/common/util/UnsafeUtils.class</exclude>
                                <!-- end excludes for Unsafe -->
                                <!-- start excludes for Math.abs -->
                                <exclude>org/elasticsearch/common/util/MathUtils.class</exclude>
                                <exclude>org/elasticsearch/common/math/UnboxedMathUtils.class</exclude>
                                <exclude>org/elasticsearch/cluster/routing/operation/plain/PlainOperationRouting.class
                                </exclude>
                                <!-- end excludes for Math.abs -->
                                <!-- start exclude for FilteredQuery -->
                                <exclude>org/elasticsearch/common/lucene/search/XFilteredQuery.class</exclude>
                                <!-- end exclude for FilteredQuery -->
                                <!-- start exclude for Channels utility class -->
                                <exclude>org/elasticsearch/common/io/Channels.class</exclude>
                                <!-- end exclude for Channels -->
                            </excludes>
                            <bundledSignatures>
                                <!-- This will automatically choose the right signatures based on 'targetVersion': -->
                                <bundledSignature>jdk-unsafe</bundledSignature>
                                <bundledSignature>jdk-deprecated</bundledSignature>
                                <bundledSignature>jdk-system-out</bundledSignature>
                            </bundledSignatures>
                            <signaturesFiles>
                                <signaturesFile>${license.basedir}/dev-tools/forbidden/core-signatures.txt</signaturesFile>
                                <signaturesFile>${license.basedir}/dev-tools/forbidden/all-signatures.txt</signaturesFile>
                            </signaturesFiles>
                            <signatures>${forbidden.signatures}</signatures>
                        </configuration>
                        <phase>compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>check-forbidden-test-apis</id>
                        <configuration>
                            <targetVersion>1.7</targetVersion>
                            <!-- disallow undocumented classes like sun.misc.Unsafe: -->
                            <internalRuntimeForbidden>true</internalRuntimeForbidden>
                            <!-- if the used Java version is too new, don't fail, just do nothing: -->
                            <failOnUnsupportedJava>false</failOnUnsupportedJava>
                            <bundledSignatures>
                                <!-- This will automatically choose the right signatures based on 'targetVersion': -->
                                <bundledSignature>jdk-unsafe</bundledSignature>
                                <bundledSignature>jdk-deprecated</bundledSignature>
                            </bundledSignatures>
                            <signaturesFiles>
                                <signaturesFile>${license.basedir}/dev-tools/forbidden/test-signatures.txt</signaturesFile>
                                <signaturesFile>${license.basedir}/dev-tools/forbidden/all-signatures.txt</signaturesFile>
                            </signaturesFiles>
                            <signatures>${forbidden.test.signatures}</signatures>
                        </configuration>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCheck</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.3.1</version>
                <executions>
                    <execution>
                        <id>enforce-versions</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>[1.7,)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <header>${license.basedir}/dev-tools/license/elasticsearch_license_header.txt</header>
                    <headerDefinitions>
                        <headerDefinition>${license.basedir}/dev-tools/license/license_header_definition.xml</headerDefinition>
                    </headerDefinitions>
                    <includes>
                        <include>**/src/main/java/org/elasticsearch/**/*.java</include>
                        <include>**/src/test/java/org/elasticsearch/**/*.java</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>elasticsearch-private</id>
            <distributionManagement>
                <snapshotRepository>
                    <id>snapshots</id>
                    <name>maven.elasticsearch.org-snapshots</name>
                    <url>https://maven.elasticsearch.org/libs-snapshot-local</url>
                </snapshotRepository>
            </distributionManagement>
        </profile>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.carrotsearch.randomizedtesting</groupId>
                        <artifactId>junit4-maven-plugin</artifactId>
                        <version>2.1.2</version>
                        <configuration>
                            <argLine>${tests.jvm.argline}</argLine>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>