<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>
    <groupId>org.torquebox</groupId>
    <artifactId>torquebox-build</artifactId>
    <version>2.1.2.redhat.1</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <modelVersion>4.0.0</modelVersion>

  <groupId>rubygems</groupId>
  <artifactId>torquebox-server</artifactId>
  <packaging>java-gem</packaging>
  <name>TorqueBox Server Gem</name>
  <description />
  <url>http://torquebox.org/</url>

  <dependencies>

    <dependency>
      <groupId>org.torquebox</groupId>
      <artifactId>torquebox-dist</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
    </dependency>

    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>torquebox</artifactId>
      <version>${project.version}</version>
      <type>gem</type>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>rspec</artifactId>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>rake</artifactId>
      <type>gem</type>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>rspec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>run-specs</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <fork>true</fork>
              <systemProperties>
                <property>
                  <name>log4j.configuration</name>
                  <value>test-log4j.xml</value>
                </property>
              </systemProperties>
            </configuration>
          </execution>
        </executions>
        </plugin>
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>gem-maven-plugin</artifactId>
        <configuration>
          <jrubyJvmArgs>-Xmx1024m</jrubyJvmArgs>
          <extraFiles>jboss/**/*,share/**/*</extraFiles>
        </configuration>
      </plugin>
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>jruby-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-jboss-and-share</id>
            <phase>process-sources</phase>
            <goals>
              <goal>jruby</goal>
            </goals>
            <configuration>
              <script>
                require 'fileutils'
                def cp( src, dest )
                  puts %Q(copying #{src} to #{dest})
                  FileUtils.mkdir_p( dest )
                  FileUtils.cp_r( src, dest )
                end
                cp( %Q(${basedir}/../assembly/target/stage/torquebox/jboss),
                    %Q(${basedir}/target/torquebox-server) )
                cp( %Q(${basedir}/../assembly/target/stage/torquebox/share),
                    %Q(${basedir}/target/torquebox-server) )
              </script>
            </configuration>
          </execution>
          <execution>
            <id>copy-gem</id>
            <inherited>true</inherited>
            <phase>install</phase>
            <goals>
              <goal>jruby</goal>
            </goals>
            <configuration>
              <script>
                basedir = '${project.basedir}'.gsub('\\', '/')
                load %Q(#{basedir}/../assembly/lib/assembly_tool.rb)
                ext = '.gem'
                ext = ( ( 'java-gem' == '${project.packaging}' ) ? '-java.gem' : '.gem' )
                safe_version = '${project.version}'.gsub(/-SNAPSHOT/, '')
                AssemblyTool.copy_gem_to_repo( %Q(#{basedir}/target/${project.artifactId}-#{safe_version}#{ext}) )
              </script>
              <jrubyJvmArgs>-Xmx1024m</jrubyJvmArgs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
