<?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 -->
  <parent>
    <groupId>org.jboss</groupId>
    <artifactId>jboss-parent</artifactId>
    <version>35</version>
    <relativePath />
  </parent>

  <!-- Model Version -->
  <modelVersion>4.0.0</modelVersion>

  <!-- Artifact Configuration -->
  <groupId>org.jboss.arquillian.extension</groupId>
  <artifactId>arquillian-extension-byteman</artifactId>
  <name>Arquillian Extension Byteman</name>
  <description>Byteman integration for the Arquillian project</description>
  <version>1.1.0</version>

  <scm>
    <connection>scm:git:git://git@github.com:arquillian/arquillian-extension-byteman.git</connection>
    <developerConnection>scm:git:ssh://github.com/arquillian/arquillian-extension-byteman.git</developerConnection>
    <url>git://github.com/arquillian/arquillian-extension-byteman.git</url>
    <tag>1.1.0</tag>
  </scm>

  <!-- Properties -->
  <properties>
    <!-- Versioning -->
    <version.arquillian_core>1.4.1.Final</version.arquillian_core>
    <version.arquillian_chameleon>1.0.0.CR6</version.arquillian_chameleon>
    <version.javaee_spec>1.1.1.Final</version.javaee_spec>
    <version.byteman>4.0.7</version.byteman>
    <version.jarjar>1.9</version.jarjar>
    <version.xalan>2.7.2</version.xalan>
    <surefire.argline />
    <arq.server.jvm.args.debug />
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <version>${version.arquillian_core}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-build</artifactId>
        <version>${version.arquillian_core}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-7.0</artifactId>
        <version>${version.javaee_spec}</version>
        <type>pom</type>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>${version.xalan}</version>
      </dependency>
    </dependencies>
  </dependencyManagement>


  <!-- Dependencies -->
  <dependencies>

    <!-- org.jboss.arquillian -->
    <dependency>
      <groupId>org.jboss.arquillian.core</groupId>
      <artifactId>arquillian-core-spi</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-container-spi</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-container-test-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.arquillian.container</groupId>
      <artifactId>arquillian-container-test-spi</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.shrinkwrap</groupId>
      <artifactId>shrinkwrap-impl-base</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.shrinkwrap</groupId>
      <artifactId>shrinkwrap-spi</artifactId>
    </dependency>

    <!-- org.jboss.byteman -->

    <dependency>
      <groupId>org.jboss.byteman</groupId>
      <artifactId>byteman</artifactId>
      <version>${version.byteman}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.byteman</groupId>
      <artifactId>byteman-submit</artifactId>
      <version>${version.byteman}</version>
      <scope>provided</scope>
    </dependency>

    <!-- Test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.arquillian.container</groupId>
      <artifactId>arquillian-container-chameleon</artifactId>
      <version>${version.arquillian_chameleon}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-7.0</artifactId>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
        </testResource>
    </testResources>
  
    <plugins>
      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>
          <pushChanges>false</pushChanges>
          <localCheckout>true</localCheckout>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>${surefire.argline}</argLine>
          <systemProperties>
            <arq.server.jvm.args.byteman>${byteman.agent.support}</arq.server.jvm.args.byteman>
            <arq.server.jvm.args.debug>${arq.server.jvm.args.debug}</arq.server.jvm.args.debug>
          </systemProperties>
          <runOrder>alphabetical</runOrder>
          <excludes>
            <exclude>%regex[.*local.*]</exclude>
          </excludes>
        </configuration>
      </plugin>
      <!-- We need to jarjar this, since WildFly grabs all org.jboss.byteman as system packages -->
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>jarjar-maven-plugin</artifactId>
        <version>${version.jarjar}</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>jarjar</goal>
            </goals>
            <configuration>
              <includes>
                <include>org.jboss.byteman:byteman-submit</include>
              </includes>
              <rules>
                <rule>
                  <pattern>org.jboss.byteman.agent.submit.**</pattern>
                  <result>org.jboss.arquillian.extension.byteman.agent.submit.@1</result>
                </rule>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
      <!-- three Byteman-related profiles for configuring use of Byteman on different platforms/JDKs-->
      <profile>
          <id>use-toolsjar-jigsaw</id>
          <activation>
              <jdk>[1.9,)</jdk>
          </activation>
          <properties>
              <!-- required for VM attach under JDK 9-->
              <surefire.argline>-Djdk.attach.allowAttachSelf=true</surefire.argline>
              <byteman.agent.support>-Djboss.modules.system.pkgs=com.sun.tools.attach,org.jboss.byteman -Djdk.attach.allowAttachSelf=true</byteman.agent.support>
          </properties>
          <dependencies />
      </profile>

      <profile>
          <id>use-toolsjar-default</id>
          <activation>
              <file>
                  <exists>${java.home}/../lib/tools.jar</exists>
              </file>
          </activation>
          <properties>
              <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
              <byteman.agent.support>-Djboss.modules.system.pkgs=com.sun.tools.attach,org.jboss.byteman -Xbootclasspath/a:${tools.jar}</byteman.agent.support>
          </properties>
          <dependencies>
              <dependency>
                  <groupId>com.sun</groupId>
                  <artifactId>tools</artifactId>
                  <version>1.8</version>
                  <scope>system</scope>
                  <systemPath>${tools.jar}</systemPath>
              </dependency>
          </dependencies>
      </profile>

      <profile>
          <id>use-toolsjar-osx</id>
          <activation>
              <file>
                  <exists>${java.home}/../Classes/classes.jar</exists>
              </file>
          </activation>
          <properties>
              <tools.jar>${java.home}/../Classes/classes.jar</tools.jar>
              <byteman.agent.support>-Djboss.modules.system.pkgs=com.sun.tools.attach,org.jboss.byteman -Xbootclasspath/a:${tools.jar}</byteman.agent.support>
          </properties>
          <dependencies>
              <dependency>
                  <groupId>com.sun</groupId>
                  <artifactId>tools</artifactId>
                  <version>1.8</version>
                  <scope>system</scope>
                  <systemPath>${tools.jar}</systemPath>
              </dependency>
          </dependencies>
      </profile>

       <profile>
         <id>debug</id>
         <activation>
           <property>
             <name>debug</name>
           </property>
         </activation>
         <properties>
           <arq.server.jvm.args.debug>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</arq.server.jvm.args.debug>
         </properties>
       </profile>
  </profiles>
</project>

