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

    <parent>
        <groupId>com.darrinholst</groupId>
        <artifactId>sass-java-parent</artifactId>
        <version>3.4.20.0</version>
    </parent>

    <artifactId>sass-java-gems</artifactId>
    <version>3.4.20.0</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.3.2</version>
                <executions>
                    <execution>
                        <id>install-bundler</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath><dependency>org.jruby:jruby-complete</dependency></classpath>
                                <argument>org.jruby.Main</argument>
                                <argument>-S</argument>
                                <argument>gem</argument>
                                <argument>install</argument>
                                <argument>-i</argument>
                                <argument>${project.build.directory}/bundler</argument>
                                <argument>bundler</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>bundle-install</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <environmentVariables>
                                <GEM_HOME>${project.build.directory}/bundler</GEM_HOME>
                            </environmentVariables>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath><dependency>org.jruby:jruby-complete</dependency></classpath>
                                <argument>org.jruby.Main</argument>
                                <argument>-S</argument>
                                <argument>${project.build.directory}/bundler/bin/bundle</argument>
                                <argument>install</argument>
                                <argument>--gemfile</argument>
                                <argument>${basedir}/Gemfile</argument>
                                <argument>--path</argument>
                                <argument>${project.build.directory}/bundle</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>jar-it-up</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>jar</executable>
                            <arguments>
                                <argument>cf</argument>
                                <argument>${project.build.directory}/${project.name}-${project.version}.jar</argument>
                                <argument>-C</argument>
                                <argument>${project.build.directory}/bundle/jruby/1.9</argument>
                                <argument>.</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.17</version>
                <executions>
                    <execution>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.build.directory}/${project.name}-${project.version}.jar</additionalClasspathElement>
                            </additionalClasspathElements>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
