-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglassfish-build.xml
220 lines (192 loc) · 10.5 KB
/
glassfish-build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?xml version="1.0"?>
<project name="findyourthings-glassfish" basedir=".">
<!-- This file consists of Ant deployment targets for the GlassFish Application Server -->
<!-- Import this script into your Ant build using <import file="${basedir}/glassfish.build.xml"/> -->
<macrodef name="asadmin">
<attribute name="cmd"/>
<attribute name="args" default=""/>
<attribute name="log" default="true"/>
<element name="pre-conditions" optional="true"/>
<sequential>
<fail message="glassfish.home not set" unless="glassfish.home"/>
<fail message="glassfish.home does not point to a valid GlassFish installation">
<condition>
<or>
<length string="${glassfish.home}" trim="true" length="0"/>
<and>
<not><os family="windows"/></not>
<not><available file="${glassfish.home}/bin/asadmin"/></not>
</and>
<and>
<os family="windows"/>
<not><available file="${glassfish.home}/bin/asadmin.bat"/></not>
</and>
</or>
</condition>
</fail>
<condition property="glassfish.domains.dir" value="${glassfish.home}/glassfish/domains" else="${glassfish.home}/domains">
<available file="${glassfish.home}/glassfish" type="dir"/>
</condition>
<fail message="glassfish.domain not set" unless="glassfish.domain"/>
<fail message="glassfish.domain not a valid GlassFish domain">
<condition>
<or>
<length string="${glassfish.domain}" trim="true" length="0"/>
<not><available file="${glassfish.domains.dir}/${glassfish.domain}" type="dir"/></not>
</or>
</condition>
</fail>
<pre-conditions/>
<!-- Windows batch files (.bat) cannot be executed directly. Must be executed using the command shell (cmd.exe) with the /c switch. -->
<condition property="asadmin.cmd" value="cmd.exe">
<os family="windows"/>
</condition>
<condition property="asadmin.arg1" value="/c ${glassfish.home}/bin/asadmin">
<os family="windows"/>
</condition>
<property name="asadmin.cmd" value="${glassfish.home}/bin/asadmin"/>
<property name="asadmin.arg1" value=""/>
<exec executable="${asadmin.cmd}">
<arg line="${asadmin.arg1}"/>
<arg value="@{cmd}"/>
<arg line="@{args}"/>
<redirector outputproperty="gf.cmd.output" alwayslog="@{log}"/>
</exec>
</sequential>
</macrodef>
<target name="gf-init" description="Prepare properties for GlassFish">
<property name="transactionManagerLookupClass" value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
<property name="ejbJndiPattern" value="java:comp/env/${project.name}/#{ejbName}/local"/>
<property name="seamBootstrapsPu" value="false"/>
<property name="seamEmfRef" value="#{null}"/>
<property name="puJndiName" value="java:comp/env/${project.name}/pu"/>
</target>
<target name="gf-start" description="Start GlassFish">
<asadmin cmd="start-domain" args="${glassfish.domain}"/>
</target>
<target name="gf-debug" description="Start GlassFish in debug mode">
<asadmin cmd="start-domain" args="--debug=true ${glassfish.domain}"/>
</target>
<target name="gf-stop" description="Stop GlassFish">
<asadmin cmd="stop-domain" args="${glassfish.domain}"/>
</target>
<target name="gf-reboot" depends="gf-stop,gf-start" description="Restart GlassFish"/>
<target name="gf-list-components" description="List archives deployed to GlassFish">
<asadmin cmd="list-components"/>
</target>
<target name="gf-list-jdbc-resources" description="List JDBC resources deployed to GlassFish">
<asadmin cmd="list-jdbc-resources"/>
</target>
<target name="gf-check-datasource" unless="glassfish.datasource.useDefault" description="Check if the datasource is registered with GlassFish">
<asadmin cmd="list-jdbc-resources" log="false"/>
<condition property="gf.needs.datasource">
<not><contains string="${gf.cmd.output}" substring="${project.name}Datasource"/></not>
</condition>
</target>
<target name="gf-deploy-datasource" depends="gf-check-datasource" if="gf.needs.datasource"
description="Deploy the datasource to GlassFish">
<asadmin cmd="add-resources" args="${basedir}/resources/glassfish-resources-${profile}.xml"/>
</target>
<target name="gf-cleanup-ear" if="project.ear">
<move todir="${war.dir}/WEB-INF/classes">
<fileset dir="${jar.dir}">
<include name="META-INF/orm.xml" if="project.ear"/>
<include name="META-INF/persistence.xml" if="project.ear"/>
</fileset>
</move>
</target>
<target name="gf-check-seam-exploded" if="project.ear">
<!-- This file has to be deleted each time since the exploded directory has a different name (doesn't block it) -->
<delete file="${ear.dir}/jboss-seam.jar"/>
<condition property="gf.explode.seam">
<and>
<isset property="project.ear"/>
<not><available file="${ear.dir}/jboss-seam_jar" type="dir"/></not>
</and>
</condition>
</target>
<target name="gf-explode-seam" depends="gf-check-seam-exploded" if="gf.explode.seam">
<mkdir dir="${ear.dir}/jboss-seam_jar"/>
<unjar src="${lib.dir}/jboss-seam.jar" dest="${ear.dir}/jboss-seam_jar"/>
</target>
<target name="gf-explode" depends="gf-stage,gf-explode-seam,gf-deploy-datasource"
description="Deploy the datasource and exploded archive to GlassFish">
<asadmin cmd="deploy" args="--name ${project.name} ${exploded.archive.dir}"/>
</target>
<target name="gf-restart" depends="gf-explode"/>
<target name="gf-reexplode" depends="clean,gf-undeploy,gf-explode"
description="Clean, undeploy, and deploy the datasource and exploded archive to GlassFish"/>
<target name="gf-redeploy" depends="clean,gf-undeploy,gf-deploy"
description="Clean, undeploy, and deploy the datasource and packaged archive to GlassFish"/>
<target name="gf-hotdeploy" depends="gf-stage" description="Publish hot deployable artifacts"/>
<target name="gf-stage" depends="gf-init,stage" description="Prepare the exploded archive targeting GlassFish">
<antcall target="gf-cleanup-ear"/>
</target>
<target name="gf-archive" depends="gf-init,archive" description="Prepare a packaged archive targeting GlassFish"/>
<target name="gf-deploy" depends="gf-archive,gf-deploy-datasource"
description="Deploy the datasource and packaged archive to GlassFish">
<asadmin cmd="deploy" args="--name ${project.name} ${packaged.archive}"/>
</target>
<target name="gf-unexplode" depends="gf-undeploy"/>
<target name="gf-undeploy-archive" description="Undeploy the archive from GlassFish">
<asadmin cmd="undeploy" args="${project.name}"/>
</target>
<target name="gf-undeploy-datasource" unless="glassfish.datasource.useDefault"
description="Undeploy the datasource from GlassFish">
<asadmin cmd="delete-jdbc-resource" args="${project.name}Datasource"/>
<asadmin cmd="delete-jdbc-connection-pool" args="${project.name}Pool"/>
<!-- Duplicate last two lines for each JDBC resource -->
</target>
<target name="gf-undeploy" depends="gf-undeploy-archive,gf-undeploy-datasource"
description="Undeploy the archive and datasource from GlassFish"/>
<target name="gf-prepare" depends="gf-stop,gf-deploy-hibernate"
description="Prepare GlassFish to run a Seam application"/>
<target name="gf-deploy-hibernate" description="Deploy Hibernate as a JPA provider on GlassFish">
<fail message="glassfish.home not set" unless="glassfish.home"/>
<fail message="glassfish.home does not point to a valid GlassFish installation">
<condition>
<or>
<length string="${glassfish.home}" trim="true" length="0"/>
<not><available file="${glassfish.home}/bin/asadmin"/></not>
</or>
</condition>
</fail>
<condition property="glassfish.v3" value="true">
<available file="${glassfish.home}/glassfish" type="dir"/>
</condition>
<condition property="glassfish.domains.dir" value="${glassfish.home}/glassfish/domains" else="${glassfish.home}/domains">
<isset property="glassfish.v3"/>
</condition>
<fail message="glassfish.domain not set" unless="glassfish.domain"/>
<fail message="glassfish.domain not a valid GlassFish domain">
<condition>
<or>
<length string="${glassfish.domain}" trim="true" length="0"/>
<not><available file="${glassfish.domains.dir}/${glassfish.domain}" type="dir"/></not>
</or>
</condition>
</fail>
<copy todir="${glassfish.domains.dir}/${glassfish.domain}/lib/ext" overwrite="true">
<fileset dir="${basedir}/lib">
<include name="antlr.jar"/>
<include name="asm.jar" unless="glassfish.v3"/>
<include name="asm-attrs.jar" unless="glassfish.v3"/>
<include name="cglib.jar" unless="glassfish.v3"/>
<include name="cglib-nodep.jar" if="glassfish.v3"/>
<include name="commons-collections.jar"/>
<include name="commons-logging.jar"/>
<include name="concurrent.jar"/>
<include name="dom4j.jar"/>
<include name="hibernate.jar"/>
<include name="hibernate-*.jar"/>
<exclude name="hibernate-search.jar"/>
<include name="javassist.jar"/>
<include name="jboss-common-core.jar"/>
<include name="jta.jar"/>
<include name="persistence-api.jar"/>
<!-- Include any required JDBC driver JARs below -->
<include name="postgresql-9.3-1100.jdbc3.jar"/>
</fileset>
</copy>
</target>
</project>