Cloudbar variables and loginUrl are configurable through runtime.properties and build.xml
[pithos-web-client] / build.xml
1 <?xml version="1.0" encoding="utf-8" ?>
2 <project name="pithos" default="main" basedir=".">
3         <description>The Pithos web client project build file</description>
4
5         <property file="build.properties"/>
6         <property file="runtime.properties"/>
7     <property name="deps.dir" value="dependencies"/>
8
9     <property name="gwt.workers" value="1"/>
10
11     <property name="gwt.version" value="2.4.0"/>
12         <property name="gwt.home" value="${deps.dir}/gwt-${gwt.version}"/>
13     <property name="gwt.filename" value="gwt-${gwt.version}.zip"/>
14     <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/${gwt.filename}"/>
15
16     <property name="gwt.module.class" value="Pithos" />
17     <property name="gwt.root.package" value="gr.grnet.pithos.web" />
18     <property name="gwt.root.path" value="gr/grnet/pithos/web" />
19     <property name="gwt.module" value="${gwt.root.package}.${gwt.module.class}" />
20
21         <property name="src.dir" value="${basedir}/src"/>
22
23         <!-- Build dirs -->
24         <property name="build.dir" value="${basedir}/bin" />
25         <property name="build.classes.dir" value="${build.dir}/classes" />
26         <property name="gwt.www.dir" value="${build.dir}/www" />
27         <property name="gwt.www.admin.dir" value="${build.dir}/wwwadmin" />
28         <property name="dist.war" value="${ant.project.name}.war"/>
29         <property name="war.dir" value="${basedir}/war" />
30         <property name="war.web-inf.dir" value="${war.dir}/WEB-INF"/>
31         <property name="war.lib.dir" value="${war.web-inf.dir}/lib"/>
32
33         <!-- set classpath -->
34         <path id="project.class.path">
35         <pathelement location="${gwt.home}/gwt-user.jar"/>
36         </path>
37
38         <target name="check-dependencies" description="Checks if all dependencies are present">
39         <condition property="dependencies.present">
40             <and>
41                 <available file="${gwt.home}" type="dir"/>
42             </and>
43         </condition>
44         <echo message="dependencies.present=${dependencies.present}"/>
45     </target>
46
47     <target name="fetch-dependencies" unless="dependencies.present" description="Fetch the dpendencies if not present" depends="check-dependencies">
48         <mkdir dir="${deps.dir}"/>
49         <get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
50         <unzip src="${deps.dir}/${gwt.filename}" dest="${gwt.home}/.."/>
51     </target>
52
53         <target name="check-gwt-compile" description="Checks is the web gwt client sources are up-to-date with the compiled artifacts">
54                 <uptodate property="compilation-not-needed">
55                         <srcfiles dir="${src.dir}">
56                 <include name="${gwt.root.path}/**"/>
57             </srcfiles>
58                         <mergemapper to="${gwt.www.dir}/${gwt.module}/${gwt.module}.nocache.js"/>
59                 </uptodate>
60         </target>
61
62         <target name="gwt-compile" depends="check-gwt-compile, fetch-dependencies" unless="compilation-not-needed" description="Compile the gwt web client code to JavaScript">
63                 <java classname="com.google.gwt.dev.Compiler" failonerror="true" fork="true">
64                         <arg value="-localWorkers" />
65                         <arg value="${gwt.workers}" />
66                         <arg value="-war"/>
67                         <arg value="${gwt.www.dir}"/>
68                         <arg value="${gwt.module}"/>
69                         
70                     <classpath>
71                 <pathelement path="${gwt.home}/gwt-dev.jar"/>
72                 <pathelement path="${gwt.home}/gwt-user.jar" />
73                                 <path refid="project.class.path"/>
74                                 <pathelement path="${src.dir}" />
75                     </classpath>
76                 </java>
77         </target>
78     
79     <target name="main" depends="gwt-compile">
80         <!--Fix the index html file variables -->
81             <replaceregexp file="${gwt.www.dir}/${gwt.module}/index.html"
82                            match="CLOUDBAR_ACTIVE_SERVICE = (.*)"
83                            replace="CLOUDBAR_ACTIVE_SERVICE = '${CLOUDBAR_ACTIVE_SERVICE}';"
84                            byline="true"
85             />
86             <replaceregexp file="${gwt.www.dir}/${gwt.module}/index.html"
87                            match="CLOUDBAR_LOCATION = (.*)"
88                            replace="CLOUDBAR_LOCATION = &quot;${CLOUDBAR_LOCATION}&quot;;"
89                            byline="true"
90             />
91             <replaceregexp file="${gwt.www.dir}/${gwt.module}/index.html"
92                            match="CLOUDBAR_SERVICES = (.*)"
93                            replace="CLOUDBAR_SERVICES = &quot;${CLOUDBAR_SERVICES}&quot;;"
94                            byline="true"
95             />
96             <replaceregexp file="${gwt.www.dir}/${gwt.module}/index.html"
97                            match="CLOUDBAR_MENU = (.*)"
98                            replace="CLOUDBAR_MENU = &quot;${CLOUDBAR_MENU}&quot;;"
99                            byline="true"
100             />
101             <replaceregexp file="${gwt.www.dir}/${gwt.module}/index.html"
102                            match="loginUrl: (.*)"
103                            replace="loginUrl: &quot;${loginUrl}&quot;"
104                            byline="true"
105             />
106     </target>
107
108     <target name="uploadToVM" depends="main">
109         <scp todir="chstath@pithos.dev.grnet.gr:/var/www/pithos_web_client" keyfile="${ssh.key}" passphrase="${passphrase}">
110             <fileset dir="${gwt.www.dir}/${gwt.module}"/>
111         </scp>
112     </target>
113
114     <target name="uploadCSSToVM">
115         <scp todir="chstath@pithos.dev.grnet.gr:/var/www/pithos_web_client" keyfile="${ssh.key}" passphrase="${passphrase}">
116             <fileset dir="${src.dir}/${gwt.root.path}/public" includes="pithos.css"/>
117         </scp>
118     </target>
119
120         <target name="clean" description="Delete all build artifacts">
121                 <delete dir="${build.dir}"/>
122         </target>
123
124     <target name="distclean" depends="clean" description="Delete all downloaded dependencies">
125         <delete dir="${deps.dir}"/>
126     </target>
127
128     <target name="run-web-dev-mode" description="Run web client in development mode">
129         <java fork="true" classname="com.google.gwt.dev.DevMode" spawn="true">
130             <classpath>
131                 <pathelement location="${src.dir}"/>
132                 <pathelement location="${build.classes.dir}"/>
133                 <pathelement path="${gwt.home}/gwt-dev.jar"/>
134                 <pathelement path="${gwt.home}/gwt-user.jar" />
135                 <path refid="project.class.path"/>
136             </classpath>
137             <jvmarg value="-Xmx256M"/>
138             <jvmarg value="-Xdebug"/>
139             <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=55555"/>
140             <arg value="-war"/>
141             <arg value="${gwt.www.dir}"/>
142             <arg value="-noserver"/>
143             <arg value="-startupUrl"/>
144             <arg value="http://127.0.0.1:8080/client"/>
145             <arg value="${gwt.module}"/>
146         </java>
147     </target>
148 </project>