-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
193 lines (166 loc) · 8.29 KB
/
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
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright © 2016 - 2018 Software AG, Darmstadt, Germany and/or its licensors
~
~ SPDX-License-Identifier: Apache-2.0
~
~ Licensed 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="J2EE JMS Examples" default="assemble" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant" xmlns:if="ant:if">
<description>build file</description>
<condition property="build.customprofiles.properties.exist" value="true">
<available file="build.customprofiles.properties"/>
</condition>
<property file="build.customprofiles.properties" if:true="${build.customprofiles.properties.exist}"/>
<property file="build.properties"/>
<property environment="env"/>
<target name="init.ant.contrib">
<path id="ant.contrib.classpath" path="${j2ee-jms-examples.lib.dir}/ant-contrib.jar"/>
<taskdef classpathref="ant.contrib.classpath" resource="net/sf/antcontrib/antlib.xml"/>
</target>
<!-- Maven task Initialization -->
<target name="init.maven">
<property name="mvn_home" value="${env.MAVEN_HOME}" if:set="env.MAVEN_HOME"/>
<property name="mvn_home" value="${env.M2_HOME}" if:set="env.M2_HOME"/>
<property name="mvn_home" value="${maven.home}" if:set="maven.home"/>
<property name="mvn_home" value="" />
<echo>Maven home: ${mvn_home}</echo>
<fail message="Path to "maven_home" must be set. You can set it in application build.properties or in either MAVEN_HOME or M2_HOME environment variable.">
<condition>
<and>
<equals arg1="${mvn_home}" arg2="" trim="true"/>
</and>
</condition>
</fail>
<mkdir dir="${j2ee-jms-examples.lib.dir}"/>
<get src="http://central.maven.org/maven2/org/apache/maven/maven-ant-tasks/2.1.3/maven-ant-tasks-2.1.3.jar"
dest="${j2ee-jms-examples.lib.dir}/maven-ant-tasks-2.1.3.jar" usetimestamp="true"/>
<path id="maven-ant-tasks.classpath" path="${j2ee-jms-examples.lib.dir}/maven-ant-tasks-2.1.3.jar"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath"/>
</target>
<!-- Initialization -->
<target name="init" description="Generic initialization steps for the project" depends="init.ant.contrib,init.maven">
<mkdir dir="${j2ee-jms-examples.target.dir}"/>
</target>
<target name="clean_target_dir" description="Cleaning target dist dir">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${j2ee-jms-examples.target.dir}" includes="*.ear"/>
</delete>
<echo message="Cleaning completed fortarget dist dir"/>
</target>
<!-- Clean runtime -->
<target name="clean" description="Cleaning all projects" depends="init">
<echo>Maven Cleaning...</echo>
<artifact:mvn pom="pom.xml" mavenHome="${mvn_home}" fork="true" failonerror="true">
<jvmarg value="-Dmaven.multiModuleProjectDirectory"/>
<arg value="clean"/>
<arg value="-P ${mvn_profile}"/>
</artifact:mvn>
<echo message="Cleaning completed for all projects"/>
</target>
<target name="package" description="Compiles the sources and creates runtime jar" depends="init,clean">
<echo>Build package for profile ${profile}</echo>
<property name="regex" value="^([^_-]*)[_-]?(.*)$"/>
<propertyregex
property="app.name"
input="${profile}"
regexp="${regex}"
select="\1"
casesensitive="false"/>
<propertyregex
property="build.name"
input="${profile}"
regexp="${regex}"
select="\2"
casesensitive="false"/>
<!-- Some defaults -->
<property name="app.name" value="" />
<property name="build.name" value="" />
<echo>app.name = ${app.name}</echo>
<echo>build.name = ${build.name}</echo>
<tolowercase propname="build.property.name" value="${build.name}"></tolowercase>
<property name="build.property.name" value="${build.name}" />
<if>
<or>
<equals arg1="${build.name}" arg2="" trim="true"/>
<equals arg1="${build.name}" arg2="default" trim="true"/>
</or>
<then>
<property name="property.file.name" value="build.properties"/>
</then>
<else>
<property name="property.file.name" value="build.${build.property.name}.properties"/>
</else>
</if>
<echo>Building with properties in: ${basedir}/${app.name}/${property.file.name}</echo>
<artifact:mvn pom="pom.xml" mavenHome="${mvn_home}" fork="true" failonerror="true">
<jvmarg value="-Dmaven.multiModuleProjectDirectory"/>
<arg value="package"/>
<arg value="-DskipTests"/>
<arg value="-Dbuild.properties=${basedir}/${app.name}/${property.file.name}"/>
<arg value="-P deployment_${j2ee-jms-examples.deployment_target}"/>
<arg value="-P ${j2ee-jms-examples.compiler.target}"/>
<arg value="-P logging_${j2ee-jms-examples.logging.level}"/>
</artifact:mvn>
</target>
<target name="assemble" description="Creates server jar" depends="init,clean_target_dir">
<setprofilelist propname="deployment_profile_list" profilename="${j2ee-jms-examples.deployment_profilename}" />
<echo>${deployment_profile_list}</echo>
<for list="${deployment_profile_list}" param="profile">
<sequential>
<trycatch reference="exception_ref">
<try>
<echo message="@{profile}"/>
<echo>Building profile @{profile}</echo>
<antcall target="package">
<param name="profile" value="@{profile}"/>
</antcall>
<if>
<contains string="@{profile}" substring="${j2ee-jms-examples.simpleJmsSend.dir}" casesensitive="false"/>
<then>
<copy todir="${j2ee-jms-examples.target.dir}">
<fileset file="${j2ee-jms-examples.simpleJmsSend.dir}/ear/target/*.ear"/>
</copy>
</then>
</if>
<if>
<contains string="@{profile}" substring="${j2ee-jms-examples.simpleJmsConsume.dir}" casesensitive="false"/>
<then>
<copy todir="${j2ee-jms-examples.target.dir}">
<fileset file="${j2ee-jms-examples.simpleJmsConsume.dir}/ear/target/*.ear"/>
</copy>
</then>
</if>
</try>
<catch>
<echo message="Build for profile '@{profile}' failed"/>
</catch>
</trycatch>
</sequential>
</for>
</target>
<macrodef name="setprofilelist">
<attribute name="propname"/>
<attribute name="profilename"/>
<sequential>
<property name="@{propname}" value="${j2ee-jms-examples.deployment_profiles_@{profilename}}" />
</sequential>
</macrodef>
<scriptdef language="javascript" name="tolowercase">
<attribute name="propname" />
<attribute name="value" />
project.setProperty(attributes.get("propname"), attributes.get("value").toLowerCase());
</scriptdef>
</project>