blob: a95d7d0d124f04709fe23bb9711bd29ebbfd5e4a [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<project name="hello-jsp" default="default" basedir=".">
<property file="build.properties"/>
<description>Builds, tests, and runs the project Hello JSP Application</description>
<!-- <import file="nbproject/build-impl.xml"/>-->
<path id="sun.appserver.antjar">
<fileset dir="${install.dir}/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="sun-taskdef">
<taskdef name="sun-appserv-deploy"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask">
<classpath refid="sun.appserver.antjar" />
</taskdef>
<taskdef name="sun-appserv-undeploy"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UndeployTask">
<classpath refid="sun.appserver.antjar" />
</taskdef>
</target>
<path id="class.path">
<fileset dir="${install.dir}/lib">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${class.output}/app"/>
</path>
<path id="run.testng.classpath">
<fileset dir="${install.dir}/lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="../../lib">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${class.output}/app"/>
<pathelement location="${test.class.output}"/>
</path>
<!-- TestNG class fileset -->
<fileset id="run.classfileset"
dir="${build.dir}/"
includes="**/*.class">
</fileset>
<target name="build">
<delete dir="${class.output}/app"/>
<delete dir="${dist.dir}"/>
<mkdir dir="${class.output}/app"/>
<mkdir dir="${dist.dir}"/>
<echo message="Now compiling"/>
<javac debug="true"
fork="true"
source="1.5"
classpathref="class.path"
srcdir="src/myapp/java"
destdir="${class.output}/app"/>
<echo message="Now creating a war file ${dist.dir}/${war.file}"/>
<war destfile="${dist.dir}/${war.file}" webxml="metadata/web.xml" needxmlfile="true">
<fileset dir="src/myapp/html"/>
<fileset dir="src/myapp/jsp"/>
<!--<lib dir="thirdparty/libs">
<exclude name="jdbc1.jar"/>
</lib>-->
<classes dir="${class.output}/app">
<include name="**/Hello.class"/>
</classes>
<!--<zipfileset dir="src/graphics/images/gifs"
prefix="images"/>-->
<!--<webinf dir="metadata">
<include name="**/*.xml"/>
</webinf>-->
</war>
<copy file="${dist.dir}/${war.file}" tofile="./${war.file}"/>
<echo message="======================================================="/>
<echo message="Packaged Archive at ${dist.dir}/${war.file}"/>
<echo message="======================================================="/>
</target>
<path id="path2testng">
<pathelement location="testng-5.0-jdk15.jar"/>
</path>
<taskdef name="testng"
classpathref="path2testng"
classname="org.testng.TestNGAntTask"/>
<!-- Generate the TestNG report -->
<target name="report">
<delete dir="${result.output}"/>
<mkdir dir="${test-report}"/>
<junitreport todir="${test-report}">
<fileset dir=".">
<include name="**/test-output/**/*.xml"/>
<exclude name="**/testng-failed.xml"/>
</fileset>
<report format="noframes" todir="test-report"/>
</junitreport>
</target>
<target name="compile-tests"
description="compile the test ng example" depends="">
<mkdir dir="${test.class.output}"/>
<javac debug="true"
fork="true"
source="1.5"
classpathref="path2testng"
srcdir="src/test"
destdir="${test.class.output}"
/>
</target>
<target name="run">
<echo message="=============Starting TestNG test at ${class.output}/test ============"/>
<mkdir dir="${result.output}"/>
<testng outputdir="${result.output}"
suitename="V3 TestSuite"
testname="web_hello_world"
classpathref="run.testng.classpath">
<!--<xmlfileset dir="../../" includes="testng.xml"/>-->
<classfileset dir="${test.class.output}" includes="**/WebTestNG.class"/>
<jvmarg value="-Dhost=localhost" />
<jvmarg value="-Dport=8080" />
<jvmarg value="-Dcontextroot=hellojsp" />
</testng>
</target>
<target name="stop">
</target>
<target name="deploy">
<antcall target="deploy-v2"/>
<antcall target="deploy-v3"/>
</target>
<target name="deploy-v2" depends="sun-taskdef" unless="v3">
<sun-appserv-deploy file="${dist.dir}/${war.file}"
name="helloworld"
force="true"
precompilejsp="true"
verify="false"
upload="true"
user="${admin.user}"
passwordfile="${install.dir}/pass.txt"
host="${admin.host}"
port="${admin.port}"
asinstalldir="${install.dir}" />
</target>
<target name="deploy-v3" if="v3">
<echo message="deploying in v3 mode"/>
<echo message="./${war.file}"/>
<copy file="${dist.dir}/${war.file}" todir="${glassfish.home}/domains/domain1/autodeploy"/>
<!--<get src="http://localhost:8080/_asadmin/deploy?path=${war.file}" dest="test.html"/>-->
</target>
<target name="undeploy" depends="sun-taskdef">
<sun-appserv-undeploy file="${dist.dir}/${war.file}"
name="helloworld"
user="${admin.user}"
passwordfile="${install.dir}/pass.txt"
host="${admin.host}"
port="${admin.port}"
asinstalldir="${install.dir}" />
</target>
<target name="source">
<zip zipfile="${final.src.name}" basedir=".">
<exclude name="${out.dir}/**"/>
<exclude name="**/*.log"/>
<exclude name="**/*.bak"/>
<exclude name="**/*.class"/>
<exclude name="${build.dir}/build.properties"/>
</zip>
</target>
</project>