<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<project name="j2g-security" default="all" basedir=".">

    <import file="build-macros.xml"/>
    <property file="build.properties"/>

    <mkdir dir="build"/>


    <path id="classpath">
        <fileset dir="${jboss.home}/server/${jboss.server}/lib" includes="*.jar"/>
    </path>

    <path id="xdoclet.classpath">
        <path refid="classpath"/>
        <fileset dir="${xdoclet.home}/lib" includes="*.jar"/>
    </path>


    <target name="clean">
        <delete dir="build"/>
    </target>

    <target name="jboss.security.ejb">
        <build.jar name="security.jar" target="jboss"/>
    </target>

    <target name="jboss.security.sar">
        <build.jar name="security.sar" target="jboss"/>
    </target>


    <target name="jboss.security.war" depends="jboss.security.ejb">
        <build.war name="security.war" target="jboss">
            <extradeps>
                <pathelement path="build/jboss/security.jar"/>
            </extradeps>
        </build.war>
    </target>

    <target name="jboss.security.ear" depends="jboss.security.war,jboss.security.ejb,jboss.security.sar">
        <build.ear name="security.ear" target="jboss">
            <modules>
                <include name="security.war"/>
                <include name="security.jar"/>
                <include name="security.sar"/>
            </modules>
        </build.ear>
    </target>


    <target name="geronimo.security.ejb">
        <build.jar name="security.jar" target="geronimo"/>
    </target>

    <target name="geronimo.security.war" depends="geronimo.security.ejb">
        <build.war name="security.war" target="geronimo">
            <extradeps>
                <pathelement path="build/geronimo/security.jar"/>
            </extradeps>
        </build.war>
    </target>

    <target name="geronimo.security.ear" depends="geronimo.security.war,geronimo.security.ejb">
        <build.ear name="security.ear" target="geronimo">
            <modules>
                <include name="security.war"/>
                <include name="security.jar"/>
                <include name="security.sar"/>
            </modules>
        </build.ear>
    </target>

    <target name="all" depends="geronimo.security.ear,jboss.security.ear"/>


    <!-- 
        Deploys (or redeploys) the application on JBoss. If the server is
        started the application will be installed and started on the fly.
        The JBoss version of the application must be previously built and
        located in the <bin> folder.
    -->
    <target name="deploy.jboss">
        <copy todir="${jboss.home}/server/${jboss.server}/deploy"
              file="build/jboss/security.ear"/>
    </target>

    <!-- 
        Deploys (or redeploys) the application on Geronimo. The server
        should be started.
        The Geronimo version of the application must be previously built
        and located in the <bin> folder.
    -->
    <target name="deploy.geronimo">
        <java jar="${geronimo.home}/bin/deployer.jar" fork="true">
            <arg value="--user"/>
            <arg value="${geronimo.user}"/>
            <arg value="--password"/>
            <arg value="${geronimo.password}"/>
            <arg value="undeploy"/>
            <arg value="org/apache/geronimo/demo/security"/>
        </java>

        <java jar="${geronimo.home}/bin/deployer.jar" fork="true">
            <arg value="--user"/>
            <arg value="${geronimo.user}"/>
            <arg value="--password"/>
            <arg value="${geronimo.password}"/>
            <arg value="deploy"/>
            <arg value="build/geronimo/security.ear"/>
        </java>
    </target>



    <target name="xdoclet.ejb">
        <taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="xdoclet.classpath"/>
        <ejbdoclet ejbSpec="2.0"  excludedTags="@version,@author,@todo"  destDir="modules/security.jar/src"  verbose="true"  addedTags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version}" >
            <fileset dir="modules/security.jar/src"  includes="**/*.java"/>
            <remoteinterface/>
            <localinterface/>
            <homeinterface/>
            <localhomeinterface/>
            <session/>
            <utilobject includeGUID="true"  cacheHomes="true"/>
            <deploymentdescriptor validateXML="true"  destDir="modules/security.jar/src/META-INF"/>
            <jboss Version="3.0"  securityDomain="java:/jaas/j2g"  destDir="modules/security.jar/src/META-INF/jboss"/>
        </ejbdoclet>
    </target>

    <target name="xdoclet.web">
        <taskdef name="webdoclet" classname="xdoclet.modules.web.WebDocletTask" classpathref="xdoclet.classpath"/>
        <webdoclet excludedTags="@version,@author,@todo"  destDir="modules/security.war/src"  verbose="true"  addedTags="@xdoclet-generated at ${TODAY},@copyright The XDoclet Team,@author XDoclet,@version ${version}" >
            <fileset dir="modules/security.war/src"  includes="**/*.java"/>
            <deploymentdescriptor Servletspec="2.4"  destDir="modules/security.war/src/WEB-INF"  mergeDir="modules/security.war/src/WEB-INF/merge"/>
            <jbosswebxml securitydomain="java:/jaas/j2g"  destDir="modules/security.war/src/WEB-INF/jboss"/>
        </webdoclet>
    </target>

    <target name="xdoclet" depends="xdoclet.web,xdoclet.ejb"/>

</project>