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

    <parent>
        <groupId>org.rhq</groupId>
        <artifactId>rhq-enterprise-server-sars-parent</artifactId>
        <version>4.8.0</version>
    </parent>

    <groupId>org.rhq</groupId>
    <artifactId>rhq-enterprise-server-services-sar</artifactId>
    <packaging>jboss-sar</packaging>

    <name>RHQ Enterprise Server Internal Services SAR</name>
    <description>The SAR that provides the server with some necessary internal RHQ services.</description>

    <properties>
        <sarDirectory>${project.build.directory}/${project.build.finalName}</sarDirectory>
    </properties>

    <build>
        <finalName>rhq-enterprise-server-services-sar</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <profiles>

        <profile>
            <id>dev</id>

            <properties>
                <rhq.rootDir>../../../../..</rhq.rootDir>
                <rhq.containerDir>${rhq.rootDir}/${rhq.devContainerServerPath}</rhq.containerDir>
                <rhq.deploymentName>${project.build.finalName}.sar</rhq.deploymentName>
                <rhq.deploymentDir>${rhq.containerDir}/${rhq.earDeployDir}/${rhq.deploymentName}</rhq.deploymentDir>
            </properties>

            <build>
                <plugins>

                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>

                            <execution>
                                <id>deploy</id>
                                <phase>package</phase>
                                <configuration>
                                    <target>
                                        <property name="deployment.dir" location="${rhq.deploymentDir}" />
                                        <echo>*** Copying updated files
                                            from
                                            target${file.separator}classes${file.separator}
                                            to
                                            ${deployment.dir}${file.separator}...</echo>
                                        <jar destfile="${deployment.dir}">
                                            <fileset dir="target/${project.build.finalName}" />
                                        </jar>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>

                            <execution>
                                <id>undeploy</id>
                                <phase>clean</phase>
                                <configuration>
                                    <target>
                                        <property name="deployment.dir" location="${rhq.deploymentDir}" />
                                        <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
                                        <delete file="${deployment.dir}" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>

                        </executions>
                    </plugin>

                </plugins>
            </build>

        </profile>

    </profiles>

</project>
