<?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">

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.drools</groupId>
    <artifactId>guvnor</artifactId>
    <version>5.6.0.Final</version>
  </parent>

  <!--
    TODO Make this module obsolete by providing the functionality in a screen in Guvnor
    https://issues.jboss.org/browse/GUVNOR-1230
  -->
  <artifactId>guvnor-bulk-importer</artifactId>
  <name>Guvnor bulk importer</name>
  <description>Bulk imports files into the Guvnor repository</description>

  <properties>
    <guvnor.server.url>http://localhost:8080/guvnor-${guvnor.version}</guvnor.server.url>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>org.jboss.drools.guvnor.importgenerator.ImportFileGenerator</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>fullProfile</id>
      <activation>
        <property>
          <name>full</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>attached</goal>
                </goals>
                <configuration>
                  <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                  </descriptorRefs>
                  <archive>
                    <manifest>
                      <mainClass>org.jboss.drools.guvnor.importgenerator.ImportFileGenerator</mainClass>
                    </manifest>
                  </archive>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>gen-brms-import</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <!--plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>obtain-domain-model-jar</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.jboss.drools.guvnor.tools.example</groupId>
                      <artifactId>example-domain</artifactId>
                      <version>1.0.0-SNAPSHOT</version>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin-->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>

            <executions>
              <execution>
                <phase>package</phase> <!-- after compile since we need the class to be on the cp before executing -->
                <goals>
                  <goal>java</goal>
                </goals>
              </execution>
            </executions>

            <configuration>
              <mainClass>org.jboss.drools.guvnor.importgenerator.ImportFileGenerator</mainClass>
              <arguments>
                <argument>-classpath</argument> <!--  bring in the project classpath dependencies below -->

                <argument>-p</argument>
                <argument>${basedir}/my_rules</argument> <!--  directory to start importing from -->

                <argument>-s</argument>
                <argument>my_rules</argument> <!--  directory to start importing from -->

                <argument>-e</argument>
                <argument>[0-9|.]*[.|-]+[SNAPSHOT]+[.|-]*[09|.]*</argument> <!--  matches the version directory if it exists -->

                <argument>-r</argument>
                <argument>true</argument> <!--  recurse sub-directories when looking for rules files -->

                <argument>-u</argument>
                <argument>admin</argument> <!--  user account name to import the rules files as -->

                <argument>-f</argument>
                <argument>drl,xls</argument> <!--  rule file extension to import -->

                <argument>-o</argument>
                <argument>guvnor-import.xml</argument> <!--  import file generated -->

                <argument>-c</argument>
                <argument>functions.drl</argument> <!--  functions file to look for -->

                <argument>-n</argument>
                <argument>1.0.0-SNAPSHOT</argument> <!--  default snapshot name -->

                <argument>-k</argument>
                <argument>${guvnor.server.url}/org.drools.guvnor.Guvnor/package/</argument> <!--  kagent brms server -->

                <argument>-b</argument>
                <argument>${basedir}</argument>

                <!-- optional argument to generate a kagent change-set file -->
                <argument>-w</argument>
                <argument>kagent-changeset.xml</argument> <!--  kagent changeset file output -->

                <!-- optional argument that will add this model to every package -->
                <!--argument>-m</argument>
                <argument>${project.build.directory}/example-domain-1.0.0-SNAPSHOT.jar</argument-->

                <argument>-V</argument> <!--  verbose output (v=verbose, V=very verbose -->
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>guvnor-repository</artifactId>
    </dependency>

    <!-- for RuleAgent testing -->
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-compiler</artifactId>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-decisiontables</artifactId>
    </dependency>
    <!-- end RuleAgent testing dependencies -->

    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>1.7.0</version>
    </dependency>
    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>1.6</version>
    </dependency>
    <!--dependency>
      <groupId>org.jboss.drools.guvnor.tools.example</groupId>
      <artifactId>example-domain</artifactId>
      <version>1.0.0-SNAPSHOT</version>
    </dependency-->
    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>
  </dependencies>
</project>
