<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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</groupId>
    <artifactId>business-central-distribution-wars</artifactId>
    <version>7.65.0.Final</version>
  </parent>

  <artifactId>business-central</artifactId>
  <packaging>pom</packaging>

  <name>Business Central - Distribution Wars</name>

  <properties>
    <org.kie.swagger.url>../rest/swagger.json</org.kie.swagger.url>
    <org.kie.swagger.title>Business Central Documentation</org.kie.swagger.title>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>business-central-webapp</artifactId>
      <type>war</type>
    </dependency>

    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-swagger-ui</artifactId>
    </dependency>

    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
    </dependency>

    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <dependency>
      <groupId>org.mariadb.jdbc</groupId>
      <artifactId>mariadb-java-client</artifactId>
    </dependency>

    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>business-central-webapp</artifactId>
      <classifier>standalone</classifier>
      <exclusions>
        <exclusion>
          <groupId>org.yaml</groupId>
          <artifactId>snakeyaml</artifactId>
        </exclusion>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis-ext</artifactId>
       </exclusion>
       <exclusion>
          <groupId>org.jboss.modules</groupId>
          <artifactId>jboss-modules</artifactId>
        </exclusion>	       
      </exclusions>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>notProductizedProfile</id>
      <activation>
        <property>
          <name>!productized</name>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>get-wildfly-dist</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.wildfly</groupId>
                      <artifactId>wildfly-dist</artifactId>
                      <version>${version.org.wildfly}</version>
                      <type>zip</type>
                      <outputDirectory>${project.build.directory}</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                  <overWriteSnapshots>true</overWriteSnapshots>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>${project.parent.basedir}/src/main/community/assembly-kie-wb-wildfly.xml</descriptor>
                    <descriptor>${project.parent.basedir}/src/main/community/assembly-kie-wb-wildfly.zip.xml</descriptor>
                  </descriptors>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>productizedProfile</id>
      <activation>
        <property>
          <name>productized</name>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>get-webapp-standalone</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.kie</groupId>
                      <artifactId>${project.artifactId}-webapp</artifactId>
                      <version>${project.version}</version>
                      <classifier>standalone</classifier>
                      <outputDirectory>${project.build.directory}/${project.artifactId}-webapp</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>${project.parent.basedir}/src/main/productized/assembly-kie-wb-eap-7-redhat.xml</descriptor>
                    <descriptor>${project.parent.basedir}/src/main/productized/assembly-kie-wb-standalone-redhat.xml</descriptor>
                    <descriptor>${project.parent.basedir}/src/main/productized/assembly-kie-wb-standalone-zip-redhat.xml</descriptor>
                  </descriptors>
                  <archive>
                    <manifestFile>${project.build.directory}/${project.artifactId}-webapp/META-INF/MANIFEST.MF</manifestFile>
                  </archive>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
