<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>
    <artifactId>wise-webapp</artifactId>
    <packaging>war</packaging>
    <name>WiseMapping Webapp</name>
    <url>http://www.wisemapping.org</url>
    <parent>
        <groupId>org.wisemapping</groupId>
        <artifactId>wisemapping</artifactId>
        <relativePath>../pom.xml</relativePath>
        <version>5.1.0-SNAPSHOT</version>
    </parent>

    <properties>
        <org.springframework.version>6.0.11</org.springframework.version>
        <org.springframework.addons>6.1.2</org.springframework.addons>
        <hibernate.version>6.2.6.Final</hibernate.version>
        <hibernate-validator.version>6.0.21.Final</hibernate-validator.version>
        <spring-security-taglibs.version>6.0.2</spring-security-taglibs.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.wisemapping</groupId>
            <artifactId>wise-ui</artifactId>
            <version>${com.wisemapping.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.7</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.7.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>annotations</artifactId>
            <version>12.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-messaging</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.5.4</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${spring-security-taglibs.version}</version>
        </dependency>
        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core-jakarta</artifactId>
            <version>5.6.15.Final</version>
        </dependency>

        <!-- Hibernate Validator -->
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>8.0.1.Final</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${org.springframework.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.3.15</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${org.springframework.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${org.springframework.addons}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>${org.springframework.addons}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
            <version>2.1.2</version>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <version>8.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>jakarta.mail</artifactId>
            <version>2.0.2</version>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.hibernate</groupId>-->
<!--            <artifactId>hibernate-ehcache</artifactId>-->
<!--            <version>5.6.15.Final</version>-->
<!--        </dependency>-->
<!--        <dependency>-->
<!--            <groupId>javax.cache</groupId>-->
<!--            <artifactId>cache-api</artifactId>-->
<!--            <version>1.1.1</version>-->
<!--        </dependency>-->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.20.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-validator/commons-validator -->
        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.7</version>
        </dependency>

        <!-- Only for test purposes -->
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.7.1</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.15.1</version>
        </dependency>

        <dependency>
            <groupId>jakarta.transaction</groupId>
            <artifactId>jakarta.transaction-api</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>
        <!-- JSLT implementation -->
        <dependency>
            <groupId>jakarta.servlet.jsp.jstl</groupId>
            <artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jakarta.servlet.jsp.jstl</artifactId>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.11.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>fluent-hc</artifactId>
            <version>4.5.14</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.addons}</version>
        </dependency>
    </dependencies>
    <profiles>
        <profile>
            <id>hsqldb</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <version>1.5</version>

                        <configuration>
                            <driver>org.hsqldb.jdbc.JDBCDriver</driver>
                            <url>jdbc:hsqldb:file:${project.build.directory}/db/wisemapping</url>
                            <username>sa</username>
                        </configuration>

                        <dependencies>
                            <dependency>
                                <groupId>org.hsqldb</groupId>
                                <artifactId>hsqldb</artifactId>
                                <version>2.7.1</version>
                            </dependency>
                        </dependencies>

                        <executions>
                            <execution>
                                <id>drop-schemas</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <onError>continue</onError>
                                    <orderFile>descending</orderFile>
                                    <fileset>
                                        <basedir>${project.basedir}</basedir>
                                        <includes>
                                            <include>config/database/hsql/drop-schemas.sql</include>
                                            <include>config/database/hsql/create-schemas.sql</include>
                                            <include>config/database/hsql/apopulate-schemas.sql</include>
                                        </includes>
                                    </fileset>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>mysqldb</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <version>1.5</version>
                        <dependencies>
                            <dependency>
                                <groupId>mysql</groupId>
                                <artifactId>mysql-connector-java</artifactId>
                                <version>8.0.31</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>init-schema</id>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <phase>prepare-package</phase>
                            </execution>
                        </executions>
                        <configuration>
                            <driver>com.mysql.jdbc.Driver</driver>
                            <username>root</username>
                            <password/>
                            <url>jdbc:mysql://127.0.0.1:3306/?useUnicode=true&amp;characterEncoding=UTF-8</url>
                            <autocommit>false</autocommit>
                            <srcFiles>
                                <srcFile>config/database/mysql/create-database.sql</srcFile>
                                <srcFile>config/database/mysql/create-schemas.sql</srcFile>
                                <srcFile>config/database/mysql/apopulate-schemas.sql</srcFile>
                            </srcFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <plugins>
<!--            <plugin>-->
<!--                <groupId>org.hibernate.orm.tooling</groupId>-->
<!--                <artifactId>hibernate-enhance-maven-plugin</artifactId>-->
<!--                <version>${hibernate.version}</version>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <phase>compile</phase>-->
<!--                        <configuration>-->
<!--                            <failOnError>true</failOnError>-->
<!--                            <enableLazyInitialization>true</enableLazyInitialization>-->
<!--                            <enableDirtyTracking>true</enableDirtyTracking>-->
<!--                            <enableAssociationManagement>true</enableAssociationManagement>-->
<!--                            <enableExtendedEnhancement>false</enableExtendedEnhancement>-->
<!--                            <enableExtendedEnhancement>false</enableExtendedEnhancement>-->
<!--                        </configuration>-->
<!--                        <goals>-->
<!--                            <goal>enhance</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
<!--            </plugin>-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <warName>wisemapping</warName>
                    <overlays>
                        <overlay>
                            <groupId>org.wisemapping</groupId>
                            <artifactId>wise-ui</artifactId>
                            <targetPath>/static/mindplot/</targetPath>
                            <includes>
                                <include>wisemapping-mindplot/package/dist/*</include>
                            </includes>
                        </overlay>
                        <overlay>
                            <groupId>org.wisemapping</groupId>
                            <artifactId>wise-ui</artifactId>
                            <targetPath>/static/webapp/</targetPath>
                            <includes>
                                <include>wisemapping-webapp/package/dist/*</include>
                            </includes>
                        </overlay>
                    </overlays>
                    <archiveClasses>true</archiveClasses>
                    <packagingExcludes>
                        WEB-INF/lib/commons-logging-*.jar,
                    </packagingExcludes>
                    <webResources>
                        <resource>
                            <directory>src/main/resources</directory>
                            <targetPath>WEB-INF</targetPath>
                            <includes>
                                <include>*.wsdl</include>
                                <include>*.xsd</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.10</version>
                <executions>
                    <execution>
                        <id>default-prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-prepare-agent-integration</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>prepare-agent-integration</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                <exclude>**/*Test*</exclude>
                            </excludes>
                            <propertyName>integrationTestArgLine</propertyName>
                        </configuration>
                    </execution>

                    <execution>
                        <id>default-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>COMPLEXITY</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.10</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>11.0.15</version>
                <configuration>
                    <httpConnector>
                        <port>8080</port>
                    </httpConnector>
                    <jvmArgs>-Ddatabase.base.url=${project.build.directory} -Djetty.port=8080</jvmArgs>
                    <stopPort>9999</stopPort>
                    <deployMode>FORK</deployMode>
                    <stopKey>foo</stopKey>
                    <webApp>
                        <war>${project.build.directory}/wisemapping.war</war>
                        <overrideDescriptor>${project.basedir}/webdefault.xml</overrideDescriptor>
                    </webApp>
                </configuration>
                <executions>
                    <execution>
                        <id>run-forked</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start-war</goal>
                        </goals>
                        <configuration>
                            <useTestScope>true</useTestScope>
                        </configuration>
                    </execution>
                    <execution>
                        <id>stop-jetty</id>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>stop</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>