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

  <name>Flowable - REST - APP</name>
  <artifactId>flowable-app-rest</artifactId>
  <packaging>war</packaging>

  <parent>
    <groupId>org.flowable</groupId>
    <artifactId>flowable-spring-boot</artifactId>
    <relativePath>../flowable-spring-boot/pom.xml</relativePath>
    <version>6.5.0.1-SNAPSHOT</version>
  </parent>

  <properties>
    <!--<swagger.host>localhost:8080</swagger.host>-->
    <swagger.generated.directory>target/generated-swagger</swagger.generated.directory>
  </properties>

  <build>
    <finalName>flowable-rest</finalName>

    <plugins>
      <plugin>
	    <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
		<configuration>
		  <port>8080</port>
		  <path>/flowable-rest</path>
          <warDirectory>${project.build.directory}/${project.build.finalName}</warDirectory>
          <systemProperties>
		    <com.sun.management.jmxremote.port>4000</com.sun.management.jmxremote.port>
          </systemProperties>
		</configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <filesets>
            <fileset>
              <directory>src/main/resources/static/docs/specfile</directory>.
              <includes>
                <include>**</include>
              </includes>
              <followSymlinks>false</followSymlinks>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <excludeArtifactIds>
            spring-boot-configuration-processor
          </excludeArtifactIds>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                	<pluginExecutionFilter>
                		<groupId>com.github.kongchen</groupId>
                		<artifactId>swagger-maven-plugin</artifactId>
                		<versionRange>[3.1.5,)</versionRange>
                		<goals>
                			<goal>generate</goal>
                		</goals>
                	</pluginExecutionFilter>
                	<action>
                		<ignore></ignore>
                	</action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
	  <id>buildExecutableWar</id>
	    <build>
		  <plugins>
            <plugin>
              <groupId>org.apache.tomcat.maven</groupId>
			  <artifactId>tomcat7-maven-plugin</artifactId>
			  <version>2.2</version>
			  <configuration>
			    <path>/</path>
			  </configuration>
			  <executions>
			    <execution>
				  <id>tomcat-run</id>
				  <goals>
				    <goal>exec-war-only</goal>
				  </goals>
				  <phase>package</phase>
				  <configuration>
                    <path>/flowable-rest</path>
                  </configuration>
				</execution>
			  </executions>
			</plugin>
		  </plugins>
	  </build>
    </profile>
    <profile>
      <id>swagger</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>3.1.6</version>
            <configuration>
              <apiSources>
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/service</basePath>
                  <info>
                    <title>Flowable REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/process</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- IDM -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.idm.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/idm-api</basePath>
                  <info>
                    <title>Flowable IDM REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/idm</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- DMN -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.dmn.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/dmn-api</basePath>
                  <info>
                    <title>Flowable DMN REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/dmn</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- FORM -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.form.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/form-api</basePath>
                  <info>
                    <title>Flowable FORM REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/form</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- CONTENT -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.content.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/content-api</basePath>
                  <info>
                    <title>Flowable CONTENT REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/content</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- APP -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.app.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/app-api</basePath>
                  <info>
                    <title>Flowable APP REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/app</swaggerDirectory>
                </apiSource>
                <!-- ++++++++++ -->
                <!-- CMMN -->
                <!-- ++++++++++ -->
                <apiSource>
                  <springmvc>true</springmvc>
                  <locations>
                    <location>org.flowable.cmmn.rest.service.api</location>
                  </locations>
                  <schemes>
                    <scheme>http</scheme>
                    <scheme>https</scheme>
                  </schemes>
                  <host>${swagger.host}</host>
                  <basePath>/flowable-rest/cmmn-api</basePath>
                  <info>
                    <title>Flowable CMMN REST API</title>
                    <version>v1</version>
                    <contact>
                      <email></email>
                      <name>Flowable</name>
                      <url>http://www.flowable.org/</url>
                    </contact>
                    <license>
                      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                      <name>Apache 2.0</name>
                    </license>
                  </info>
                  <securityDefinitions>
                    <securityDefinition>
                      <name>basicAuth</name>
                      <type>basic</type>
                    </securityDefinition>
                  </securityDefinitions>
                  <descriptionFile>${basedir}/src/main/resources/swagger/info.txt</descriptionFile>
                  <outputFormats>json,yaml</outputFormats>
                  <swaggerFileName>flowable</swaggerFileName>
                  <swaggerDirectory>${basedir}/src/main/resources/static/docs/specfile/cmmn</swaggerDirectory>
                </apiSource>
              </apiSources>
            </configuration>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>h2mem</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <dependencies>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <configuration>
              <path>/flowable-rest</path>
              <port>8080</port>
              <protocol>org.apache.coyote.http11.Http11NioProtocol</protocol>
              <systemProperties>
                <com.sun.management.jmxremote.port>4000</com.sun.management.jmxremote.port>
              </systemProperties>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>postgresql</id>
      <dependencies>
        <dependency>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
          <scope>runtime</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <configuration>
              <path>/flowable-rest</path>
              <port>8080</port>
              <protocol>org.apache.coyote.http11.Http11NioProtocol</protocol>
              <systemProperties>
                <spring.datasource.driver-class-name>org.postgresql.Driver</spring.datasource.driver-class-name>
                <spring.datasource.url>jdbc:postgresql://localhost:5432/flowable</spring.datasource.url>
                <spring.datasource.username>flowable</spring.datasource.username>
                <spring.datasource.password>flowable</spring.datasource.password>
                <com.sun.management.jmxremote.port>4000</com.sun.management.jmxremote.port>
              </systemProperties>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>mysql</id>
      <dependencies>
        <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <scope>compile</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
              <arguments>
                <argument>--spring.datasource.driver-class-name=com.mysql.jdbc.Driver</argument>
                <argument>--spring.datasource.url=jdbc:mysql://127.0.0.1:3306/flowable?characterEncoding=UTF-8</argument>
                <argument>--spring.datasource.username=flowable</argument>
                <argument>--spring.datasource.password=flowable</argument>
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <!-- docker image build and push -->
    <profile>
      <id>docker</id>
      <dependencies>
        <dependency>
          <groupId>org.postgresql</groupId>
          <artifactId>postgresql</artifactId>
          <scope>compile</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>docker-resources</id>
                <phase>validate</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>target/</outputDirectory>
                  <resources>
                    <resource>
                      <directory>src/main/docker/</directory>
                      <filtering>false</filtering>
                      <excludes>
                        <exclude>**/*.yml</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>dockerfile-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>build</id>
                <phase>package</phase>
                <goals>
                  <goal>build</goal>
                </goals>
                <configuration>
                  <tag>latest</tag>
                </configuration>
              </execution>
              <execution>
                <id>push-latest</id>
                <phase>deploy</phase>
                <goals>
                  <goal>push</goal>
                </goals>
                <configuration>
                  <tag>latest</tag>
                </configuration>
              </execution>
              <execution>
                <id>push-version</id>
                <phase>deploy</phase>
                <goals>
                  <goal>tag</goal>
                  <goal>push</goal>
                </goals>
                <configuration>
                  <tag>${project.version}</tag>
                </configuration>
              </execution>
            </executions>
            <configuration>
              <repository>flowable/flowable-rest</repository>
              <buildArgs>
                <WAR_FILE>${project.build.finalName}.war</WAR_FILE>
              </buildArgs>
              <contextDirectory>${project.build.directory}</contextDirectory>
              <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-spring-boot-starter-rest</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.hibernate.validator</groupId>
          <artifactId>hibernate-validator</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-properties-migrator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-json-converter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-groovy-script-static-engine</artifactId>
    </dependency>
    <dependency>
      <groupId>org.flowable</groupId>
      <artifactId>flowable-http</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-crypto</artifactId>
    </dependency>

    <!-- LOGGING -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

    <!-- Actuator -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <dependency>
      <groupId>com.zaxxer</groupId>
      <artifactId>HikariCP</artifactId>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jsr223</artifactId>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId> <!-- Needed for swagger doc generation -->
        <artifactId>jaxb-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>
