<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>ontolib-io</artifactId>
  <packaging>jar</packaging>

  <name>${project.groupId}:${project.artifactId}</name>
  <description>ontolib-io contains the generic I/O functionality for ontologies</description>
  <url>https://github.com/phenomics/ontolib</url>

  <parent>
    <groupId>com.github.phenomics</groupId>
    <artifactId>OntoLib</artifactId>
    <version>0.1</version>
  </parent>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <!-- Ontolib core -->
    <dependency>
      <groupId>com.github.phenomics</groupId>
      <artifactId>ontolib-core</artifactId>
      <version>${project.parent.version}</version>
    </dependency>

    <!-- Antlr4 runtime -->
    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>antlr4-runtime</artifactId>
      <version>${antlr4.version}</version>
    </dependency>

    <!-- Apache Commons I/O for testing -->
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons.io.version}</version>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <!--Use filtering so that maven will replace placeholders with values 
          from the pom e.g. ${project.version} -->
        <filtering>true</filtering>
      </resource>
    </resources>

    <plugins>
      <!-- Helps finding generated sources from Antlr4 -->
      <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/antlr4/</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Antlr4 generator -->
      <plugin>
        <groupId>org.antlr</groupId>
        <artifactId>antlr4-maven-plugin</artifactId>
        <version>${antlr4.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>antlr4</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Specify the dependencies to copy -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.8</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>false</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Specify the resources which need to be made accessible to the 
        user -->
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>validate</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/resources</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/resources</directory>
                  <!--Use filtering so that maven will replace placeholders 
                    with values from the pom e.g. ${project.version} -->
                  <filtering>true</filtering>
                  <includes>
                    <include>application.properties</include>
                    <include>example.settings</include>
                    <include>test.settings</include>
                    <include>log4j2.xml</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
