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

  <groupId>org.spf4j.avro</groupId>
  <artifactId>schema-parent-pom</artifactId>
  <version>0.28</version>
  <packaging>pom</packaging>
  <name>${project.artifactId}-${project.version}</name>
  <description>Avro schema project parent</description>
  <properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spf4j.version>8.6.34</spf4j.version>
    <!-- default to my fork: https://github.com/zolyfarkas/avro/blob/trunk/README.md -->
    <avro.version>1.9.0.16p</avro.version>
    <scm.url>https://github.com/zolyfarkas/schema-parent-pom</scm.url>
    <scm.connection>scm:git:${scm.url}.git</scm.connection>
    <skip.avrodoc>false</skip.avrodoc>
    <skip.avrodoc.html>true</skip.avrodoc.html> <!-- set to false if html should be published to repo -->
    <node.downloadUrl>https://nodejs.org/dist/</node.downloadUrl>
    <npm.downloadUrl>https://registry.npmjs.org/npm/-/</npm.downloadUrl>
    <npm.registryUrl />
    <avro.allowUndefinedLogicalTypes>false</avro.allowUndefinedLogicalTypes>
    <avro.deleteProtocolInterface>true</avro.deleteProtocolInterface>
    <avro.validator.deprecationRemoval>true</avro.validator.deprecationRemoval>
    <avro.validator.maxNrOfVersionsToCheckForCompatibility>20</avro.validator.maxNrOfVersionsToCheckForCompatibility>
    <avro.validator.maxNrOfDaysBackCheckForCompatibility>365</avro.validator.maxNrOfDaysBackCheckForCompatibility>
    <avro.createSetters>false</avro.createSetters>
    <avro.validator.validFieldNames>id</avro.validator.validFieldNames>
    <avro.useSchemaReferencesForAvsc>false</avro.useSchemaReferencesForAvsc>
    <compatibility.skip>false</compatibility.skip>
    <namesValidator.skip>false</namesValidator.skip>
    <docValidator.skip>false</docValidator.skip>
    <compatibility.versionRange>[,${project.version})</compatibility.versionRange>
    <scm-publish.checkoutDirectory>${project.build.directory}/scmpublish</scm-publish.checkoutDirectory>
    <scm-publish.scmBranch>gh-pages</scm-publish.scmBranch>
    <scm-publish.pubScmUrl>${scm.connection}</scm-publish.pubScmUrl>
  </properties>

    <url>${scm.url}</url>
    <organization>
      <name>SPF4J</name>
      <url>http://www.spf4j.org</url>
    </organization>
    
    <licenses>
        <license>
            <name>GNU Library or Lesser General Public License (LGPL) 3.0</name>
            <url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>GNU Library or Lesser General Public License (LGPL) 2.1</name>
            <url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</url>
            <distribution>repo</distribution>
        </license>
        <license>
          <name>The Apache Software License, Version 2.0</name>
          <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
          <distribution>repo</distribution>
        </license>
    </licenses>

    <repositories>
      <repository>
        <snapshots>
          <enabled>false</enabled>
        </snapshots>
        <id>bintray-zolyfarkas-core</id>
        <name>bintray</name>
        <url>https://dl.bintray.com/zolyfarkas/core</url>
      </repository>
    </repositories>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <developers>
    <developer>
      <name>Zoltan Farkas</name>
      <timezone>ET</timezone>
      <roles>
        <role>Lead</role>
      </roles>
      <url>https://github.com/zolyfarkas</url>
    </developer>
  </developers>

  <profiles>
    <profile>
      <id>windows</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <cmd.ext>.cmd</cmd.ext>
      </properties>
    </profile>
    <profile>
      <activation>
        <file><exists>parent.marker</exists></file>
      </activation>
      <properties>
          <skip.avrodoc>true</skip.avrodoc>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-scm-publish-plugin</artifactId>
              <executions>
                  <execution>
                      <phase>none</phase>
                  </execution>
              </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <scm>
    <connection>${scm.connection}</connection>
    <developerConnection>${scm.connection}</developerConnection>
    <url>${scm.url}</url>
    <tag>schema-parent-pom-0.28</tag>
  </scm>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.0.1</version>
          <configuration>
            <failOnError>false</failOnError>
            <quiet>true</quiet>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
     <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>1.6</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>1.6.5</version>
        <extensions>true</extensions>
        <configuration>
          <serverId>ossrh</serverId>
          <nexusUrl>https://oss.sonatype.org/</nexusUrl>
          <autoReleaseAfterClose>true</autoReleaseAfterClose>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>1.4</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <getRevisionOnlyOnce>true</getRevisionOnlyOnce>
          <providerImplementations>
            <git>git</git>
          </providerImplementations>
          <doCheck>false</doCheck>
          <doUpdate>false</doUpdate>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.spf4j</groupId>
        <artifactId>maven-avro-schema-plugin</artifactId>
        <version>${spf4j.version}</version>
        <extensions>true</extensions>
        <configuration>
          <createSetters>${avro.createSetters}</createSetters>
          <deleteProtocolInterface>${avro.deleteProtocolInterface}</deleteProtocolInterface>
          <useSchemaReferencesForAvsc>${avro.useSchemaReferencesForAvsc}</useSchemaReferencesForAvsc>
          <systemProperties>
            <allowUndefinedLogicalTypes>${avro.allowUndefinedLogicalTypes}</allowUndefinedLogicalTypes>
          </systemProperties>
          <validatorConfigs>
            <compatibility.skip>${compatibility.skip}</compatibility.skip>
            <compatibility.maxNrOfVersionsToCheckForCompatibility>${avro.validator.maxNrOfVersionsToCheckForCompatibility}</compatibility.maxNrOfVersionsToCheckForCompatibility>
            <compatibility.maxNrOfDaysBackCheckForCompatibility>${avro.validator.maxNrOfDaysBackCheckForCompatibility}</compatibility.maxNrOfDaysBackCheckForCompatibility>
            <compatibility.deprecationRemoval>${avro.validator.deprecationRemoval}</compatibility.deprecationRemoval>
            <compatibility.versionRange>${compatibility.versionRange}</compatibility.versionRange>
            <namesValidator.validFieldNames>${avro.validator.validFieldNames}</namesValidator.validFieldNames>
            <namesValidator.skip>${namesValidator.skip}</namesValidator.skip>
            <docValidator.skip>${docValidator.skip}</docValidator.skip>
          </validatorConfigs>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro</artifactId>
            <version>${avro.version}</version>
          </dependency>
          <dependency>
            <groupId>org.apache.avro</groupId>
            <artifactId>avro-compiler</artifactId>
            <version>${avro.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <fork>true</fork>
          <!--
          <executable>${java.home}/bin/javac</executable>
            -->
          <compilerVersion>${java.version}</compilerVersion>
          <source>${java.version}</source>
          <target>${java.version}</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <archive>
            <manifest>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
            <manifestEntries>
              <Implementation-Vendor>${project.groupId}</Implementation-Vendor>
              <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>
              <Implementation-Title>${project.artifactId}</Implementation-Title>
              <Implementation-Version>${project.version}</Implementation-Version>
              <Implementation-Description>${project.description}</Implementation-Description>
              <Implementation-Url>${project.url}</Implementation-Url>
              <Implementation-Org>${project.organization.name}</Implementation-Org>
              <Implementation-Org-Url>${project.organization.url}</Implementation-Org-Url>
              <Implementation-Build>${buildNumber}</Implementation-Build>
              <Build-Time>${maven.build.timestamp}</Build-Time>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <version>2.5.3</version>
      </plugin>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.7.6</version>
        <!-- executions go here -->
        <executions>
          <execution>
            <id>install node and npm</id>
            <phase>initialize</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>initialize</phase>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>install avrodoc</arguments>
              <workingDirectory>${project.basedir}/target/node</workingDirectory>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <nodeDownloadRoot>${node.downloadUrl}</nodeDownloadRoot>
          <npmDownloadRoot>${npm.downloadUrl}</npmDownloadRoot>
          <npmRegistryURL>${npm.registryUrl}</npmRegistryURL>
          <skip>${skip.avrodoc}</skip>
          <installDirectory>${project.basedir}/target</installDirectory>
        </configuration>
      </plugin>
      <!-- Generate avrodoc archive -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <id>generate avrodoc for all schemas</id>
            <phase>process-classes</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <skip>${skip.avrodoc}</skip>
              <target>
                <mkdir dir="${project.basedir}/target/avrodoc" />
                <fileset id="fileset" dir="${project.basedir}/target/generated-sources/avsc">
                  <include name="**/*.avsc" />
                </fileset>
                <pathconvert refid="fileset" property="converted" pathsep=" " dirsep="/">
                  <globmapper from="${project.basedir}${file.separator}target${file.separator}generated-sources${file.separator}avsc${file.separator}*" to="*" />
                </pathconvert>
                <exec executable="${project.basedir}/target/node/node" dir="${project.basedir}/target/generated-sources/avsc">
                  <arg value="${project.basedir}/target/node/node_modules/avrodoc/bin/avrodoc" />
                  <arg line="${converted}" />
                  <arg value="-o" /> 
                  <arg value="${project.basedir}/target/avrodoc/avrodoc.html" />
                </exec>
                <echoxml file="${project.basedir}/target/avrodoc/index.html">
                  <head>
                  <META http-equiv="refresh" content="0;URL=avrodoc.html" />
                  </head>
                </echoxml>
                <echoxml file="${project.basedir}/target/avrodoc/index.html" append="true">
                  <body>
                    <a href="avrodoc.html">Click here if auto redirect is not happening automatically</a>
                  </body>
                </echoxml>
                <zip destfile="${project.basedir}/target/avrodoc.jar">
                  <fileset dir="${project.basedir}/target/avrodoc" includes="avrodoc.html" />
                </zip>
              </target>
            </configuration>
          </execution>
          <execution>
            <phase>site</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <mkdir dir="target/site" />
                <copy file="target/avrodoc/avrodoc.html" todir="target/site" />
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>attach-avrodoc</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <skipAttach>${skip.avrodoc}</skipAttach>
               <artifacts>
                  <artifact>
                      <file>${project.basedir}/target/avrodoc.jar</file>
                      <type>jar</type>
                      <classifier>avrodoc</classifier>
                  </artifact>
               </artifacts>
            </configuration>
          </execution>
          <execution>
            <id>attach-avrodoc-html</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <skipAttach>${skip.avrodoc.html}</skipAttach>
               <artifacts>
                  <artifact>
                      <file>${project.basedir}/target/avrodoc.html</file>
                      <type>html</type>
                      <classifier>avrodoc</classifier>
                  </artifact>
               </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-scm-publish-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <phase>deploy</phase>
            <goals>
              <goal>publish-scm</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <checkoutDirectory>${scm-publish.checkoutDirectory}</checkoutDirectory>
          <checkinComment>Publishing Site Docs for ${project.artifactId}:${project.version}</checkinComment>
          <content>${project.basedir}/target/avrodoc</content>
          <skipDeletedFiles>true</skipDeletedFiles>
          <pubScmUrl>${scm-publish.pubScmUrl}</pubScmUrl>
          <scmBranch>${scm-publish.scmBranch}</scmBranch>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.apache.avro</groupId>
      <artifactId>avro</artifactId>
      <version>${avro.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.xerial.snappy</groupId>
          <artifactId>snappy-java</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-compress</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.thoughtworks.paranamer</groupId>
          <artifactId>paranamer</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.tukaani</groupId>
          <artifactId>xz</artifactId>
        </exclusion>
      </exclusions>      
    </dependency>
    <dependency> <!-- necessary for zolyfarkas/avro fork -->
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
      <version>3.0.2</version>
    </dependency>
  </dependencies>
</project>
