<?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>at.researchstudio.sat</groupId>
        <artifactId>webofneeds</artifactId>
        <version>0.3</version>
    </parent>
    <groupId>at.researchstudio.sat</groupId>
    <artifactId>won-node-webapp</artifactId>
    <version>0.3</version>
    <packaging>war</packaging>
    <name>Node Webapp</name>

    <dependencies>
        <!--

                 Warning! Only to be used in connection with the
                 <dependencyManagement> section in the parent pom!

        -->
        <dependency>
            <groupId>at.researchstudio.sat</groupId>
            <artifactId>won-node</artifactId>
            <version>${project.version}</version>
            <scope>${dependencies.scope}</scope>
        </dependency>

        <!-- spring stuff -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <scope>${dependencies.scope}</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <scope>${dependencies.scope}</scope>
        </dependency>

        <!-- servlet stuff -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>

    </dependencies>

    <build>
        <finalName>won</finalName>
        <sourceDirectory>src/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>


        <plugins>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>${cargo.version}</version>
                <configuration>
                    <skip>false</skip>
                    <container>
                        <containerId>tomcat7x</containerId>
                        <type>remote</type>
                    </container>
                    <configuration>
                        <type>runtime</type>
                        <properties>
                            <cargo.remote.uri>${tomcat.url}</cargo.remote.uri>
                            <cargo.remote.username>${tomcat.user}</cargo.remote.username>
                            <cargo.remote.password>${tomcat.password}</cargo.remote.password>
                        </properties>
                    </configuration>
                    <deployer>
                        <type>remote</type>
                    </deployer>
                    <deployables>
                        <deployable>
                            <groupId>at.researchstudio.sat</groupId>
                            <artifactId>won-node-webapp</artifactId>
                            <type>war</type>
                        </deployable>
                    </deployables>
                </configuration>
                <!--<executions>
                    <execution>
                        <id>deploy-node-tomcat</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deployer-redeploy</goal>
                        </goals>
                    </execution>
                </executions>-->
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>copy-dependencies-to-node-webapp</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                            <overWriteReleases>true</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeGroupIds>${project.groupId}</includeGroupIds>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
    <profiles>
        <profile>
            <id>skip-node-webapp-war</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.ekryd.echo-maven-plugin</groupId>
                        <artifactId>echo-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>skip-node-webapp-jar-before</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>echo</goal>
                                </goals>
                                <configuration>
                                    <message>Note: building the won-node-webapp war file is skipped. This is done because the profile 'skip-node-webapp-war' is active ('-P skip-node-webapp-war' on the command line)</message>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- use the same config as above but set the phase to 'none' -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-war</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-dependencies-to-node-webapp</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-node-webapp-war-but-explode</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.ekryd.echo-maven-plugin</groupId>
                        <artifactId>echo-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>skip-node-webapp-war-but-explode-before</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>echo</goal>
                                </goals>
                                <configuration>
                                    <message>Note: building the won-node-webapp war file is skipped, but the webapp is built in 'exploded' mode. This is done because the profile 'skip-node-webapp-war-but-explode' is active ('-P skip-node-webapp-war-but-explode' on the command line)</message>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- use the same config as above but set the phase to 'none' -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-war-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-war</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>default-exploded</id>
                                <phase>package</phase>
                                <goals><goal>exploded</goal></goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

