xref: /aoo42x/main/scripting/java/build.xml (revision 33ef1020)
1<!--***********************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 ***********************************************************-->
21
22
23<project name="Scipting Framework" default="all" basedir=".">
24
25  <!-- =================== Environmental Properties ======================= -->
26
27  <property name="prj" value=".."/>
28  <property name="build.compiler"   value="modern"/>
29  <property name="optimize"   value="off"/>
30  <property name="debug"   value="on"/>
31  <property name="jardir" value="${out}/class"/>
32  <property name="bindir" value="${out}/bin"/>
33  <property name="idesupport.dir" value="org/openoffice/idesupport"/>
34  <property name="netbeans.dir" value="org/openoffice/netbeans/modules/office"/>
35  <property name="framework.dir" value="Framework/com/sun/star/script/framework/security"/>
36
37  <!-- Change this property if you are building NetBeans editor support jar.
38       Not needed in default build -->
39  <property name="netbeans.install.path" value="/export/home/netbeans"/>
40
41  <property environment="env"/>
42  <property name="env.BSH_JAR" value="${solar.jar}/bsh.jar"/>
43
44  <target name="eval_environment">
45    <condition property="with_rhino">
46      <equals arg1="${env.ENABLE_JAVASCRIPT}" arg2="YES" />
47    </condition>
48    <condition property="with_beanshell">
49      <equals arg1="${env.ENABLE_BEANSHELL}" arg2="YES" />
50    </condition>
51  </target>
52
53  <!-- ==================== classpath setting ============================ -->
54  <path id="idlclasspath">
55    <pathelement location="${solar.jar}/jurt.jar"/>
56    <pathelement location="${solar.jar}/unoil.jar"/>
57    <pathelement location="${solar.jar}/juh.jar"/>
58    <pathelement location="${solar.jar}/java_uno.jar"/>
59    <pathelement location="${solar.jar}/ridl.jar"/>
60    <pathelement location="${env.BSH_JAR}"/>
61    <pathelement location="${solar.jar}/js.jar"/>
62    <pathelement location="${jardir}"/>
63  </path>
64
65  <path id="idesupport.class.path">
66    <pathelement path="${jardir}"/>
67  </path>
68
69  <path id="openide.class.path">
70    <pathelement path="${jardir}"/>
71    <pathelement path="${solar.jar}/openide.jar"/>
72  </path>
73
74  <path id="netbeans.editor.support.classpath">
75    <pathelement path="${jardir}"/>
76    <pathelement path="${netbeans.install.path}/modules/ext/nb-editor.jar"/>
77  </path>
78
79  <condition property="boot_refID" value="macPath" else="nonMacPath">
80    <and>
81      <os family="mac"/>
82      <os family="unix"/>
83    </and>
84  </condition>
85
86  <path id="mac.apple.java.path" location="${java.home}/../Classes/classes.jar"/>
87  <path id="mac.oracle.java.path" location="${java.home}/lib/rt.jar"/>
88
89  <condition property="mac.java.path" value="mac.oracle.java.path" else ="mac.apple.java.path">
90    <and>
91      <os family="mac"/>
92      <os family="unix"/>
93      <contains string="${java.version}" substring="1.8" casesensitive="false" />
94      <or>
95        <contains string="${java.vendor}" substring="Oracle" casesensitive="false" />
96        <contains string="${java.vendor}" substring="adoptopenjdk" casesensitive="false" />
97        <contains string="${java.vendor}" substring="azul" casesensitive="false" />
98      </or>
99    </and>
100  </condition>
101
102  <path id="macPath" refID="${mac.java.path}"/>
103
104  <!-- rhino.jar from OpenJDK breaks build -->
105  <path id="nonMacPath">
106    <fileset dir="${java.home}/">
107       <include name="jre/lib/*.jar"/>
108       <include name="lib/*.jar"/>
109       <exclude name="jre/lib/rhino.jar"/>
110       <exclude name="lib/rhino.jar"/>
111     </fileset>
112  </path>
113  <path id="my.bootstrap.classpath" refID="${boot_refID}"/>
114
115  <!-- ===================== Prepare Directories ========================= -->
116  <target name="prepare">
117    <mkdir dir="${jardir}"/>
118  </target>
119
120  <!-- ======================== Compile Classes ========================== -->
121  <target name="compile" depends="prepare, eval_environment">
122    <javac srcdir="com" destdir="${jardir}"
123         includes="**/*.java" classpathref="idlclasspath" includeantruntime="false"
124         debug="${debug}" optimize="${optimize}" deprecation="off">
125      <exclude name="**/provider/javascript/*.java" unless="with_rhino" />
126      <exclude name="**/provider/beanshell/*.java" unless="with_beanshell" />
127      <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
128    </javac>
129    <javac srcdir="Framework/" destdir="${jardir}"
130         includes="**/*.java" classpathref="idlclasspath" debug="${debug}"
131         optimize="${optimize}" deprecation="off" includeantruntime="false">
132     <compilerarg value="-Xbootclasspath:${toString:my.bootstrap.classpath}"/>
133    </javac>
134  </target>
135
136  <target name="idesupport.compile" depends="compile, prepare">
137    <javac srcdir="." destdir="${jardir}"
138           debug="${debug}" deprecation="on">
139      <classpath refid="idesupport.class.path"/>
140      <exclude name="${idesupport.dir}/**/.*/*"/>
141      <exclude name="${idesupport.dir}/localoffice/**/*"/>
142      <exclude name="${idesupport.dir}/LocalOffice.java"/>
143      <include name="${idesupport.dir}/*.java"/>
144      <include name="${idesupport.dir}/*/*.java"/>
145    </javac>
146  </target>
147
148  <target name="localoffice.compile" depends="prepare">
149    <javac srcdir="." destdir="${jardir}"
150           debug="${debug}" deprecation="on">
151      <classpath refid="idlclasspath"/>
152      <exclude name="${idesupport.dir}/localoffice/.*/*"/>
153      <include name="${idesupport.dir}/localoffice/*.java"/>
154    </javac>
155  </target>
156
157  <target name="netbeans.compile" depends="idesupport.compile, prepare">
158    <javac srcdir="." destdir="${jardir}"
159           debug="${debug}" deprecation="on">
160      <classpath refid="openide.class.path"/>
161      <exclude name="${netbeans.dir}/**/.*/*"/>
162      <include name="${netbeans.dir}/**/*.java"/>
163    </javac>
164  </target>
165
166  <target name="netbeans.editor.support" depends="prepare">
167    <javac srcdir="." destdir="${jardir}"
168           debug="${debug}" deprecation="on">
169      <classpath refid="netbeans.editor.support.classpath"/>
170      <include name="org/openoffice/netbeans/editor/*.java"/>
171    </javac>
172    <jar jarfile="${jardir}/nb-editorsupport.jar">
173      <fileset dir="${jardir}">
174          <include name="org/openoffice/netbeans/editor/*.class"/>
175      </fileset>
176      <fileset dir=".">
177        <include name="org/openoffice/netbeans/editor/OOo.jcs"/>
178        <include name="org/openoffice/netbeans/editor/OOo.jcb"/>
179      </fileset>
180    </jar>
181  </target>
182
183  <!-- ===================== jar ========================= -->
184  <target name="jar.provider.java" depends="compile">
185    <jar jarfile="${jardir}/ScriptProviderForJava.jar"
186         basedir="${jardir}">
187        <manifest>
188            <attribute name="Built-By" value="Sun Microsystems"/>
189            <attribute name="RegistrationClassName"
190                       value="com.sun.star.script.framework.provider.java.ScriptProviderForJava"/>
191            <attribute name="Class-Path" value="ScriptFramework.jar"/>
192            <attribute name="UNO-Type-Path" value=""/>
193        </manifest>
194        <include name="**/provider/java/*.class"/>
195    </jar>
196  </target>
197
198  <target name="jar.provider.beanshell" depends="compile" if="with_beanshell">
199    <jar jarfile="${jardir}/ScriptProviderForBeanShell.jar"
200         basedir="${jardir}">
201        <manifest>
202            <attribute name="Built-By" value="Sun Microsystems"/>
203            <attribute name="RegistrationClassName"
204                       value="com.sun.star.script.framework.provider.beanshell.ScriptProviderForBeanShell"/>
205            <attribute name="Class-Path" value="ScriptFramework.jar bsh.jar"/>
206            <attribute name="UNO-Type-Path" value=""/>
207        </manifest>
208        <include name="**/provider/beanshell/*.class"/>
209        <fileset dir=".">
210          <include name="**/provider/beanshell/*.bsh"/>
211        </fileset>
212    </jar>
213  </target>
214
215  <target name="jar.provider.javascript" depends="compile" if="with_rhino">
216    <jar jarfile="${jardir}/ScriptProviderForJavaScript.jar"
217         basedir="${jardir}">
218        <manifest>
219            <attribute name="Built-By" value="Sun Microsystems"/>
220            <attribute name="RegistrationClassName"
221                       value="com.sun.star.script.framework.provider.javascript.ScriptProviderForJavaScript"/>
222            <attribute name="Class-Path" value="ScriptFramework.jar js.jar"/>
223            <attribute name="UNO-Type-Path" value=""/>
224        </manifest>
225        <include name="**/provider/javascript/*.class"/>
226        <fileset dir=".">
227          <include name="**/provider/javascript/*.js"/>
228        </fileset>
229    </jar>
230  </target>
231
232  <target name="jar.scriptframework" depends="compile">
233    <jar jarfile="${jardir}/ScriptFramework.jar"
234         basedir="${jardir}">
235        <manifest>
236            <attribute name="Built-By" value="Sun Microsystems"/>
237            <attribute name="RegistrationClassName"
238                       value="com.sun.star.script.framework.security.SecurityDialog"/>
239            <attribute name="UNO-Type-Path" value=""/>
240        </manifest>
241        <include name="**/security/*"/>
242        <include name="**/log/*.class"/>
243        <include name="**/provider/*.class"/>
244        <include name="**/browse/*.class"/>
245        <include name="**/container/*.class"/>
246        <include name="**/io/*.class"/>
247    </jar>
248  </target>
249
250  <target name="jar" depends="jar.provider.java,jar.provider.beanshell,jar.provider.javascript,jar.scriptframework">
251  </target>
252
253  <target name="idesupport.jar" depends="idesupport.compile">
254    <jar jarfile="${jardir}/idesupport.jar">
255      <fileset dir="${jardir}">
256          <include name="${idesupport.dir}/**/*.class"/>
257          <include name="CommandLineTools*"/>
258          <exclude name="${idesupport.dir}/localoffice/*.class"/>
259      </fileset>
260      <fileset dir=".">
261        <include name="${idesupport.dir}/ui/add.gif"/>
262      </fileset>
263    </jar>
264  </target>
265
266  <target name="localoffice.jar" depends="localoffice.compile">
267    <unjar
268      src="${solar.jar}/unoil.jar"
269      dest="${jardir}"/>
270    <jar jarfile="${jardir}/localoffice.jar">
271      <fileset dir="${jardir}">
272        <include name="${idesupport.dir}/localoffice/*.class"/>
273        <include name="drafts/com/sun/star/script/framework/storage/*.class"/>
274      </fileset>
275    </jar>
276  </target>
277
278  <target name="netbeans.jar" depends="netbeans.compile">
279    <jar jarfile="${jardir}/office.jar" manifest="manifest.mf">
280      <fileset dir="${jardir}">
281        <include name="${netbeans.dir}/**/*.class"/>
282        <exclude name="${netbeans.dir}/**/ParcelDescriptorChildren.class"/>
283        <exclude name="${netbeans.dir}/**/ScriptNode.class"/>
284        <include name="${idesupport.dir}/**/*.class"/>
285        <include name="CommandLineTools*"/>
286      </fileset>
287      <fileset dir=".">
288        <include name="${idesupport.dir}/ui/add.gif"/>
289        <include name="${netbeans.dir}/resources/*"/>
290        <include name="${netbeans.dir}/resources/templates/*"/>
291        <include name="${netbeans.dir}/**/Bundle*"/>
292      </fileset>
293    </jar>
294  </target>
295
296  <!-- Uncomment this target when building within NetBeans to reinstall the
297       module.
298  <target name="netbeans.install" depends="netbeans.package">
299    <copy file="${jardir}/localoffice.jar"
300          tofile="${netbeans.home}/modules/ext/localoffice.jar"/>
301    <nbinstaller action="reinstall" module="${jardir}/office.jar"/>
302  </target>
303  -->
304
305  <!-- ====================== Clean Generated Files ===================== -->
306  <target name="clean">
307    <delete file="${jardir}/ScriptProviderForJava.jar"/>
308    <delete file="${jardir}/ScriptProviderForJavaScript.jar"/>
309    <delete file="${jardir}/ScriptProviderForBeanShell.jar"/>
310    <delete file="${jardir}/ScriptFramework.jar"/>
311    <delete file="${jardir}/office.jar"/>
312    <delete file="${jardir}/localoffice.jar"/>
313    <delete file="${jardir}/idesupport.jar"/>
314  </target>
315
316  <!-- ========================= All In One Build ======================= -->
317  <target name="all" depends="jar"/>
318</project>
319