<?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/maven-v4_0_0.xsd">
  <parent>
    <artifactId>cucumber-jvm</artifactId>
    <groupId>info.cukes</groupId>
    <version>1.1.2</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>cucumber-jruby</artifactId>
  <name>Cucumber-JVM: JRuby</name>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>lib</directory>
              <includes>
                <include>**/*.*</include>
              </includes>
            </fileset>
            <fileset>
              <directory>.</directory>
              <includes>
                <include>*.gem</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-i18n-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <taskdef />
                <groovy>def template = """\
module Cucumber
  module Runtime
    module JRuby
      module Dsl
&lt;% i18n.codeKeywords.each { kw -&gt; %&gt;
        def \${java.text.Normalizer.normalize(kw, java.text.Normalizer.Form.NFD)}(regexp, &amp;proc)
          register_stepdef(regexp, proc)
        end
&lt;% } %&gt;
      end
    end
  end
end
"""

gherkin.I18n.all.each { i18n -&gt;
    def engine = new groovy.text.SimpleTemplateEngine()
    def binding = ["i18n":i18n]
    def source = engine.createTemplate(template).make(binding).toString()

    def file = new File(project.baseDir, "target${File.separator}generated-resources${File.separator}i18n${File.separator}cucumber${File.separator}api${File.separator}jruby${File.separator}${i18n.underscoredIsoCode}.rb")
    file.parentFile.mkdirs()
    file.write(source, "UTF-8")
}</groovy>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>package-gem</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy />
                <echo />
                <java>
                  <sysproperty />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                </java>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>jruby-cli-test</id>
            <phase>integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo />
                <java>
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                </java>
              </target>
            </configuration>
          </execution>
          <execution>
            <id>deploy-gem</id>
            <phase>deploy</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo />
                <java>
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                </java>
                <echo />
                <java>
                  <env />
                  <arg />
                  <arg />
                  <arg />
                  <arg />
                </java>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-resource</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>add-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${basedir}/target/generated-resources/i18n</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-jvm-deps</artifactId>
      <version>1.0.3</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>xstream</artifactId>
          <groupId>com.thoughtworks.xstream</groupId>
        </exclusion>
        <exclusion>
          <artifactId>diffutils</artifactId>
          <groupId>com.googlecode.java-diff-utils</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>gherkin</artifactId>
      <version>2.11.6</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.jruby</groupId>
      <artifactId>jruby-complete</artifactId>
      <version>1.7.2</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-junit</artifactId>
      <version>1.1.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>hamcrest-core</artifactId>
          <groupId>org.hamcrest</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>net.sourceforge.cobertura</groupId>
      <artifactId>cobertura</artifactId>
      <version>1.9.4.1</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>oro</artifactId>
          <groupId>oro</groupId>
        </exclusion>
        <exclusion>
          <artifactId>asm</artifactId>
          <groupId>asm</groupId>
        </exclusion>
        <exclusion>
          <artifactId>asm-tree</artifactId>
          <groupId>asm</groupId>
        </exclusion>
        <exclusion>
          <artifactId>log4j</artifactId>
          <groupId>log4j</groupId>
        </exclusion>
        <exclusion>
          <artifactId>ant</artifactId>
          <groupId>org.apache.ant</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</project>

