This repository has been archived by the owner on May 1, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.xml
218 lines (184 loc) · 10.5 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
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
<?xml version="1.0" encoding="UTF-8"?>
<project name="archetypes" basedir=".">
<property name="version" value="3.5.1-SNAPSHOT"/>
<property name="archetype" value="${archetype}"/>
<property name="test.dir" value="${basedir}/target"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="../lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<target name="test" description="Tests that 'mvn integration-test' works with archetype" unless="skipTests">
<echo message="Creating archetype '${archetype}', version '${version}'"/>
<test archetype="${archetype}" version="${version}" dao.framework="${dao.framework}"/>
</target>
<target name="build-archetype" description="Builds Archetypes">
<buildArchetype module="${module}"/>
</target>
<target name="deploy" description="Deploys archetype">
<property name="dir" value="target/${module}-archetype"/>
<mvn command="deploy" dir="${dir}/target/generated-sources/archetype"/>
</target>
<macrodef name="test">
<attribute name="archetype"/>
<attribute name="version"/>
<attribute name="dao.framework"/>
<sequential>
<delete dir="${test.dir}/@{archetype}"/>
<maven dir="${test.dir}" archetype="@{archetype}" version="@{version}"/>
<mvn dir="${test.dir}/@{archetype}" command="integration-test -Ddao.framework=@{dao.framework}"/>
</sequential>
</macrodef>
<macrodef name="maven">
<attribute name="dir"/>
<attribute name="name" default=""/>
<attribute name="archetype" default=""/>
<attribute name="version" default=""/>
<attribute name="command"
default="archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=@{archetype}
-DarchetypeVersion=@{version} -DgroupId=com.mycompany -DartifactId=@{archetype} -DpackageName=com.mycompany
-Darchetype.keepParent=false -DarchetypeCatalog=local"/>
<sequential>
<mkdir dir="${test.dir}"/>
<mvn dir="${test.dir}" command="@{command}"/>
</sequential>
</macrodef>
<macrodef name="buildArchetype">
<attribute name="module" default=""/>
<attribute name="dir" default="target/@{module}-archetype"/>
<sequential>
<mkdir dir="@{dir}"/>
<copy todir="@{dir}">
<fileset dir=".">
<include name="**/**"/>
<exclude name="target/**"/>
<exclude name="**/.svn/**"/>
<exclude name="*.iml"/>
<exclude name="*.ipr"/>
<exclude name="*.log"/>
</fileset>
</copy>
<!-- Fix bug that happens in Bamboo -->
<delete dir="@{dir}" includes="main/**"/>
<mvn dir="@{dir}" command="archetype:create-from-project -DpackageName=org.appfuse.webapp -Darchetype.keepParent=true"/>
<!-- Move packages resources to the root -->
<property name="resources.root" value="@{dir}/target/generated-sources/archetype/src/main/resources/archetype-resources/src/main/resources"/>
<move file="${resources.root}/org/appfuse/webapp" tofile="${resources.root}/webapp" failonerror="false"/>
<delete dir="${resources.root}/src/main/resources/org" failonerror="false"/>
<!-- Change the version number of the generated archetype -->
<replace file="@{dir}/target/generated-sources/archetype/pom.xml" value="${version}">
<replacetoken><![CDATA[<version>1.0-SNAPSHOT</version>]]></replacetoken>
</replace>
<!-- Change the groupId -->
<replace file="@{dir}/target/generated-sources/archetype/pom.xml">
<replacetoken><![CDATA[<groupId>org.appfuse</groupId>]]></replacetoken>
<replacevalue><![CDATA[<groupId>org.appfuse.archetypes</groupId>]]></replacevalue>
</replace>
<!-- Add a description to the archetype's pom.xml -->
<replace file="@{dir}/target/generated-sources/archetype/pom.xml">
<replacetoken><![CDATA[<description>AppFuse Light Web Frameworks: JSF, Spring MVC, Stripes, Struts 2, Tapestry, Wicket.</description>]]></replacetoken>
<replacevalue><![CDATA[<description>AppFuse Archetype</description>]]></replacevalue>
</replace>
<!-- Preserve embedded package names -->
<replace dir="@{dir}/target/generated-sources/archetype/src">
<replacetoken><![CDATA[import ${groupId}.Constants]]></replacetoken>
<replacevalue><![CDATA[import org.appfuse.Constants]]></replacevalue>
</replace>
<replace dir="@{dir}/target/generated-sources/archetype/src">
<replacetoken><![CDATA[import ${groupId}.model]]></replacetoken>
<replacevalue><![CDATA[import org.appfuse.model]]></replacevalue>
</replace>
<replace dir="@{dir}/target/generated-sources/archetype/src">
<replacetoken><![CDATA[import ${groupId}.service.]]></replacetoken>
<replacevalue><![CDATA[import org.appfuse.service.]]></replacevalue>
</replace>
<replace dir="@{dir}/target/generated-sources/archetype/src">
<replacetoken><![CDATA[import ${groupId}.util]]></replacetoken>
<replacevalue><![CDATA[import org.appfuse.util]]></replacevalue>
</replace>
<replace dir="@{dir}/target/generated-sources/archetype/src">
<replacetoken><![CDATA[import org.appfuse.util.MessageUtil]]></replacetoken>
<replacevalue><![CDATA[import ${groupId}.util.MessageUtil]]></replacevalue>
</replace>
<!-- Manually add ${package} to *.tld files -->
<replace dir="@{dir}/target/generated-sources/archetype/src">
<include name="**/*.tld"/>
<replacetoken>org.appfuse.webapp.taglib</replacetoken>
<replacevalue>${package}.webapp.taglib</replacevalue>
</replace>
<!-- Make sure .tld files are filtered -->
<replace dir="@{dir}/target/generated-sources/archetype">
<include name="**/archetype-metadata.xml"/>
<replacetoken><![CDATA[<include>**/*.tld</include>]]></replacetoken>
</replace>
<replace dir="@{dir}/target/generated-sources/archetype">
<include name="**/archetype-metadata.xml"/>
<replacetoken><![CDATA[<include>**/*.jsp</include>
<include>**/*.xml</include>]]></replacetoken>
<replacevalue><![CDATA[<include>**/*.jsp</include>
<include>**/*.tld</include>
<include>**/*.xml</include>]]></replacevalue>
</replace>
<!-- Fix package for java files -->
<replace dir="@{dir}/target/generated-sources/archetype">
<include name="**/archetype-metadata.xml"/>
<replacetoken><![CDATA[<include>**/*.java</include>]]></replacetoken>
<replacevalue><![CDATA[<include>webapp/**/*.java</include>]]></replacevalue>
</replace>
<!-- Fix hibernate.cfg.xml and persistence.xml -->
<replace dir="@{dir}/target/generated-sources/archetype/src">
<include name="**/hibernate.cfg.xml"/>
<include name="**/persistence.xml"/>
<replacetoken>${groupId}</replacetoken>
<replacevalue>org.appfuse</replacevalue>
</replace>
<!-- Make sure webapp.xml has proper package replacement -->
<replace dir="@{dir}/target/generated-sources/archetype">
<include name="**/web.xml"/>
<replacetoken>org.appfuse.webapp</replacetoken>
<replacevalue>${groupId}.webapp</replacevalue>
</replace>
<!-- Make sure all Java files are in webapp directory -->
<replace dir="@{dir}/target/generated-sources/archetype">
<include name="**/*"/>
<replacetoken>${package}</replacetoken>
<replacevalue>${package}.webapp</replacevalue>
</replace>
<replace dir="@{dir}/target/generated-sources/archetype">
<include name="**/*"/>
<replacetoken>webapp.webapp</replacetoken>
<replacevalue>webapp</replacevalue>
</replace>
<property name="web.root"
value="@{dir}/target/generated-sources/archetype/src/main/resources/archetype-resources"/>
<!-- sources -->
<move file="${web.root}/src/main/java" tofile="${web.root}/src/main/java/webapp"/>
<!-- tests -->
<move file="${web.root}/src/test/java" tofile="${web.root}/src/test/java/webapp"/>
<!-- Fix filtering of Tapestry components -->
<replaceregexp byline="false" flags="gim">
<regexp pattern="<fileSet encoding="UTF-8">(\s+)<directory>src/main/resources</directory>(\s+)<includes>(\s+)<include>\*\*/\*.tml</include>(\s+)</includes>(\s+)</fileSet>"/>
<substitution expression="<fileSet packaged="true" encoding="UTF-8">${line.separator} <directory>src/main/resources</directory>${line.separator} <includes>${line.separator} <include>**/*.tml</include>${line.separator} </includes>${line.separator} </fileSet>"/>
<fileset dir="@{dir}/target/generated-sources/archetype">
<include name="**/archetype-metadata.xml"/>
</fileset>
</replaceregexp>
<mvn command="install" dir="@{dir}/target/generated-sources/archetype"/>
</sequential>
</macrodef>
<macrodef name="mvn">
<attribute name="command"/>
<attribute name="dir"/>
<sequential>
<exec dir="@{dir}" executable="mvn.bat" os="Windows XP" failonerror="true">
<arg line="@{command}"/>
</exec>
<exec dir="@{dir}" executable="mvn" os="Mac OS X" failonerror="true">
<arg line="@{command}"/>
</exec>
<exec dir="@{dir}" executable="mvn" os="Linux" failonerror="true">
<arg line="@{command}"/>
</exec>
</sequential>
</macrodef>
</project>