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

  <modelVersion>4.0.0</modelVersion>
  <artifactId>torquebox-modules-parent</artifactId>
  <packaging>pom</packaging>
  <name>TorqueBox Modules Parent</name>
  <description />

  <modules>
    <module>bootstrap</module>
    <module>core</module>
    <module>services</module>
    <module>web</module>
    <module>messaging</module>
    <module>jobs</module>

    <module>cdi</module>
    <module>security</module>
    <module>stomp</module>
  </modules>

  <dependencies>
    <dependency>
      <groupId>org.jboss.as</groupId>
      <artifactId>jboss-as-server</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>rubygems</groupId>
      <artifactId>rspec</artifactId>
      <type>gem</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.projectodd</groupId>
      <artifactId>polyglot-module-support</artifactId>
      <version>${version.polyglot}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.projectodd</groupId>
      <artifactId>polyglot-hasingleton</artifactId>
      <version>${version.polyglot}</version>
      <type>zip</type>
      <classifier>module</classifier>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.projectodd</groupId>
      <artifactId>polyglot-cache</artifactId>
      <version>${version.polyglot}</version>
      <type>zip</type>
      <classifier>module</classifier>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build> 
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>src/main/java</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*.rb</include>
          <include>**/*.properties</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/ruby</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
      <testResource>
        <directory>src/test/java</directory>
        <includes>
          <include>**/*.rb</include>
          <include>**/*.yml</include>
          <include>**/*.properties</include>
        </includes>
      </testResource>
    </testResources>
    <plugins> 
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemProperties>
            <property>
              <name>log4j.configuration</name>
              <value>test-log4j.xml</value>
            </property>
            <property>
              <name>test.version.torquebox</name>
              <value>${project.version}</value>
            </property>
            <property>
              <name>test.version.jbossas</name>
              <value>${version.jbossas}</value>
            </property>
            <property>
              <name>test.version.jruby</name>
              <value>${version.jruby}</value>
            </property>
            <property>
              <name>gem.path</name>
              <value>${project.basedir}/../target/rubygems</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>gem-maven-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <gemHome>${project.basedir}/../target/rubygems</gemHome>
          <gemPath>${project.basedir}/../target/rubygems</gemPath>
          <fork>true</fork>
        </configuration>
        <executions>
          <execution>
            <id>install-component-rubygem-dependencies</id>
            <phase>process-test-classes</phase>
            <goals>
              <goal>initialize</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>de.saumya.mojo</groupId>
        <artifactId>rspec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>run-specs</id>
            <configuration>
              <inherit>true</inherit>
              <gemHome>${project.basedir}/../target/rubygems</gemHome>
              <gemPath>${project.basedir}/../target/rubygems</gemPath>
            </configuration>
          </execution>
        </executions>
      </plugin> 
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>org.projectodd</groupId>
            <artifactId>polyglot-module-support</artifactId>
            <version>${version.polyglot}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>assemble-module</id>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <descriptorRefs>
                <descriptorRef>module</descriptorRef>
              </descriptorRefs>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
              <lifecycleMappingMetadata>
                <pluginExecutions>
                  <pluginExecution>
                    <pluginExecutionFilter>
                      <groupId>de.saumya.mojo</groupId>
                      <artifactId>gem-maven-plugin</artifactId>
                      <versionRange>
                        [0.28.4-SNAPSHOT,)
                      </versionRange>
                      <goals>
                        <goal>initialize</goal>
                      </goals>
                    </pluginExecutionFilter>
                    <action>
                      <ignore />
                    </action>
                  </pluginExecution>
                  <pluginExecution>
                    <pluginExecutionFilter>
                      <groupId>de.saumya.mojo</groupId>
                      <artifactId>jruby-maven-plugin</artifactId>
                      <versionRange>
                        [0.28.4-SNAPSHOT,)
                      </versionRange>
                      <goals>
                        <goal>jruby</goal>
                      </goals>
                    </pluginExecutionFilter>
                    <action>
                      <ignore />
                    </action>
                  </pluginExecution>
                </pluginExecutions>
              </lifecycleMappingMetadata>
            </configuration>
          </plugin>
        </plugins>
    </pluginManagement>
  </build> 

  <profiles>
    <profile>
      <id>assemblage-present</id>
      <activation>
        <file>
          <exists>../../build/assembly/target/stage/torquebox/jboss</exists>
        </file>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>de.saumya.mojo</groupId>
              <artifactId>jruby-maven-plugin</artifactId>
              <executions>
                <execution>
                  <id>install-module</id>
                  <inherited>true</inherited>
                  <phase>install</phase>
                  <goals>
                    <goal>jruby</goal>
                  </goals>
                  <configuration>
                    <script>
                      load '${project.basedir}/../../build/assembly/lib/assembly_tool.rb'
                      module_name = '${project.artifactId}'
                      module_name.gsub!(/torquebox-/, '' )
                      AssemblyTool.install_module( module_name, '${project.basedir}/target/${project.artifactId}-module' )
                    </script>
                  </configuration>
                </execution>
              </executions>
            </plugin>
         </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

</project>
