<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.jboss.jopr</groupId>
        <artifactId>jopr-embedded-parent</artifactId>
        <version>1.4.0.CR2</version>
   </parent>
   
	<groupId>org.jboss.jopr</groupId>
	<artifactId>jopr-embedded-jbas4</artifactId>	
	<packaging>war</packaging>
	<name>JBossAS 4.x Administration Console</name>

    <scm>
		<connection>scm:svn:http://anonsvn.jboss.org/repos/embjopr/tags/EmbJopr_1_4_0_CR2/jbas4</connection>
		<developerConnection>scm:svn:https://svn.jboss.org/repos/embjopr/tags/EmbJopr_1_4_0_CR2/jbas4</developerConnection>
	  <url>http://git.fedorahosted.org/git/tags/EmbJopr_1_4_0_CR2/jbas4?p=rhq/rhq.git;a=tree/jopr-embedded-parent/jopr-embedded-jbas4</url>
  </scm>
    
   <properties>       
       <warDir>${basedir}/target/${project.build.finalName}</warDir>
       <warFile>${warDir}.war</warFile>
       <contextRoot>admin-console</contextRoot>
   </properties>
   
   <dependencies>

       <dependency>
         <groupId>org.jboss.jopr</groupId>
         <artifactId>jopr-embedded-core</artifactId>
         <version>${project.version}</version>
         <type>war</type>
       </dependency>
       
		<!--Needed for 4.0.5, not for 4.2-->
		<!--<dependency>-->
		<!--<groupId>com.sun.el</groupId>-->
		<!--<artifactId>el-ri</artifactId>-->
		<!--<version>1.0</version>-->
		<!--</dependency>-->
       
   </dependencies>
   
	<build>		
		<finalName>${jbas4.finalName}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.0</version>
                <executions>
                    <execution>
                        <id>copy-dist-plugins</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${warDir}/plugins</outputDirectory>
                            <artifactItems>
                                <!-- the AS4 plugin itself -->
                                <artifactItem>
                                    <groupId>${jopr.groupId}</groupId>
                                    <artifactId>jopr-jboss-as-plugin</artifactId>
                                    <version>${jopr.version}</version>
                                </artifactItem>

                                <!-- the plugins the AS4 plugin depends on -->
                                <artifactItem>
                                    <groupId>${jopr.groupId}</groupId>
                                    <artifactId>jopr-hibernate-plugin</artifactId>
                                    <version>${jopr.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>${rhq.groupId}</groupId>
                                    <artifactId>rhq-jmx-plugin</artifactId>
                                    <version>${rhq.version}</version>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>${jopr.groupId}</groupId>
                                    <artifactId>jopr-tomcat-plugin</artifactId>
                                    <version>${jopr.version}</version>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>				
                               
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
                    <webResources>						
						<resource>
							<filtering>true</filtering>
							<directory>
								${basedir}/src/main/webapp
							</directory>
						</resource>
					</webResources>  
                    <overlays>
                      <overlay>
                        <!-- empty groupId/artifactId detected as the current build.
                             earlier overlays win over later overlays, so put ourselves first. -->
                      </overlay>
                      <overlay>
                        <groupId>org.jboss.jopr</groupId>
                        <artifactId>jopr-embedded-core</artifactId>
                      </overlay>
                    </overlays>               
				</configuration>
		  </plugin>    			
        
          <!--
		   <plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
   				<execution>
      				<phase>package</phase>
      				<configuration>
         				<tasks>                         
                            <echo>*** Overlaying messages...</echo>
         				    <replace file="${warDir}/WEB-INF/classes/messages.properties" token="default.windowTitle=JBoss Application Server Console" value="default.windowTitle=JBoss Administration Console for ESB" />
                                  
                            <zip destfile="${warFile}" basedir="${warDir}" includes="WEB-INF/classes/messages.properties" update="true" />  
         				</tasks>
      				</configuration>
      				<goals>
      				    <goal>run</goal>
      				</goals>
   				</execution>
				</executions>
			</plugin>			        
           -->
		</plugins>
	</build>
        
    <profiles>        
       <profile>
         <id>dev</id>

         <properties>            
            <warDeployDir>${jbas4.configDir}/deploy/${project.build.finalName}.war</warDeployDir>                        
         </properties>

         <build>
            <plugins>

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

                     <execution>
                        <id>deploy</id>
                        <phase>package</phase>
                        <configuration>
                          <tasks>
                            <property name="deployment.dir" location="${warDeployDir}" />
                            <echo>*** Copying updated files from target${file.separator}${project.build.finalName} to &lt;warDir&gt;...</echo>
                            <touch file="${basedir}/target/${project.build.finalName}/WEB-INF/classes/messages.properties" />
                            <copy todir="${deployment.dir}" verbose="${embedded.verbose}">
                               <fileset dir="${basedir}/target/${project.build.finalName}" />
                            </copy>
                            <unjar src="${project.build.directory}/${project.build.finalName}.war" dest="${deployment.dir}">
                               <patternset>
                                  <include name="META-INF/**" />
                               </patternset>
                            </unjar>
                            <echo>*** Touching &lt;warDir&gt;/WEB-INF/web.xml to force redeploy...</echo>
                            <touch file="${deployment.dir}/WEB-INF/web.xml" />                            
                          </tasks>
                        </configuration>
                        <goals>
                          <goal>run</goal>
                        </goals>
                     </execution>

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

                  </executions>
               </plugin>

            </plugins>
         </build>
      </profile>        
   </profiles>        
   
</project>