<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright (c) 2001-2015, Zoltan Farkas All Rights Reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library 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
  GNU General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>spf4j-core</artifactId>
  <packaging>jar</packaging>
  <parent>
    <groupId>org.spf4j</groupId>
    <artifactId>spf4j</artifactId>
    <version>8.9.0</version>
  </parent>
  <name>${project.artifactId}</name>
  <description>A continuously growing collection of utilities to measure performance, get better diagnostics,
    improve performance, or do things more reliably, faster that other open source libraries...</description>
  <properties>
    <argLine>-ea -Xmx64m -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false</argLine>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.spf4j</groupId>
      <artifactId>spf4j-slf4j-test</artifactId>
      <scope>test</scope>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.spf4j.avro</groupId>
      <artifactId>core-schema</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>
    <dependency>
      <groupId>net.java.dev.jna</groupId>
      <artifactId>jna-platform</artifactId>
      <version>4.5.0</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>args4j</groupId>
      <artifactId>args4j</artifactId>
      <version>2.33</version>
      <!-- Need only is use of Monitor class is done as main -->
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>findbugs-annotations</artifactId>
      <version>3.0.1</version>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>3.0.2</version>
    </dependency>
    <dependency>
      <groupId>net.sf.trove4j</groupId>
      <artifactId>trove4j</artifactId>
      <version>3.0.3</version>
    </dependency>
    <dependency>
      <groupId>org.apache.avro</groupId>
      <artifactId>avro</artifactId>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <version>1.4.196</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>1.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>1.7.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <version>1.7.4</version>
        <scope>test</scope>
    </dependency>
  </dependencies>
  
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/avro/</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-test-source</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>target/generated-test-sources/avro</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- discover system property uses -->
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>spf4j-config-discovery-maven-plugin</artifactId>
        <version>${project.version}</version>
        <executions>
          <execution>
            <id>generate</id>
            <phase>process-classes</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>      

      <!-- Start generated avsc files for all IDL -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <id>create avsc destination folder</id>
            <phase>initialize</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo message="creating avsc folder target/generated-sources/avsc" />
                <mkdir dir="target/generated-sources/avsc" />
              </target>
            </configuration>
          </execution>
          <execution>
            <id>generate all sysprop defined files</id>
            <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <apply executable="java" force="true">
                  <arg value="-cp" />
                  <arg pathref="maven.plugin.classpath" />
                  <arg value="org.apache.avro.tool.Main" />
                  <arg value="idl2schemata" />
                  <srcfile />
                  <targetFile />
                  <mapper type="regexp" from="^((.*/)?)([^/]+)\.avdl$$" to="${project.basedir}/target/generated-sources/avsc/\1" />
                  <fileset dir="${project.basedir}/target/generated-sources/avdl" includes="**/*.avdl" />
                </apply>
              </target>
            </configuration>
          </execution>

          <execution>
            <id>generate avrodoc for all schemas</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <skip>${skip.avrodoc}</skip>
              <target>
                <fileset id="fileset" dir="${project.basedir}/target/generated-sources/avsc">
                  <include name="**/*.avsc" />
                </fileset>
                <pathconvert refid="fileset" property="converted" pathsep=" ">
                  <globmapper from="${project.basedir}/target/generated-sources/avsc/*" to="*" />
                </pathconvert>
                <exec executable="${project.basedir}/target/node/node" dir="${project.basedir}/target/generated-sources/avsc">
                  <arg value="${project.basedir}/target/lib/node_modules/avrodoc/bin/avrodoc" />
                  <arg line="${converted}" />
                  <arg value="-o${project.basedir}/target/avrodoc.html" />
                </exec>
              </target>
            </configuration>
          </execution>
          <execution>
            <phase>site</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <mkdir dir="target/site" />
                <copy file="target/avrodoc.html" todir="target/site" />
              </target>
            </configuration>
          </execution>

        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-tools</artifactId>
            <version>${avro.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- Generate avrodoc -->
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.6</version>
        <!-- executions go here -->
        <executions>
          <execution>
            <id>install node and npm</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <configuration>
              <nodeVersion>v4.4.4</nodeVersion>
              <npmVersion>2.15.1</npmVersion>
            </configuration>
          </execution>
          <execution>
            <id>install AVRODOC</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>install avrodoc -g</arguments>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <skip>${skip.avrodoc}</skip>
          <installDirectory>${project.basedir}/target</installDirectory>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <index>true</index>
            <manifestEntries>
              <Premain-Class>org.spf4j.base.InstrumentationHelper</Premain-Class>
            </manifestEntries>
          </archive>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>      
      </plugin>

      <plugin>
        <groupId>eu.somatik.serviceloader-maven-plugin</groupId>
        <artifactId>serviceloader-maven-plugin</artifactId>
        <version>1.0.7</version>
        <configuration>
          <services>
            <param>org.spf4j.io.ObjectAppender</param>
          </services>
        </configuration>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
            
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
      </plugin>
            
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkCount>1</forkCount>
          <reuseForks>false</reuseForks>
          <systemProperties>
            <spf4j.execContentFactoryWrapperClass>org.spf4j.stackmonitor.ProfiledExecutionContextFactory</spf4j.execContentFactoryWrapperClass>
          </systemProperties>
          <properties>
            <property>
              <name>listener</name>
              <value>org.spf4j.test.log.junit4.Spf4jTestLogRunListener</value>
            </property>
          </properties>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <!-- Include only classes referenced in this module and their -->
              <minimizeJar>true</minimizeJar>
              <artifactSet>
                <includes>
                  <include>com.google.guava:guava</include>
                </includes>
              </artifactSet>
              <relocations>
                <relocation>
                  <pattern>com.google.common</pattern>
                  <shadedPattern>org.spf4j.shaded.com.google.common</shadedPattern>
                </relocation>
              </relocations>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>guava</shadedClassifierName>
              <createDependencyReducedPom>true</createDependencyReducedPom>
              <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.avro</groupId>
                    <artifactId>
                      avro-maven-plugin
                    </artifactId>
                    <versionRange>
                      [1.8.1,)
                    </versionRange>
                    <goals>
                      <goal>idl-protocol</goal>
                      <goal>schema</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <execute>
                      <runOnIncremental>true</runOnIncremental>
                      <runOnConfiguration>true</runOnConfiguration>
                    </execute>
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>
                      org.apache.maven.plugins
                    </groupId>
                    <artifactId>
                      maven-antrun-plugin
                    </artifactId>
                    <versionRange>[1.8,)</versionRange>
                    <goals>
                      <goal>run</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.spf4j</groupId>
                    <artifactId>
                      spf4j-config-discovery-maven-plugin
                    </artifactId>
                    <versionRange>[8.3.14-SNAPSHOT,)</versionRange>
                    <goals>
                      <goal>generate</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco.version}</version>
      </plugin>
      <plugin>
        <groupId>org.spf4j</groupId>
        <artifactId>spf4j-jdiff-maven-plugin</artifactId>
        <version>${project.version}</version>
        <configuration>
          <maxNumberOfDiffs>12</maxNumberOfDiffs>
        </configuration>
      </plugin>

    </plugins>
  </reporting>
  
  
</project>
