<?xml version="1.0" encoding="UTF-8"?>
<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>

    <groupId>com.swdfactory</groupId>
    <artifactId>Handelion</artifactId>
    <version>0.0.2</version>
    <packaging>war</packaging>

    <name>Handelion</name>

    <properties>
        <version.properties.file>${project.basedir}/version.properties</version.properties.file>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>

        <properties.file.local>${basedir}/local.properties</properties.file.local>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <war.final.name>Handelion</war.final.name>

        <version.deltaspike>1.8.2</version.deltaspike>
        <version.httpclient>4.5.5</version.httpclient>
        <version.httpcore>4.4.9</version.httpcore>
        <version.security.shiro>1.4.0-RC2</version.security.shiro>
        <version.aws.java.sdk>1.11.105</version.aws.java.sdk>
        <version.resteasy.jboss>3.0.24.Final</version.resteasy.jboss>
        <!--version.resteasy.jboss>3.1.1.Final</version.resteasy.jboss-->
        <version.powermock>1.6.6</version.powermock>
        <version.jackson>2.8.9</version.jackson>

        <!-- JBoss dependency versions -->
        <version.wildfly.maven.plugin>1.2.1.Final</version.wildfly.maven.plugin>

        <!-- Define the version of the JBoss BOMs we want to import to specify
        tested stacks. -->
        <version.jboss.bom>11.0.0.Final</version.jboss.bom>


        <shiro.realm.jpa>$jpaRealm</shiro.realm.jpa>
        <shiro.realm.activeDirectory>$activeDirectoryRealm</shiro.realm.activeDirectory>
        <shiro.cache.manager.infinispan>com.swdfactory.handelion.core.security.InfinispanCacheManager</shiro.cache.manager.infinispan>

        <restricted.resource.1>/restricted1/*</restricted.resource.1>

        <storage.factory.class.local>com.swdfactory.handelion.core.util.StorageProfileProducer</storage.factory.class.local>

        <shiro.realm>${shiro.realm.jpa}</shiro.realm>
        <shiro.cache.manager>${shiro.cache.manager.infinispan}</shiro.cache.manager>
        <storage.factory.class>${storage.factory.class.local}</storage.factory.class>

        <wildfly.local.hostname>127.0.0.1</wildfly.local.hostname>
        <wildfly.local.port>10090</wildfly.local.port>

        <persistence.hibernate.hbm2ddl.auto>validate</persistence.hibernate.hbm2ddl.auto>
        <ui.skip>false</ui.skip>
        <maven.test.skip>false</maven.test.skip>

        <grunt.dev></grunt.dev>
    </properties>
    
    <dependencyManagement>
        <dependencies>
            <!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill
            of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection)
            of artifacts. We use this here so that we always get the correct versions
            of artifacts. Here we use the jboss-javaee-7.0-with-tools stack (you can
            read this as the JBoss stack of the Java EE 7 APIs, with some extras tools
            for your project, such as Arquillian for testing) and the jboss-javaee-7.0-with-hibernate
            stack you can read this as the JBoss stack of the Java EE 7 APIs, with extras
            from the Hibernate family of projects) -->
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>wildfly-javaee7-with-tools</artifactId>
                <version>${version.jboss.bom}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>


    <dependencies>
        <dependency>
            <groupId>org.mindrot</groupId>
            <artifactId>jbcrypt</artifactId>
            <version>0.4</version>
        </dependency>

        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${version.httpclient}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>${version.httpcore}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-api</artifactId>
            <version>${version.deltaspike}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.deltaspike.core</groupId>
            <artifactId>deltaspike-core-impl</artifactId>
            <version>${version.deltaspike}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.deltaspike.modules</groupId>
            <artifactId>deltaspike-data-module-api</artifactId>
            <version>${version.deltaspike}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.deltaspike.modules</groupId>
            <artifactId>deltaspike-data-module-impl</artifactId>
            <version>${version.deltaspike}</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.1.10.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <!-- jsoup HTML parser library @ http://jsoup.org/ -->
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.11.3</version>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
        </dependency>

		<dependency>
			<groupId>commons-lang</groupId>
			<artifactId>commons-lang</artifactId>
			<version>2.6</version>
            <scope>provided</scope>
		</dependency>

        <dependency>
        	<groupId>org.apache.commons</groupId>
        	<artifactId>commons-lang3</artifactId>
        	<version>3.6</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.22</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk15on</artifactId>
            <version>1.56</version>
            <scope>provided</scope>
        </dependency>

        <!--dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.5</version>
        </dependency-->

        <dependency>
        	<groupId>com.fasterxml.jackson.core</groupId>
        	<artifactId>jackson-core</artifactId>
        	<version>${version.jackson}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>${version.security.shiro}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>${version.security.shiro}</version>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.3</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.5</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
			<groupId>commons-collections</groupId>
			<artifactId>commons-collections</artifactId>
			<version>3.2.2</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.7</version>
            <scope>provided</scope>
        </dependency>
        <!-- amazon sdk core -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-core</artifactId>
            <version>${version.aws.java.sdk}</version>
        </dependency>

        <!-- amazon sdk S3 -->
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>${version.aws.java.sdk}</version>
        </dependency>

        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>8.2.8.Final</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jaxrs</artifactId>
			<version>${version.resteasy.jboss}</version>
        </dependency>

		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-multipart-provider</artifactId>
			<version>${version.resteasy.jboss}</version>
		</dependency>

        <!-- Unit testing: REST services -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>tjws</artifactId>
            <version>${version.resteasy.jboss}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>${version.resteasy.jboss}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson-provider</artifactId>
            <version>${version.resteasy.jboss}</version>
            <scope>test</scope>
        </dependency>

        <!-- Unit testing: mockito -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.7.19</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jmock</groupId>
            <artifactId>jmock-legacy</artifactId>
            <version>2.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock</artifactId>
            <version>${version.powermock}</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <version>${version.powermock}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4-common</artifactId>
            <version>${version.powermock}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>${version.powermock}</version>
            <scope>test</scope>
        </dependency>

        <!-- Needed for running tests (you may also use TestNG) -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Optional, but highly recommended -->
        <!-- Arquillian allows you to test enterprise code such as EJBs and Transactional(JTA)
        JPA from JUnit/TestNG -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.arquillian.protocol</groupId>
            <artifactId>arquillian-protocol-servlet</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- testing: archiver-->
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
            <version>2.2.6</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.descriptors</groupId>
            <artifactId>shrinkwrap-descriptors-impl-javaee</artifactId>
            <version>2.0.0-alpha-10</version>
            <scope>test</scope>
        </dependency>


        <!-- jasperreports -->
        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.4.0</version>

            <exclusions>
              <exclusion>
                <groupId>org.bouncycastle</groupId>
				<artifactId>bctsp-jdk14</artifactId>
              </exclusion>
              <exclusion>
                <groupId>bouncycastle</groupId>
				<artifactId>bcprov-jdk14</artifactId>
              </exclusion>
              <exclusion>
                <groupId>bouncycastle</groupId>
				<artifactId>bcmail-jdk14</artifactId>
              </exclusion>

            </exclusions>
        </dependency>

        <dependency>
        	<groupId>org.freemarker</groupId>
        	<artifactId>freemarker</artifactId>
        	<version>2.3.23</version>
        </dependency>

        <dependency>
			<groupId>javax.mail</groupId>
			<artifactId>javax.mail-api</artifactId>
			<version>1.5.6</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
        	<groupId>javax.activation</groupId>
        	<artifactId>activation</artifactId>
        	<version>1.1.1</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>

        <pluginManagement>
            <plugins>

                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.12.4</version>
                    <configuration>
                        <includes>
                            <include>**/*Test.java</include>
                        </includes>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>


        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <endorseddirs>${endorsed.dir}</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <webResources combine.children="append">
                        <resource>
                            <directory>${basedir}/src/main/webapp</directory>
                            <filtering>true</filtering>
                            <excludes>
                            	<exclude>index.html</exclude>
                            </excludes>
                        </resource>
                        <!--resource>
                            <directory>frontend/dist</directory>
                            <filtering>false</filtering>
                            <excludes>
                            	<exclude>scripts/**.*</exclude>
                            </excludes>

                        </resource>
                        <resource>
                            <directory>frontend/dist</directory>
                            <filtering>true</filtering>
                            <includes>
                            	<include>scripts/**.*</include>
                            </includes>
						</resource-->

                    </webResources>

                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <warName>${war.final.name}</warName>

                    <archive>
                    	<manifestEntries>
                    		<Dependencies>org.infinispan export, org.apache.commons.io export, org.apache.commons.beanutils export, org.apache.commons.codec export, org.apache.commons.collections export, org.apache.commons.lang export, javax.activation.api export, org.joda.time export, org.bouncycastle export</Dependencies>
                    	</manifestEntries>
                    </archive>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${endorsed.dir}</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax</groupId>
                                    <artifactId>javaee-endorsed-api</artifactId>
                                    <version>7.0</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

			<plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>frontend/dist</directory>
                            <includes>
                                <include>**/*</include>
                            </includes>
                        </fileset>
                        <fileset>
                            <directory>frontend/.tmp</directory>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<version>1.0.0</version>

				<executions>
		          <execution>
		            <phase>initialize</phase>
		            <goals>
		              <goal>read-project-properties</goal>
		            </goals>
		            <configuration>
		              <files>
						<file>${properties.file.local}</file>
                        <file>${version.properties.file}</file>
		              </files>
		            </configuration>
		          </execution>
		        </executions>

			</plugin>


        </plugins>
    </build>

    <profiles>

        <profile>
            <!-- An optional Arquillian testing profile that executes tests in a remote
            WildFly instance -->
            <!-- Run with: mvn clean test -Parq-wildfly-remote -->
            <id>it-wildfly-remote</id>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-remote</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>

                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.12.4</version>
                        <configuration>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                        </configuration>
                    </plugin>

                </plugins>
            </build>

        </profile>



        <profile>
            <id>wildfly-remote</id>

            <build>
                <plugins>

                    <plugin>
                    	<groupId>org.wildfly.plugins</groupId>
                    	<artifactId>wildfly-maven-plugin</artifactId>
                    	<version>${version.wildfly.maven.plugin}</version>

                    	<configuration>
                    	    <filename>${war.final.name}.war</filename>
	                    	<hostname>${wildfly.local.hostname}</hostname>
	                    	<port>${wildfly.local.port}</port>
                    	</configuration>
                    </plugin>

                </plugins>
            </build>

        </profile>

        <profile>
            <id>wildfly-remote-prod</id>

            <properties>
                <persistence.hibernate.hbm2ddl.auto>none</persistence.hibernate.hbm2ddl.auto>
            </properties>

            <build>
                <plugins>

                    <plugin>
                    	<groupId>org.wildfly.plugins</groupId>
                    	<artifactId>wildfly-maven-plugin</artifactId>
                    	<version>${version.wildfly.maven.plugin}</version>

                    	<configuration>
                    	    <filename>${war.final.name}.war</filename>
	                    	<hostname>${wildfly.local.hostname}</hostname>
	                    	<port>${wildfly.local.port}</port>
                    	</configuration>
                    </plugin>

                </plugins>
            </build>

        </profile>

        <profile>
            <id>dev</id>

            <properties>
                <grunt.dev>dev</grunt.dev>
            </properties>

        </profile>

        <profile>
            <id>root</id>
            <properties>
                <war.final.name>ROOT</war.final.name>
            </properties>
        </profile>

        <profile>
            <id>ui</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <!-- optional: you don't really need execution ids, but it looks nice in your build log. -->
                                <id>install node and npm</id>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <!-- optional: default phase is "generate-resources" -->
                                <phase>generate-resources</phase>
                            </execution>
                            <execution>
                                <id>npm install</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>

                                <!-- optional: default phase is "generate-resources" -->
                                <phase>generate-resources</phase>

                                <configuration>
                                    <arguments>install</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm run-script build</id>
                                <goals>
                                    <goal>npm</goal>
                                </goals>

                                <!-- optional: default phase is "generate-resources" -->
                                <phase>generate-resources</phase>

                                <configuration>
                                    <arguments>run build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <nodeVersion>v8.11.3</nodeVersion>
                            <workingDirectory>frontend</workingDirectory>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <webResources>
                                <resource>
                                    <directory>frontend/dist</directory>
                                </resource>
                            </webResources>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
</project>