<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.jruby</groupId>
    <artifactId>jruby-artifacts</artifactId>
    <version>1.7.13</version>
  </parent>
  <artifactId>jruby-dist</artifactId>
  <packaging>pom</packaging>
  <name>JRuby Dist</name>
  <properties>
    <jruby.home>${basedir}/../..</jruby.home>
    <tesla.dump.readonly>true</tesla.dump.readonly>
    <main.basedir>${project.parent.parent.basedir}</main.basedir>
    <tesla.dump.pom>pom.xml</tesla.dump.pom>
  </properties>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack jruby-stdlib</id>
            <phase>process-classes</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <stripVersion>true</stripVersion>
              <artifactItems>
                <artifactItem>
                  <groupId>org.jruby</groupId>
                  <artifactId>jruby-stdlib-complete</artifactId>
                  <version>${project.version}</version>
                  <type>jar</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <tarLongFileMode>gnu</tarLongFileMode>
          <descriptors>
            <descriptor>src/main/assembly/jruby.xml</descriptor>
          </descriptors>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-invoker-plugin</artifactId>
        <executions>
          <execution>
            <id>integration-test</id>
            <goals>
              <goal>install</goal>
              <goal>run</goal>
            </goals>
            <configuration>
              <settingsFile>${basedir}/src/it/settings.xml</settingsFile>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <projectsDirectory>src/it</projectsDirectory>
          <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
          <preBuildHookScript>setup.bsh</preBuildHookScript>
          <postBuildHookScript>verify.bsh</postBuildHookScript>
          <streamLogs>true</streamLogs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>io.tesla.polyglot</groupId>
        <artifactId>tesla-polyglot-maven-plugin</artifactId>
        <version>0.0.8</version>
        <executions>
          <execution>
            <id>fix_executable_bits</id>
            <phase>process-classes</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <taskId>fix_executable_bits</taskId>
              <nativePom>pom.rb</nativePom>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>io.tesla.polyglot</groupId>
            <artifactId>tesla-polyglot-ruby</artifactId>
            <version>0.0.8</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>source dist</id>
      <activation>
        <file>
          <exists>../../.git</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>buildnumber-maven-plugin</artifactId>
            <version>1.2</version>
            <executions>
              <execution>
                <id>jruby-revision</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>create</goal>
                </goals>
                <configuration>
                  <shortRevisionLength>7</shortRevisionLength>
                  <buildNumberPropertyName>jruby.revision</buildNumberPropertyName>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>build source archive - tar</id>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <workingDirectory>${basedir}/../..</workingDirectory>
                  <arguments>
                    <argument>archive</argument>
                    <argument>--prefix</argument>
                    <argument>jruby-${project.version}/</argument>
                    <argument>--format</argument>
                    <argument>tar</argument>
                    <argument>${jruby.revision}</argument>
                    <argument>.</argument>
                    <argument>-o</argument>
                    <argument>${project.build.directory}/${project.artifactId}-${project.version}-src.tar</argument>
                  </arguments>
                  <executable>git</executable>
                </configuration>
              </execution>
              <execution>
                <id>gzip build source tar</id>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <workingDirectory>${basedir}/../..</workingDirectory>
                  <arguments>
                    <argument>${project.build.directory}/${project.artifactId}-${project.version}-src.tar</argument>
                    <argument>-f</argument>
                  </arguments>
                  <executable>gzip</executable>
                </configuration>
              </execution>
              <execution>
                <id>build source archive - zip</id>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <workingDirectory>${basedir}/../..</workingDirectory>
                  <arguments>
                    <argument>archive</argument>
                    <argument>--prefix</argument>
                    <argument>jruby-${project.version}/</argument>
                    <argument>-9</argument>
                    <argument>--format</argument>
                    <argument>zip</argument>
                    <argument>${jruby.revision}</argument>
                    <argument>.</argument>
                    <argument>-o</argument>
                    <argument>${project.build.directory}/${project.artifactId}-${project.version}-src.zip</argument>
                  </arguments>
                  <executable>git</executable>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
