<?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">
    <parent>
        <groupId>org.campagnelab.goby</groupId>
        <artifactId>goby-framework</artifactId>
        <version>3.3.1</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>goby-io</artifactId>
    <name>Goby I/O</name>
    <description>I/O core of the Goby Framework</description>
    <url>http://goby.campagnelab.org</url>

    <properties>
        <protobuf.input.directory>${project.basedir}/protobuf</protobuf.input.directory>
        <protobuf.output.directory>${project.build.directory}/generated-sources</protobuf.output.directory>
        <os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>
        <maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
        <maven-dependency-plugin.version>2.10</maven-dependency-plugin.version>
        <protobuf.input.filepaths.path>Alignments.proto Reads.proto BaseInformationRecords.proto</protobuf.input.filepaths.path>
</properties>

    <build>
        <sourceDirectory>${basedir}/../goby-distribution/src/main/java</sourceDirectory>
        <extensions>
            <!-- provides os.detected.classifier (i.e. linux-x86_64, osx-x86_64) property -->
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>${os-maven-plugin.version}</version>
            </extension>
        </extensions>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/GOBY_COMMIT.properties.skeleton</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/GOBY_COMMIT.properties.skeleton</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-verifier-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <verificationFile>verifications.xml</verificationFile>
                </configuration>
                <executions>
                    <execution>
                        <id>main</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>2.2.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>validate-the-git-infos</id>
                        <goals>
                            <goal>validateRevision</goal>
                        </goals>
                        <phase>compile</phase>
                    </execution>
                </executions>

                <configuration>
                    <failOnNoGitDirectory>true</failOnNoGitDirectory>
                    <commitIdGenerationMode>flat</commitIdGenerationMode>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <generateGitPropertiesFile>false</generateGitPropertiesFile>
                    <gitDescribe>
                        <skip>true</skip>
                    </gitDescribe>
                </configuration>
            </plugin><!-- copy protoc binary into build directory -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven-dependency-plugin.version}</version>
                <executions>
                    <execution>
                        <id>copy-protoc</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.google.protobuf</groupId>
                                    <artifactId>protoc</artifactId>
                                    <version>${protobuf.version}</version>
                                    <classifier>${os.detected.classifier}</classifier>
                                    <type>exe</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-protoc-python</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.google.protobuf</groupId>
                                    <artifactId>protoc</artifactId>
                                    <version>${protobuf.python.version}</version>
                                    <classifier>${os.detected.classifier}</classifier>
                                    <type>exe</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- compile proto buffer files using copied protoc binary -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>${maven-antrun-plugin.version}</version>
                <executions>
                    <execution>
                        <id>exec-java-protoc</id>
                        <phase>generate-sources</phase>
                        <configuration>

                            <target>
                                <chmod file="${project.build.directory}/protoc-${protobuf.version}-${os.detected.classifier}.exe"
                                       perm="ugo+rx"/>
                                <mkdir dir="${protobuf.output.directory}"/>
                                <path id="protobuf.input.filepaths.path">
                                    <fileset dir="${protobuf.input.directory}">
                                        <include name="*.proto"/>
                                    </fileset>
                                </path>
                                <pathconvert pathsep=" " property="protobuf.input.filepaths"
                                             refid="protobuf.input.filepaths.path"/>
                                <exec executable="${project.build.directory}/protoc-${protobuf.version}-${os.detected.classifier}.exe"
                                      failonerror="true">
                                    <arg value="-I"/>
                                    <arg value="${protobuf.input.directory}"/>
                                    <arg value="--java_out"/>
                                    <arg value="${protobuf.output.directory}"/>
                                    <arg line="${protobuf.input.filepaths}"/>
                                </exec>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <!-- compile proto buffer files to python  -->
                    <execution>
                        <id>exec-python-protoc</id>
                        <phase>generate-sources</phase>
                        <configuration>

                            <target>
                                <chmod file="${project.build.directory}/protoc-${protobuf.python.version}-${os.detected.classifier}.exe"
                                       perm="ugo+rx"/>
                                <mkdir dir="${protobuf.output.directory}"/>
                                <path id="protobuf.input.filepaths.path">
                                    <fileset dir="${protobuf.input.directory}">
                                        <include name="*.proto"/>
                                    </fileset>
                                </path>
                                <pathconvert pathsep=" " property="protobuf.input.filepaths"
                                             refid="protobuf.input.filepaths.path"/>
                                <exec executable="${project.build.directory}/protoc-${protobuf.python.version}-${os.detected.classifier}.exe"
                                      failonerror="true">
                                    <arg value="-I"/>
                                    <arg value="${protobuf.input.directory}"/>
                                    <arg value="--python_out"/>
                                    <arg value="../python/goby"/>
                                    <arg line="${protobuf.input.filepaths}"/>
                                </exec>
                            </target>

                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>

                    <!-- compile proto buffer files to cpp for python  -->
                    <execution>
                        <id>exec-python-cpp-protoc</id>
                        <phase>generate-sources</phase>
                        <configuration>

                            <target>
                                <chmod file="${project.build.directory}/protoc-${protobuf.python.version}-${os.detected.classifier}.exe"
                                       perm="ugo+rx"/>
                                <mkdir dir="${protobuf.output.directory}"/>
                                <path id="protobuf.input.filepaths.path">
                                    <fileset dir="${protobuf.input.directory}">
                                        <include name="*.proto"/>
                                    </fileset>
                                </path>
                                <pathconvert pathsep=" " property="protobuf.input.filepaths"
                                             refid="protobuf.input.filepaths.path"/>
                                <exec executable="${project.build.directory}/protoc-${protobuf.python.version}-${os.detected.classifier}.exe"
                                      failonerror="true">
                                    <arg value="-I"/>
                                    <arg value="${protobuf.input.directory}"/>
                                    <arg value="--cpp_out"/>
                                    <arg value="../python/cpp"/>
                                    <arg line="${protobuf.input.filepaths}"/>
                                </exec>
                            </target>

                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>

                </executions>
            </plugin>


            <!-- add generated proto buffer classes into the package -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build-helper-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>add-classes</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${protobuf.output.directory}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- do not use another version, see http://stackoverflow.com/questions/11051620/compiling-only-selected-files-in-maven-->
                <version>2.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>

                    <excludes>
                        <exclude>**/*.html</exclude>
                        <exclude>**/*.jsap</exclude>
                    </excludes>
                    <includes>
                        <include>org/campagnelab/goby/algorithmic/algorithm/EquivalentIndelRegionCalculator**</include>
                        <include>org/campagnelab/goby/algorithmic/compression/**</include>
                        <include>org/campagnelab/goby/algorithmic/dsv/**</include>
                        <include>org/campagnelab/goby/algorithmic/indels/**</include>
                        <include>org/campagnelab/goby/compression/**</include>
                        <include>org/campagnelab/goby/reads/**</include>
                        <include>org/campagnelab/goby/readers/**</include>
                        <include>org/campagnelab/goby/alignments/**</include>
                        <include>org/campagnelab/goby/baseinfo/**</include>
                        <include>org/campagnelab/goby/counts/**</include>
                        <include>org/campagnelab/goby/GobyVersion*</include>
                        <include>org/campagnelab/goby/exception/**</include>
                        <include>org/campagnelab/goby/modes/core/**</include>
                        <include>org/campagnelab/goby/util/**</include>
                        <include>org/campagnelab/goby/parsers/**</include>
                        <include>org/campagnelab/goby/predictions/**</include>
                        <include>org/campagnelab/goby/util/Variant*</include>
                        <include>org/campagnelab/dl/varanalysis/protobuf/**</include>
                    </includes>

                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <includes>
                        <include>org/campagnelab/goby/algorithmic/compression/**</include>
                        <include>org/campagnelab/goby/algorithmic/dsv/**</include>
                        <include>org/campagnelab/goby/algorithmic/indels/**</include>
                        <include>org/campagnelab/goby/compression/**</include>
                        <include>org/campagnelab/goby/reads/**</include>
                        <include>org/campagnelab/goby/readers/**</include>
                        <include>org/campagnelab/goby/alignments/**</include>
                        <include>org/campagnelab/goby/baseinfo/**</include>
                        <include>org/campagnelab/goby/counts/**</include>
                        <include>org/campagnelab/goby/GobyVersion*</include>
                        <include>org/campagnelab/goby/exception/**</include>
                        <include>org/campagnelab/goby/modes/core/**</include>
                        <include>org/campagnelab/goby/util/**</include>
                        <include>org/campagnelab/goby/parsers/**</include>
                        <include>org/campagnelab/goby/predictions/**</include>
                        <include>org/campagnelab/dl/varanalysis/protobuf/**</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.4</version>
                <configuration>
                    <includes>
                        <include>org/campagnelab/goby/algorithmic/compression/**</include>
                        <include>org/campagnelab/goby/algorithmic/dsv/**</include>
                        <include>org/campagnelab/goby/algorithmic/indels/**</include>
                        <include>org/campagnelab/goby/compression/**</include>
                        <include>org/campagnelab/goby/reads/**</include>
                        <include>org/campagnelab/goby/readers/**</include>
                        <include>org/campagnelab/goby/alignments/**</include>
                        <include>org/campagnelab/goby/baseinfo/**</include>
                        <include>org/campagnelab/goby/counts/**</include>
                        <include>org/campagnelab/goby/GobyVersion*</include>
                        <include>org/campagnelab/goby/exception/**</include>
                        <include>org/campagnelab/goby/modes/core/**</include>
                        <include>org/campagnelab/goby/util/**</include>
                        <include>org/campagnelab/goby/parsers/**</include>
                        <include>org/campagnelab/goby/predictions/**</include>
                        <include>org/campagnelab/dl/varanalysis/protobuf/**</include>
                    </includes>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <additionalparam>-Xdoclint:none</additionalparam>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <configuration>
                            <tasks>
                                <copy file="${project.build.outputDirectory}/GOBY_COMMIT.properties.skeleton"
                                      toFile="${project.basedir}/../GOBY_COMMIT.properties" overwrite="true" />

                                <copy file="${project.build.outputDirectory}/GOBY_COMMIT.properties.skeleton"
                                      toFile="${project.basedir}/target/classes/GOBY_COMMIT.properties" overwrite="true" />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>


 <dependencies>

     <dependency>
         <groupId>com.google.protobuf</groupId>
         <artifactId>protobuf-java</artifactId>
         <version>${protobuf.version}</version>
     </dependency>

     <dependency>
         <groupId>it.unimi.dsi</groupId>
         <artifactId>fastutil</artifactId>
         <version>7.0.12</version>
     </dependency>

     <dependency>
         <groupId>org.campagnelab.icb</groupId>
         <artifactId>icb-utils</artifactId>
         <version>2.0.1</version>
     </dependency>

     <dependency>
         <groupId>org.slf4j</groupId>
         <artifactId>slf4j-api</artifactId>
         <version>1.7.21</version>
     </dependency>

     <dependency>
         <groupId>it.unimi.dsi</groupId>
         <artifactId>dsiutils</artifactId>
         <version>2.3.3</version>
         <exclusions>
             <exclusion>
                 <groupId>com.google.guava</groupId>
                 <artifactId>*</artifactId>
             </exclusion>
         </exclusions>
     </dependency>

     <dependency>
         <groupId>com.github.samtools</groupId>
         <artifactId>htsjdk</artifactId>
         <version>2.8.1</version>
     </dependency>

     <dependency>
         <groupId>com.google.protobuf</groupId>
         <artifactId>protobuf-java</artifactId>
         <version>${protobuf.version}</version>
     </dependency>


     <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-math</artifactId>
         <version>2.2</version>
     </dependency>

     <dependency>
         <groupId>org.reflections</groupId>
         <artifactId>reflections</artifactId>
         <version>0.9.10</version>
         <exclusions>
             <exclusion>
                 <groupId>org.slf4j</groupId>
                 <artifactId>*</artifactId>
             </exclusion>
         </exclusions>
     </dependency>

     <dependency>
         <groupId>com.github.lucarosellini.rJava</groupId>
         <artifactId>JRI</artifactId>
         <version>0.9-7</version>
     </dependency>

 </dependencies>

</project>