Salome HOME
Copyrights update 2015.
[tools/siman.git] / Workspace / Siman / build.xml
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <project name="Siman-War" default="build-war">
3
4         <property environment="env" />
5
6         <property file="build.properties" description="set the build parameters" />
7         <property file="../${siman-common.project.name}/build.properties" description="set the build parameters" />
8         <property file="../${splat.project.name}/build.properties" description="set the build parameters" />
9
10         <property name="time.simple.pattern" value="dd/MM/yyyy" />
11         <tstamp>
12                 <format property="datesimple" pattern="${time.simple.pattern}" />
13         </tstamp>
14
15         <property name="time.pattern" value="hh:mm:ss" />
16         <tstamp>
17                 <format property="time" pattern="${time.pattern}" />
18         </tstamp>
19
20         <!-- ================================================= -->
21         <!--    launcher: Build launcher jar                   -->
22         <!-- ================================================= -->
23         <target name="launcher" depends="compile-java" description="Builds launcher jar">
24                 <delete file="${siman.content.dir}/jap/splat-launcher.jar" />
25                 <jar destfile="${siman.content.dir}/jap/splat-launcher.jar">
26                         <zipfileset dir="${siman.bin.dir}/classes">
27                                 <include name="org/splat/launcher/**" />
28                         </zipfileset>
29                         <manifest>
30                 <attribute name="Built-By" value="${app.author}" />
31                 <attribute name="Version" value="${app.version}" />
32                                 <attribute name="Built-Date" value="${datesimple}" />
33                         </manifest>
34                 </jar>
35         </target>
36         
37         <!-- ================================================= -->
38         <!--    launcher: Sign launcher jar                    -->
39         <!-- ================================================= -->
40         <target name="sign-launcher" depends="launcher" description="Signs launcher jar">
41                 <!-- jarsigner -verbose -keystore launcherkeystore -signedjar splat-signedlauncher.jar splat-launcher.jar launcheralias-->
42                 <delete file="${siman.content.dir}/jap/splat-signedlauncher.jar" />
43                 <signjar verbose="on" keystore="${siman.content.dir}/jap/launcherkeystore" signedjar="${siman.content.dir}/jap/splat-signedlauncher.jar" jar="${siman.content.dir}/jap/splat-launcher.jar" alias="launcheralias" storepass="launcher" />
44         </target>
45
46         <!-- ================================================= -->
47         <!--    siman-common: Build Siman-Common project       -->
48         <!-- ================================================= -->
49         <target name="siman-common" description="Builds Siman-Common project">
50                 <ant dir="../${siman-common.project.name}" />
51         </target>
52
53         <!-- ================================================= -->
54         <!--    copy-config: Copy parametrized config files        -->
55         <!-- ================================================= -->
56         <macrodef name="copy-config">
57                 <!-- Parameter "mode" can be equal to "debug" or "release" -->
58                 <attribute name="mode" />
59                 <sequential>
60                         <echo message="Generating configuration in @{mode} mode" />
61                         <!-- Copy files from config source directory according to the given mode -->
62             <loadfile property="customer" srcfile="${config.src.dir}/customer.txt"/>
63             <loadfile property="som" srcfile="${config.src.dir}/${customer}_som.properties"/>
64                         <echo message="som: ${som}"/>
65             <loadfile property="som.en" srcfile="${config.src.dir}/${customer}_som_en.properties"/>
66                         <copy todir="${basedir}/${config.@{mode}.dir}" overwrite="true">
67                                 <fileset dir="${config.src.dir}/templates">
68                                 </fileset>
69                                 <!-- Transform the files from templates substituting properties values -->
70                                 <filterset>
71                     <filter token="som" value="${som}" />
72                     <filter token="som.en" value="${som.en}" />
73                     <filter token="datesimple" value="${datesimple}" />
74                                         <filter token="time" value="${time}" />
75                                         <!-- Get properties to substitute according to the given mode -->
76                                         <filtersfile file="${config.src.dir}/@{mode}.properties" />
77                                         <!-- Substitute the complete config source directory path value in files -->
78                                         <filter token="config.src.dir" value="${basedir}${file.separator}${config.src.dir}${file.separator}templates" />
79                                 </filterset>
80                         </copy>
81                 </sequential>
82         </macrodef>
83
84         <!-- ================================================= -->
85         <!--  debug-config: Generate parametrized config files -->
86         <!-- ================================================= -->
87         <target name="debug-config" description="Generate parametrized debug config files">
88                 <copy-config mode="debug" />
89         </target>
90
91         <!-- =================================================== -->
92         <!--  release-config: Generate parametrized config files -->
93         <!-- =================================================== -->
94         <target name="release-config" description="Generate parametrized release config files">
95                 <copy-config mode="release" />
96         </target>
97
98         <!-- ===================================================================== -->
99         <!-- compile-java : compile the java classes                               -->
100         <!-- ===================================================================== -->
101         <target name="compile-java" depends="clean, siman-common" description="Builds the java classes">
102                 <echo message="Compile Siman java classes" />
103                 <!--            <delete dir="${siman.bin.dir}/temp" quiet="true"/>-->
104                 <mkdir dir="temp" />
105                 <javac target="1.6" srcdir="${siman.src.dir}" destdir="temp" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memoryMaximumSize="${compiler.max.memory}" optimize="${compiler.optimize}" deprecation="${compiler.deprecation}">
106                         <classpath>
107                                 <fileset dir="${basedir}/../${siman-common.project.name}/${siman-common.ext.dir}" includes="**/*" />
108                                 <fileset dir="${basedir}/../${splat.project.name}/${splat.dist.dir}" includes="**/*" />
109                                 <fileset dir="${basedir}/../${splat.project.name}/${splat.lib.dir}" includes="**/*" />
110                                 <fileset dir="${basedir}/../${siman-common.project.name}/${siman-common.dist.dir}" includes="**/*" />
111                                 <fileset dir="${basedir}/../${siman-common.project.name}/${siman-common.lib.dir}" includes="**/*" />
112                                 <fileset dir="${siman.content.dir}/WEB-INF/lib" includes="**/*" />
113                         </classpath>
114                         <exclude name="test/**" />
115                 </javac>
116         </target>
117
118         <!-- ===================================================================== -->
119         <!-- build-dist : Create the war file                                                      -->
120         <!-- ===================================================================== -->
121         <target name="build-war" depends="clean, sign-launcher, launcher, siman-common, compile-java, release-config" description="Builds the WAR distribution">
122                 <echo message="build ${webapp.name}.war" />
123
124                 <mkdir dir="${siman.dist.dir}" />
125                 <war destfile="${siman.dist.dir}/${webapp.name}.war" webxml="${basedir}/${siman.content.dir}/WEB-INF/web.xml">
126                         <fileset dir="${siman.content.dir}" />
127                         <!-- Copy all sources except those which should be generated -->
128                         <classes dir="${siman.bin.dir}/classes">
129                                 <present present="srconly" targetdir="${config.release.dir}" />
130                         </classes>
131                         <!-- Copy generated sources -->
132                         <zipfileset dir="${config.release.dir}" prefix="WEB-INF/classes" />
133                         <manifest>
134                                 <attribute name="Built-By" value="${app.author}" />
135                                 <attribute name="Version" value="${app.version}" />
136                                 <attribute name="Built-Date" value="${datesimple}" />
137                         </manifest>
138                         <lib dir="${basedir}/../${siman-common.project.name}/${siman-common.dist.dir}" includes="**/*.jar" />
139                         <lib dir="${basedir}/../${siman-common.project.name}/${siman-common.lib.dir}" includes="**/*.jar" />
140                         <lib dir="${basedir}/../${splat.project.name}/${splat.dist.dir}" includes="**/*.jar" />
141                         <lib dir="${basedir}/../${splat.project.name}/${splat.lib.dir}" includes="**/*.jar" />
142                 </war>
143         </target>
144
145         <!-- ================================================= -->
146         <!--    clean: Clean the dist directory                            -->
147         <!-- ================================================= -->
148         <target name="clean" description="clean the build directory">
149                 <echo message="deleting files in ${siman.dist.dir}" />
150                 <delete includeemptydirs="true" failonerror="false">
151                         <fileset dir="${siman.dist.dir}" includes="**/*" />
152                 </delete>
153         </target>
154
155     <!-- ================================================= -->
156     <!--    prepare-postgres: Prepare config for Postgress -->
157     <!-- ================================================= -->
158     <target name="prepare-postgres" description="prepare configuration for Postgress">
159         <echo message="Prepare configuration for Postgress..." />
160         <copy file="${config.src.dir}/debug_pg.properties" tofile="${config.src.dir}/debug.properties" overwrite="true"/>
161         <copy file="${config.src.dir}/release_pg.properties" tofile="${config.src.dir}/release.properties" overwrite="true"/>
162         <antcall target="debug-config"/>
163     </target>
164         
165     <!-- ================================================= -->
166     <!--    prepare-postgres: Prepare config for MySql     -->
167     <!-- ================================================= -->
168     <target name="prepare-mysql" description="prepare configuration for MySql">
169         <echo message="Prepare configuration for MySql..." />
170         <copy file="${config.src.dir}/debug_mysql.properties" tofile="${config.src.dir}/debug.properties" overwrite="true"/>
171         <copy file="${config.src.dir}/release_mysql.properties" tofile="${config.src.dir}/release.properties" overwrite="true"/>
172         <antcall target="debug-config"/>
173     </target>
174
175     <!-- ================================================= -->
176     <!--    prepare-customer: Prepare config for the given customer -->
177     <!-- ================================================= -->
178     <macrodef name="prepare-customer">
179         <!-- Parameter "customer" can be equal to "cea" or "edf" -->
180         <attribute name="customer" />
181         <sequential>
182             <echo message="Prepare config for the customer @{customer}" />
183             <echo message="@{customer}" file="${config.src.dir}/customer.txt"/>
184             <copy file="${config.src.dir}/@{customer}_som.xml" tofile="WebContent/conf/som.xml" overwrite="true"/>
185             <antcall target="debug-config"/>
186         </sequential>
187     </macrodef>
188         
189     <!-- ================================================= -->
190     <!--    prepare-cea: Prepare config for CEA            -->
191     <!-- ================================================= -->
192     <target name="prepare-cea" description="prepare configuration for CEA">
193         <echo message="Prepare configuration for CEA..." />
194         <prepare-customer customer="cea" />
195     </target>
196
197     <!-- ================================================= -->
198     <!--    prepare-cea: Prepare config for EDF            -->
199     <!-- ================================================= -->
200     <target name="prepare-edf" description="prepare configuration for EDF">
201         <echo message="Prepare configuration for EDF..." />
202         <prepare-customer customer="edf" />
203     </target>
204 </project>