<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->
<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.apache.myfaces.tobago</groupId>
    <artifactId>tobago-example</artifactId>
    <version>5.0.0</version>
  </parent>
  <artifactId>tobago-example-demo</artifactId>
  <packaging>${app.packaging}</packaging>
<!--  XXX Must use 'jar' for 'mvn quarkus:dev'. Can't be set via variable!-->
<!--  <packaging>jar</packaging>-->
  <name>Tobago Example Demo</name>
  <description>Demonstration and documentation application.</description>

  <!-- how to run tests: http://tobago-vm.apache.org/faq.html  -->

  <properties>
    <selenium.version>3.141.59</selenium.version>
    <exec.version>1.6.0</exec.version>
    <tobago-theme-standard-dir>${basedir}/target/tobago-theme-standard</tobago-theme-standard-dir>
    <docker-tomcat-dir>${project.build.directory}/docker-tomcat</docker-tomcat-dir>
    <frontend.skip>false</frontend.skip>
  </properties>

  <build>
    <finalName>tobago-example-demo</finalName>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <!-- this is needed for ShrinkWrap to use java 8 (QUnitTests) -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${maven.compile.source}</source>
          <target>${maven.compile.target}</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <version>1.0.2</version>
        <executions>
          <execution>
            <goals>
              <goal>validate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <validationSets>
            <validationSet>
              <dir>src/main/webapp</dir>
              <includes>
                <include>**/*.xhtml</include>
              </includes>
              <excludes>
                <exclude>**/x-error-in-syntax.xhtml</exclude>
              </excludes>
            </validationSet>
          </validationSets>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webResources>
            <resource>
              <targetPath>src</targetPath>
              <directory>${basedir}/src/main/java</directory>
            </resource>
          </webResources>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>initialize</phase>
            <configuration>
              <target>
                <mkdir dir="${tobago-theme-standard-dir}/META-INF/resources" />
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <configuration>
          <loginServices>
            <loginService implementation="org.eclipse.jetty.security.HashLoginService">
              <name>demo-realm</name>
              <config>src/test/resources/realm.properties</config>
            </loginService>
          </loginServices>
          <stopKey>stopKey</stopKey>
          <stopPort>9999</stopPort>
          <systemProperties>
            <systemProperty>
              <name>derby.stream.error.file</name>
              <value>target/derby.log</value>
            </systemProperty>
          </systemProperties>
          <!--
            <webApp>
              <contextPath>/example</contextPath>
            </webApp>
          -->
          <webApp>
            <resourceBases>${basedir}/src/main/webapp,${tobago-theme-standard-dir}/META-INF/resources</resourceBases>
          </webApp>
        </configuration>
        <dependencies>
        </dependencies>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>integration/*</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
      </dependency>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>31.0.1-jre</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!-- Tobago -->
    <dependency>
      <groupId>org.apache.myfaces.test</groupId>
      <artifactId>myfaces-test23</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.persistence</groupId>
      <artifactId>javax.persistence-api</artifactId>
      <version>2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.myfaces.tobago</groupId>
      <artifactId>tobago-tool-test</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.8.8</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.validation</groupId>
      <artifactId>jakarta.validation-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.bval</groupId>
      <artifactId>bval-jsr</artifactId>
      <version>2.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
      <version>4.4.14</version>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>dev</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-tobago-theme-standard</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <outputDirectory>${tobago-theme-standard-dir}</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.apache.myfaces.tobago</groupId>
                      <artifactId>tobago-theme-standard</artifactId>
                      <version>${project.version}</version>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>integration-tests</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <includes>
                <include>integration/*</include>
              </includes>
            </configuration>
            <executions>
              <execution>
                <phase>integration-test</phase>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>checkstyle-for-view-definition-language</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <configuration>
              <configLocation>META-INF/checkstyle-tobago.xml</configLocation>
              <includes>**/*.xhtml</includes>
              <excludes>**/*.java</excludes>
              <sourceDirectory>src/main/webapp</sourceDirectory>
            </configuration>
            <dependencies>
              <dependency>
                <groupId>org.apache.myfaces.tobago</groupId>
                <artifactId>tobago-core</artifactId>
                <version>${project.version}</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>docker</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-resources</id>
                <phase>package</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${docker-tomcat-dir}</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${basedir}/src/main/docker</directory>
                      <includes>
                        <include>Dockerfile</include>
                      </includes>
                    </resource>
                    <resource>
                      <directory>${basedir}/src/test/tomee/conf</directory>
                      <includes>
                        <include>tomcat-users.xml</include>
                      </includes>
                    </resource>
                    <resource>
                      <directory>${project.build.directory}</directory>
                      <includes>
                        <include>*.war</include>
                      </includes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.37.0</version>
            <configuration>
              <images>
                <image>
                  <name>myfaces/%a:%l</name>
                  <run>
                    <ports>
                      <port>8080:8080</port>
                    </ports>
                  </run>
                  <build>
                    <dockerFileDir>${docker-tomcat-dir}</dockerFileDir>
                  </build>
                </image>
              </images>
            </configuration>
            <executions>
              <execution>
                <id>build</id>
                <phase>package</phase>
                <goals>
                  <goal>build</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>org.apache.myfaces.core</groupId>
          <artifactId>myfaces-api</artifactId>
          <version>${myfaces23.version}</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.myfaces.core</groupId>
          <artifactId>myfaces-impl</artifactId>
          <version>${myfaces23.version}</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>jcl-over-slf4j</artifactId>
        </dependency>
        <dependency>
          <groupId>org.apache.openwebbeans</groupId>
          <artifactId>openwebbeans-jsf</artifactId>
          <version>${openwebbeans.version}</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.openwebbeans</groupId>
          <artifactId>openwebbeans-web</artifactId>
          <version>${openwebbeans.version}</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.openwebbeans</groupId>
          <artifactId>openwebbeans-resource</artifactId>
          <version>${openwebbeans.version}</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.myfaces.tobago</groupId>
          <artifactId>tobago-config-owb</artifactId>
          <version>${project.version}</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>jakarta.inject</groupId>
          <artifactId>jakarta.inject-api</artifactId>
          <version>1.0.5</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>jakarta.enterprise</groupId>
          <artifactId>jakarta.enterprise.cdi-api</artifactId>
          <scope>compile</scope>
        </dependency>
        <!-- this enables the development mode -->
        <dependency>
          <groupId>org.apache.myfaces.tobago</groupId>
          <artifactId>tobago-config-dev</artifactId>
          <version>${project.version}</version>
        </dependency>
        <dependency> <!-- add JAXB to run the demo with Java 11 and higher -->
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>2.3.1</version>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>frontend</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
              <execution>
                <id>copy the result to target</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>
                    ${project.build.outputDirectory}/META-INF/resources
                  </outputDirectory>
                  <resources>
                    <resource>
                      <directory>npm/dist</directory>
                      <includes>
                        <include>js/demo.js</include>
                        <include>js/demo.js.map</include>
                      </includes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
