annotate ssdt-common-build.xml @ 4:be1051bf262f

add globally common ant scripts
author smith@nwoca.org
date Fri, 17 Dec 2010 16:55:03 -0500
parents
children 9c847b8c7e9c
rev   line source
4
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
1 <?xml version="1.0" encoding="UTF-8"?>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
2 <project name="ssdt-common-build" default="all" basedir=".">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
3 <!--
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
4 ssdt common build functions. Contains generalized tasks to perform
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
5 common functions. Assumes some standard properties from a NetBeans
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
6 project are provided.
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
7
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
8 Properties used for webapps:
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
9
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
10 build.web.dir - docBase of build webapp.
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
11 web.docbase.dir - source docBase of webapp
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
12 web.context.path - path to install webapp in Tomcat
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
13 tomcat.username - Tomcat manager username
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
14 tomcat.password - Tomcat manager password
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
15
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
16 -->
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
17 <!--
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
18 <taskdef name="groovy"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
19 classname="org.codehaus.groovy.ant.Groovy"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
20 classpath="${tools.dir}/groovy-1.0/embeddable/groovy-all-1.0.jar"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
21
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
22 <taskdef name="groovyc"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
23 classname="org.codehaus.groovy.ant.Groovyc"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
24 classpath="${tools.dir}/groovy-1.0/embeddable/groovy-all-1.0.jar"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
25
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
26 -->
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
27 <target name="project.cvs.update"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
28 depends="project.init"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
29 unless="build.devel.bamboo">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
30 <!-- Get the latest from CVS -->
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
31 <cvs command="up -d -P"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
32 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
33
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
34 <target name="project.cc.init" depends="project.init" description="Deprecated use project.ini">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
35 <echo level="warning" message="project.cc.init is deprecated. Use project.init"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
36 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
37
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
38 <target name="project.init" depends="init,-project.cvs.version.init">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
39 <property name="project.version" value="${ivy.revision}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
40 <property name="project.name" value="${ivy.module}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
41 <delete failonerror="false" quiet="true" dir="${build.dir}/checkstyle"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
42 <delete failonerror="false" quiet="true" dir="${build.dir}/tests" />
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
43 <delete failonerror="false" quiet="true" dir="${build.dir}/findbugs" />
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
44 <property name="ssdt.tools.jar" value="${tools.dir}/dist/ssdt-tools.jar"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
45 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
46
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
47 <target name="-project.cvs.getbranch">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
48 <property name="project.version.file" value="${src.dir}/version.properties"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
49 <mkdir dir="${build.dir}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
50 <cvs command="status build.xml" output="${build.dir}/cvs-branch.txt"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
51 <loadfile srcfile="${build.dir}/cvs-branch.txt" property="project.cvs.branch">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
52 <filterchain>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
53 <tabstospaces tablength="1"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
54 <linecontains>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
55 <contains value="Sticky Tag:"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
56 </linecontains>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
57 <replacestring from="Sticky Tag:" to=""/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
58 <replaceregex pattern="\(.*\)" replace=""/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
59 <replacestring from=" " to=""/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
60 <striplinebreaks/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
61 </filterchain>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
62 </loadfile>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
63 <condition property="project.cvs.reset.version.branch"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
64 value="-r ${project.cvs.branch}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
65 else="">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
66 <isset property="project.cvs.branch"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
67 </condition>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
68
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
69 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
70
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
71 <target name="-project.cvs.version.reset">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
72 <echo message="Resetting version file ${project.cvs.reset.version.branch}" level="info"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
73 <cvs command="update -A -C ${project.cvs.reset.version.branch} ${project.version.file}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
74 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
75
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
76 <target name="project.cvs.version"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
77 depends="project.init,-project.cvs.version.init"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
78 if="build.devel">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
79 <echo message="comitting project version file" level="info"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
80 <cvs command="commit -n -mversion-update ${project.version.file}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
81 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
82
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
83 <target name="-project.cvs.version.init"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
84 depends="-project.cvs.getbranch,-project.cvs.version.reset">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
85 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
86
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
87
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
88 <target name="project.version" depends="project.init" >
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
89 <propertyfile
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
90 file="${project.version.file}" comment="Version build information">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
91 <entry key="projectName" value="${project.name}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
92 <entry key="projectVersion" value="${project.version}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
93 <entry key="buildDate" type="date" value="now"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
94 <entry key="buildNumber" default="0" type="int" operation="+" value="1"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
95 <entry key="built.by" value="${ant.version}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
96 <entry key="build.java.version" value="${ant.java.version}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
97 <entry key="built.on" value="${os.name} ${os.arch} ${os.version} (${user.name})"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
98 </propertyfile>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
99 <property file="${project.version.file}" prefix="version"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
100 <copy failonerror="false"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
101 file="${project.version.file}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
102 todir="${build.classes.dir}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
103 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
104
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
105 <target name="-project.pre-init" depends="init">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
106 <condition property="tomcat.available">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
107 <and>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
108 <available file="${tools.dir}/etc/tomcat_anttask.properties"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
109 <available file="${tomcat.home}" type="dir"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
110 </and>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
111 </condition>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
112 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
113
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
114 <target name="-project.init-tomcat" depends="-project.pre-init" if="tomcat.available">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
115 <property name="tomcat.url" value="http://localhost:8084"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
116 <property name="tomcat.manager.url" value="${tomcat.url}/manager"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
117 <property name="ssdt.tools.jar" value="${tools.dir}/dist/ssdt-tools.jar"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
118
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
119 <path id="project.tools.classpath">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
120 <pathelement location="${ssdt.tools.jar}" />
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
121 <fileset dir="${tomcat.home}" includes="**/lib/catalina-ant.jar"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
122 </path>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
123
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
124 <taskdef resource="ssdttomcattasks.properties" classpathref="project.tools.classpath"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
125 <taskdef file="${tools.dir}/etc/tomcat_anttask.properties" classpathref="project.tools.classpath"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
126 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
127
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
128 <target name="project.web.context" depends="-project.init-tomcat,init">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
129 <dirname property="docBase.dir.name" file="${build.web.dir}/WEB-INF"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
130
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
131 <property name="project.context.file" value="${web.docbase.dir}/META-INF/context.xml"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
132
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
133 <copy file="${project.context.file}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
134 tofile="${build.web.dir}/META-INF/context-dev.xml"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
135 overwrite="true">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
136 <filterchain>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
137 <tokenfilter>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
138 <filetokenizer/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
139 <replaceregex
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
140 pattern="&lt;Context.*&gt;"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
141 replace="&lt;Context path=&quot;${web.context.path}&quot; docBase=&quot;@DOCBASE&quot; &gt;"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
142 />
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
143 </tokenfilter>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
144 </filterchain>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
145 </copy>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
146 <replace file="${build.web.dir}/META-INF/context-dev.xml"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
147 token="@DOCBASE"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
148 value="${docBase.dir.name}"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
149 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
150
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
151 <target name="project.undeploy" depends="-project.init-tomcat">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
152 <dirname property="build.web.dir.path" file="${build.web.dir}/WEB-INF"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
153 <undeploy password="${tomcat.password}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
154 url="${tomcat.manager.url}" username="${tomcat.username}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
155 path="${web.context.path}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
156 failonerror="false"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
157 />
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
158 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
159
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
160 <target name="project.deploy" depends="project.undeploy,project.web.context">
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
161 <dirname property="build.web.dir.path" file="${build.web.dir}/WEB-INF"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
162 <deploy password="${tomcat.password}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
163 url="${tomcat.manager.url}" username="${tomcat.username}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
164 path="${web.context.path}"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
165 config="${build.web.dir.path}/META-INF/context-dev.xml"
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
166 />
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
167 <delete file="${build.web.dir.path}/META-INF/context-dev.xml" failonerror="false"/>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
168 </target>
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
169
be1051bf262f add globally common ant scripts
smith@nwoca.org
parents:
diff changeset
170 </project>