<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>org.kie.remote</groupId>
    <artifactId>kie-remote</artifactId>
    <version>6.2.0.Final</version>
  </parent>

  <artifactId>kie-remote-client</artifactId>
  <name>KIE Remote Services :: Client</name>

  <dependencies>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
    </dependency>

    <dependency>
      <groupId>org.kie.remote</groupId>
      <artifactId>kie-remote-jaxb</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie.remote</groupId>
      <artifactId>kie-remote-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-internal</artifactId>
    </dependency>

    <!-- REST -->
   <dependency>
      <groupId>org.jsoup</groupId>
      <artifactId>jsoup</artifactId>
    </dependency>
    
    <!-- JMS -->
    <dependency>
      <groupId>org.jboss.spec.javax.jms</groupId>
      <artifactId>jboss-jms-api_1.1_spec</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hornetq</groupId>
      <artifactId>hornetq-core-client</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hornetq</groupId>
      <artifactId>hornetq-jms-client</artifactId>
    </dependency>

    <!-- REST:       covered via java classes: see KieRemoteHttpRequest  -->
    <!-- jaxb/json:  covered via imports from kie-remote-jaxb -->
 
    <!-- webservices -->
    <dependency>
      <groupId>org.kie.remote.ws</groupId>
      <artifactId>kie-remote-ws-common</artifactId>
    </dependency>
   <dependency>
      <groupId>org.jboss.spec.javax.xml.ws</groupId>
      <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
    </dependency>
    
    <!--  webservices: cxf -->
   <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-api</artifactId>
   </dependency> 
   <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-simple</artifactId>
   </dependency> 
   <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http</artifactId>
   </dependency> 
   <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-databinding-jaxb</artifactId>
   </dependency> 
   <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
   </dependency>
   
    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

    <!-- TEST -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-bpmn2</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-bpmn2</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-persistence-jpa</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-kie-services</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>kie-ci</artifactId>
          <groupId>org.kie</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- serialization -->
    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-human-task-core</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.kie.remote</groupId>
      <artifactId>kie-remote-jaxb</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    <!-- reflection -->
    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- powermock -->
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-all</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.powermock</groupId>
      <artifactId>powermock-module-junit4</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.powermock</groupId>
      <artifactId>powermock-api-mockito</artifactId>
      <scope>test</scope>
    </dependency>
  
    <!-- for the live server test -->
    <dependency>
      <groupId>org.jboss</groupId>
      <artifactId>jboss-remote-naming</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.xnio</groupId>
      <artifactId>xnio-nio</artifactId>
      <scope>test</scope>
    </dependency>
    
    <!-- web services: api's --> 
    <dependency>
      <groupId>org.jboss.spec.javax.xml.bind</groupId>
      <artifactId>jboss-jaxb-api_2.2_spec</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.servlet</groupId>
      <artifactId>jboss-servlet-api_3.0_spec</artifactId>
      <scope>test</scope>
    </dependency>
      
    <!-- web services: classes --> 
    <dependency>
      <groupId>org.jboss.ws</groupId>
      <artifactId>jbossws-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.security</groupId>
      <artifactId>wss4j</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-ws-security</artifactId>
      <scope>test</scope>
    </dependency>
    
    <!-- web services: jetty --> 
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!--  generated: 0. delete all generated unpacked files because they are generated code and could change -->
      <!--  WSDL: 0. delete all generated files because only the WSDL determines code, no code in VCS -->
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <executions>
          <execution>
            <id>unpacked-generated-files</id>
            <configuration>
              <filesets>
                <fileset>
                  <directory>${basedir}/src/main/unpacked/org</directory>
                </fileset>
              </filesets>
            </configuration>
          </execution>
          <execution>
            <id>generated-wsdl-files</id>
            <configuration>
              <filesets>
                <fileset>
                  <directory>src/main/generated</directory>
                  <includes>
                    <include>**/*.java</include>
                  </includes>
                  <followSymlinks>false</followSymlinks>
                </fileset>
              </filesets>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- generated 1. add src/main/unpacked so that unpacked classes are added to jar -->
      <!-- WSDL: 1. add src/main/generated so that generated classes are added to jar -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-unpacked-sources</id>
            <phase>initialize</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/unpacked</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-generated-sources</id>
            <phase>initialize</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
             <configuration>
              <sources>
                <source>src/main/generated</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
      <!-- Importing generated classes -->
      
      <!-- 2. unpack flat command class sourc from kie-remote-jaxb-gen -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-cmd-sources</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.kie.remote</groupId>
                  <artifactId>kie-remote-jaxb-gen</artifactId>
                  <classifier>sources</classifier>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${basedir}/src/main/unpacked</outputDirectory>
                  <includes>**/*.java</includes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    
      <!-- Web Services -->
      
      <!-- 2. copy wsdl file to target/classes so that "VERSION" in wsdl file can be replaced with appropriate value, before compile -->
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-wsdl-to-target</id>
            <!-- here the phase you need -->
            <phase>process-sources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                <resources>
                    <resource>
                        <directory>src/main/resources/</directory>
                    </resource>
                </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- 3. replace "VERSION" in WSDL file with project version + bugfix version -->
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <goals>
              <goal>replace</goal>
            </goals>                    
          </execution>
        </executions>
        <configuration>
          <basedir>${project.build.directory}/classes/wsdl</basedir>
          <includes>
            <include>CommandService.wsdl</include>
          </includes>
          <regex>true</regex>
          <replacements>
            <replacement>
              <token>VERSION</token>
              <value>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}.${bugfix.version}</value>
            </replacement>
          </replacements>
        </configuration>
      </plugin>
      <!-- 4. generate classes based on WSDL to be included in jar -->
      <plugin>
        <groupId>org.jvnet.jax-ws-commons</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.3</version>
        <executions>
          <execution>
            <id>wsimport-from-jdk</id>
            <phase>process-resources</phase>
            <goals>
              <goal>wsimport</goal>
            </goals>
            <configuration>
              <executable>${tool.wsimport}</executable>
              <sourceDestDir>${project.basedir}/src/main/generated</sourceDestDir>
              <packageName>org.kie.remote.services.ws.command.generated</packageName>
              <target>2.1</target>
              <wsdlLocation>file:///wsdl/*</wsdlLocation>
              <wsdlDirectory>${project.build.directory}/classes/wsdl</wsdlDirectory>
              <wsdlFiles>
                <wsdlFile>CommandService.wsdl</wsdlFile>              
              </wsdlFiles>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <!-- setup corresponding executables on win/*nix -->
  <profiles>
    <profile>
      <id>win</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
      <properties>
        <tool.wsgen>${java.home}/../bin/wsgen.exe</tool.wsgen>
        <tool.wsimport>${java.home}/../bin/wsimport.exe</tool.wsimport>
      </properties>
    </profile>
    <profile>
      <id>nix</id>
      <activation>
        <os>
          <family>!windows</family>
        </os>
      </activation>
      <properties>
        <tool.wsgen>${java.home}/../bin/wsgen</tool.wsgen>
        <tool.wsimport>${java.home}/../bin/wsimport</tool.wsimport>
      </properties>
    </profile>
  </profiles>
</project>
