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

    <parent>
        <groupId>org.jboss.windup.web</groupId>
        <artifactId>windup-web-parent</artifactId>
        <version>4.0.1.Final</version>
    </parent>

    <properties>
        <!-- No additional args by default -->
        <server.jvm.args>${jvm.debug.args}</server.jvm.args>
    </properties>

    <artifactId>windup-web-services</artifactId>
    <name>Windup Web - Services</name>
    <packaging>war</packaging>

    <dependencies>
        <!-- Java EE -->
        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-7.0</artifactId>
            <version>${version.jboss.javaee}</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

        <!-- Jackson -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson2-provider</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.1-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <scope>provided</scope>
            <version>5.0.10.Final</version>
        </dependency>

        <!-- Multipart provider for file upload -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-multipart-provider</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Furnace Runtime -->
        <dependency>
            <groupId>org.jboss.forge.furnace</groupId>
            <artifactId>furnace</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.forge.furnace</groupId>
            <artifactId>furnace-se</artifactId>
        </dependency>

        <!-- Furnace -> Java EE CDI Bridge -->
        <dependency>
            <groupId>org.jboss.windup.web</groupId>
            <artifactId>furnace-service-provider</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Windup Web Addons -->
        <dependency>
            <groupId>org.jboss.windup.web.addons</groupId>
            <artifactId>windup-web-support-api</artifactId>
            <version>${project.version}</version>
            <scope>compile</scope>
        </dependency>

        <!-- Windup APIs -->
        <dependency>
            <groupId>org.jboss.windup.config</groupId>
            <artifactId>windup-config-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.windup.graph</groupId>
            <artifactId>windup-graph-api</artifactId>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-httpclient</groupId>
                    <artifactId>commons-httpclient</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.windup.exec</groupId>
            <artifactId>windup-exec-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.windup.utils</groupId>
            <artifactId>windup-utils</artifactId>
            <classifier>forge-addon</classifier>
            <scope>compile</scope>
        </dependency>

        <!-- Rules -->

        <dependency>
            <groupId>org.jboss.windup.rules.apps</groupId>
            <artifactId>windup-rules-java-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.jboss.windup.web</groupId>
            <artifactId>test-authentication-client</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.10.19</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-warp</artifactId>
            <scope>test</scope>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpcore</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-rest-warp-spi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-rest-warp-impl-jaxrs-2.0</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jsapi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxb-provider</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-depchain</artifactId>
            <scope>test</scope>
            <type>pom</type>
        </dependency>

        <!-- Needed for FileDefaultServlet -->
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-core</artifactId>
            <version>1.4.0.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.undertow</groupId>
            <artifactId>undertow-servlet</artifactId>
            <version>1.4.0.Final</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>5.2.1.Final</version>
            <scope>provided</scope>
        </dependency>

        <!-- Other local dependencies -->
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>rhamt-web/api</finalName>
        
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-windup-dist</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.jboss.windup</groupId>
                                    <artifactId>rhamt-cli</artifactId>
                                    <version>${version.windup}</version>
                                    <classifier>offline</classifier>
                                    <type>zip</type>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/</outputDirectory>
                            <overWriteReleases>true</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jboss.forge.furnace</groupId>
                <artifactId>furnace-maven-plugin</artifactId>
                <version>${version.furnace}</version>
                <executions>
                    <execution>
                        <id>deploy-addons</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>addon-install</goal>
                        </goals>
                        <inherited>false</inherited>
                        <configuration>
                            <overwrite>false</overwrite>
                            <addonRepository>${project.build.directory}/${project.build.finalName}/WEB-INF/${windup.distribution.name}-${version.windup}/addons</addonRepository>
                            <addonIds>
                                <addonId>org.jboss.windup.web.addons:windup-web-support,${project.version}</addonId>
                            </addonIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>rename-windup-dist</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <move file="${project.build.directory}/${project.build.finalName}/WEB-INF/${windup.distribution.name}-${version.windup}" tofile="${project.build.directory}/${project.build.finalName}/WEB-INF/${windup.distribution.name}" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Generate Typescript Models -->
            <plugin>
                <groupId>cz.habarta.typescript-generator</groupId>
                <artifactId>typescript-generator-maven-plugin</artifactId>
                <version>1.10.212</version>
                <executions>
                    <execution>
                        <id>generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <jsonLibrary>jackson2</jsonLibrary>
                            <classPatterns>
                                <pattern>org.jboss.windup.web.services.model.**</pattern>
                                <pattern>org.jboss.windup.web.addons.websupport.rest.graph.applicationDetails.**</pattern>
                                <pattern>org.jboss.windup.web.addons.websupport.rest.graph.aggregatedStatistics.**</pattern>
                            </classPatterns>
                            <excludeClasses>
                                <class>java.io.Serializable</class>
                            </excludeClasses>
                            <outputFile>${project.build.outputDirectory}/windup-services.ts</outputFile>
                            <outputFileType>implementationFile</outputFileType>
                            <outputKind>module</outputKind>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/apt</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <configuration>
                            <processors>
                                <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-jpamodelgen</artifactId>
                        <version>5.2.1.Final</version>
                    </dependency>
                </dependencies>
                </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <proc>none</proc>
                </configuration>
            </plugin>

            <!-- Set the delimiter token. -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <delimiters combine.self="override">
                        <delimiter>$MAVEN_TOKEN{*}</delimiter>
                    </delimiters>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <classifier>typescript-models</classifier>
                            <includes>
                                <include>windup-services.ts</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- -Ddebug will make the server run in debug mode, listening for debugger at port 8000. -->
        <profile>
            <id>debug</id>
            <activation> <property> <name>debug</name> </property> </activation>
            <properties>
                <jvm.debug.argsx>-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y</jvm.debug.argsx>
            </properties>
        </profile>

        <profile>
            <id>arquillian-wildfly-10-managed</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.spec</groupId>
                    <artifactId>jboss-javaee-7.0</artifactId>
                    <version>${version.jboss.javaee}</version>
                    <type>pom</type>
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>org.wildfly.arquillian</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <version>2.0.0.Final</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.arquillian.protocol</groupId>
                    <artifactId>arquillian-protocol-servlet</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <skip>${skipTests}</skip>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jboss.windup.web</groupId>
                                            <artifactId>windup-web-tests-wildfly-dist</artifactId>
                                            <version>${project.version}</version>
                                            <type>jar</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>target</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <server.jvm.args>${surefire.server.jvm.args}</server.jvm.args>
                                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-6.0</artifactId>
                <version>3.0.3.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
