<?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>dk.nsi.stamdata4</groupId>
    <artifactId>sdm-parent</artifactId>
    <version>4.1</version>
    <packaging>pom</packaging>

    <scm>
        <url>scm:git:git@github.com:trifork/sdm4-parent</url>
        <connection>scm:git:git@github.com:trifork/sdm4-parent.git</connection>
        <developerConnection>scm:git:git@github.com:trifork/sdm4-parent.git</developerConnection>
    </scm>
    <issueManagement>
        <system>JIRA</system>
        <url>https://jira.trifork.com/</url>
    </issueManagement>
    <ciManagement>
        <system>Jenkins</system>
        <url>https://ci02.trifork.com:8443/view/SDM4/job/SDM4-parent/</url>
    </ciManagement>

    <prerequisites>
        <maven>3.0.0</maven>
    </prerequisites>

    <distributionManagement>
        <repository>
            <id>Trifork-Nexus-Release-Repository</id>
            <name>Trifork Nexus Release Repository</name>
            <url>https://nexus.trifork.com/content/repositories/releases/</url>
        </repository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>Trifork-Nexus-Public-Repository</id>
            <name>Trifork Nexus Public Repository</name>
            <url>https://nexus.trifork.com/content/groups/public/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>Trifork-Nexus-Public-Repository</id>
            <name>Trifork Nexus Public Repository</name>
            <url>https://nexus.trifork.com/content/groups/public/</url>
        </pluginRepository>
    </pluginRepositories>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring.version>3.1.1.RELEASE</spring.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.10</version>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
            <dependency>
                <groupId>dk.sdsd.nsp</groupId>
                <artifactId>nsp-util</artifactId>
                <version>1.0.8</version>
            </dependency>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-all</artifactId>
                <version>1.1</version>
            </dependency>
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.21</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.0</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>dk.nsi.stamdata4</groupId>
                <artifactId>vagrant-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-jboss-descriptors</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.12</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>deploy-integrationtest-war</id>
            <activation>
                <file>
                    <!-- activate profile only in modules which seems to be war files -->
                    <exists>src/main/webapp/WEB-INF/web.xml</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.2.1</version>
                        <executions>
                            <execution>
                                <id>provision</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>vagrant</executable>
                                    <arguments>
                                        <argument>provision</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>prepare-deploy</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>ln</executable>
                                    <arguments>
                                        <argument>-f</argument>
                                        <argument>${project.build.directory}/${project.build.finalName}.war</argument>
                                        <argument>${project.build.directory}/${project.artifactId}.war</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>deploy</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>vagrant</executable>
                                    <arguments>
                                        <argument>ssh</argument>
                                        <argument>-c</argument>
                                        <argument>/pack/jboss/bin/jboss-cli.sh -c --commands='deploy --force
                                            /vagrant/sdm4-${project.artifactId}/target/${project.artifactId}.war' --user=sdmadmin --password=trifork
                                        </argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>handle-vagrant-vms</id>
            <activation><property><name>sdm.handle.vagrant.vms</name></property></activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.2.1</version>
                        <executions>
                            <execution>
                                <id>vm-up</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>vagrant</executable>
                                    <arguments>
                                        <argument>up</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>vm-destroy</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>vagrant</executable>
                                    <arguments>
                                        <argument>destroy</argument>
                                        <argument>--force</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
