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

  <modelVersion>4.0.0</modelVersion>
  <artifactId>edi-schemas-edifact</artifactId>
  <packaging>jar</packaging>
  <name>Mule EDIFACT EDI Schemas</name>

  <parent>
    <groupId>org.mule.edi</groupId>
    <artifactId>edi</artifactId>
    <version>2.1.3</version>
    <relativePath>..</relativePath>
  </parent>

  <dependencies>
    <dependency>
      <groupId>org.mule.edi</groupId>
      <artifactId>edi-parser</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_${base.scala.version}</artifactId>
      <version>${scalatest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-compiler</artifactId>
      <version>${scala.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <goals>
              <goal>add-source</goal>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
          <execution>
            <id>build-edifact-schemas</id>
            <phase>prepare-package</phase>
            <configuration>
              <recompileMode>incremental</recompileMode>
              <source>${jdk.version}</source>
              <target>${jdk.version}</target>
              <launchers>
                <launcher>
                  <mainClass>com.mulesoft.flatfile.schema.convert.EdifactTablesConverter</mainClass>
                  <args>
                    <arg>${basedir}/src/main/build-resources/edifact</arg>
                    <!-- add generated schemas to the classes directory, both to simplify jar creation
                      and to have them included in the classpath when using this project in IDE. -->
                    <arg>${project.build.directory}/classes/edifact</arg>
                  </args>
                  <jvmArgs>
                    <jvmArg>-Xms256m</jvmArg>
                    <jvmArg>-Xmx256m</jvmArg>
                  </jvmArgs>
                </launcher>
              </launchers>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>remove-converter-code</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>clean</goal>
            </goals>
            <configuration>
              <excludeDefaultDirectories>true</excludeDefaultDirectories>
              <filesets>
                <fileset>
                  <directory>${project.build.directory}/classes/com/mulesoft/flatfile/schema/convert</directory>
                </fileset>
              </filesets>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest-maven-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
          <junitxml>.</junitxml>
          <filereports>schema-tests.txt</filereports>
        </configuration>
        <executions>
          <execution>
            <id>test</id>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <excludes>
            <exclude>**/com/mulesoft/flatfile/schema/convert</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
          <shadedArtifactAttached>true</shadedArtifactAttached>
          <shadedClassifierName>doctest</shadedClassifierName>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <mainClass>com.mulesoft.flatfile.schema.test.TestEdifactDocument</mainClass>
            </transformer>
          </transformers>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
