<?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>6.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>
    <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.1.0</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>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>export</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <descriptors>
            <descriptor>assembly-export.xml</descriptor>
          </descriptors>
        </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>4.15.0</version>
      </dependency>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>32.1.3-jre</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!-- Tobago -->
    <dependency>
      <groupId>org.apache.myfaces.core</groupId>
      <artifactId>myfaces-test</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.persistence</groupId>
      <artifactId>jakarta.persistence-api</artifactId>
      <version>3.0.0</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.10.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.validation</groupId>
      <artifactId>jakarta.validation-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpcore</artifactId>
      <version>4.4.16</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.43.4</version>
            <configuration>
              <verbose>true</verbose>
              <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>${myfaces40.version}</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.apache.myfaces.core</groupId>
          <artifactId>myfaces-impl</artifactId>
          <version>${myfaces40.version}</version>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>jcl-over-slf4j</artifactId>
        </dependency>
        <dependency>
          <groupId>jakarta.inject</groupId>
          <artifactId>jakarta.inject-api</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>jakarta.enterprise</groupId>
          <artifactId>jakarta.enterprise.cdi-api</artifactId>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>jakarta.servlet.jsp.jstl</groupId>
          <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.jboss.weld.servlet</groupId>
          <artifactId>weld-servlet-shaded</artifactId>
          <scope>runtime</scope>
        </dependency>
        <dependency>
          <groupId>org.hibernate.validator</groupId>
          <artifactId>hibernate-validator</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>
      </dependencies>
    </profile>

    <profile>
      <id>frontend</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.3.1</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>
