<?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-aspects</artifactId>
  <packaging>jar</packaging>
  <parent>
    <groupId>org.spf4j</groupId>
    <artifactId>spf4j</artifactId>
    <version>8.9.0</version>
  </parent>
  <name>${project.artifactId}</name>
  <description>spf4j aspects for monitoring performance and retry</description>

  <properties>
    <jacoco.instruction.ratio>0.2</jacoco.instruction.ratio>
    <jacoco.class.ratio>0.3</jacoco.class.ratio>
    <jacoco.method.ratio>0.3</jacoco.method.ratio>
    <argLine>-javaagent:${project.build.directory}/lib/aspectjweaver-${aspectj.version}.jar -javaagent:${project.build.directory}/lib/spf4j-core-${project.version}.jar</argLine>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.spf4j</groupId>
      <artifactId>spf4j-core</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>${aspectj.version}</version>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>${aspectj.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.spf4j</groupId>
      <artifactId>spf4j-slf4j-test</artifactId>
      <scope>test</scope>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>1.3</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  
  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.aspectj</groupId>
                  <artifactId>aspectjweaver</artifactId>
                  <version>${aspectj.version}</version>
                  <type>jar</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>org.spf4j</groupId>
                  <artifactId>spf4j-core</artifactId>
                  <version>${project.version}</version>
                  <type>jar</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>true</overWriteSnapshots>
            </configuration>
          </execution>
        </executions>
      </plugin>
            
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
          <forkCount>1</forkCount>
          <reuseForks>false</reuseForks>
          <systemProperties>
            <spf4j.test.log.expectingErrorsIn>org.aspectj.weaver.bcel.BcelWorld</spf4j.test.log.expectingErrorsIn>
            <aj.weaving.verbose>true</aj.weaving.verbose>
            <org.aspectj.tracing.enabled>false</org.aspectj.tracing.enabled>
            <org.aspectj.tracing.debug>false</org.aspectj.tracing.debug>
            <spf4j.test.log.rootPrintLevelIDE>TRACE</spf4j.test.log.rootPrintLevelIDE>
            <spf4j.test.log.rootPrintLevel>INFO</spf4j.test.log.rootPrintLevel>
            <org.aspectj.weaver.loadtime.configuration>file:META-INF/aop.xml</org.aspectj.weaver.loadtime.configuration>
          </systemProperties>
          <properties>
            <property>
              <name>listener</name>
              <value>org.spf4j.test.log.junit4.Spf4jTestLogRunListener</value>
            </property>
          </properties>
        </configuration>
        <executions>
          <execution>
            <id>surefire-it</id>
            <phase>integration-test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <skip>false</skip>
            </configuration>
          </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>

      <!-- install avrodoc -->
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.0</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>


      <!-- 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="${java8.home}/bin/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>
              <tasks>
                <mkdir dir="target/site" />
                <copy file="target/avrodoc.html" todir="target/site" />
              </tasks>
            </configuration>
          </execution>

        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-tools</artifactId>
            <version>${avro.version}</version>
          </dependency>
        </dependencies>
      </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.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.apache.maven.plugins
                    </groupId>
                    <artifactId>
                      maven-dependency-plugin
                    </artifactId>
                    <versionRange>[2.10,)</versionRange>
                    <goals>
                      <goal>copy</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>
</project>
