xref: /trunk/main/scripting/java/build.xml (revision d50e6300ed5b8be0550f94083e200ad57701b168)
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="Scripting 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    </javac>
128    <javac srcdir="Framework/" destdir="${jardir}"
129         includes="**/*.java" classpathref="idlclasspath" debug="${debug}"
130         optimize="${optimize}" deprecation="off" includeantruntime="false">
131    </javac>
132  </target>
133
134  <target name="idesupport.compile" depends="compile, prepare">
135    <javac srcdir="." destdir="${jardir}"
136           debug="${debug}" deprecation="on">
137      <classpath refid="idesupport.class.path"/>
138      <exclude name="${idesupport.dir}/**/.*/*"/>
139      <exclude name="${idesupport.dir}/localoffice/**/*"/>
140      <exclude name="${idesupport.dir}/LocalOffice.java"/>
141      <include name="${idesupport.dir}/*.java"/>
142      <include name="${idesupport.dir}/*/*.java"/>
143    </javac>
144  </target>
145
146  <target name="localoffice.compile" depends="prepare">
147    <javac srcdir="." destdir="${jardir}"
148           debug="${debug}" deprecation="on">
149      <classpath refid="idlclasspath"/>
150      <exclude name="${idesupport.dir}/localoffice/.*/*"/>
151      <include name="${idesupport.dir}/localoffice/*.java"/>
152    </javac>
153  </target>
154
155  <target name="netbeans.compile" depends="idesupport.compile, prepare">
156    <javac srcdir="." destdir="${jardir}"
157           debug="${debug}" deprecation="on">
158      <classpath refid="openide.class.path"/>
159      <exclude name="${netbeans.dir}/**/.*/*"/>
160      <include name="${netbeans.dir}/**/*.java"/>
161    </javac>
162  </target>
163
164  <target name="netbeans.editor.support" depends="prepare">
165    <javac srcdir="." destdir="${jardir}"
166           debug="${debug}" deprecation="on">
167      <classpath refid="netbeans.editor.support.classpath"/>
168      <include name="org/openoffice/netbeans/editor/*.java"/>
169    </javac>
170    <jar jarfile="${jardir}/nb-editorsupport.jar">
171      <fileset dir="${jardir}">
172          <include name="org/openoffice/netbeans/editor/*.class"/>
173      </fileset>
174      <fileset dir=".">
175        <include name="org/openoffice/netbeans/editor/OOo.jcs"/>
176        <include name="org/openoffice/netbeans/editor/OOo.jcb"/>
177      </fileset>
178    </jar>
179  </target>
180
181  <!-- ===================== jar ========================= -->
182  <target name="jar.provider.java" depends="compile">
183    <jar jarfile="${jardir}/ScriptProviderForJava.jar"
184         basedir="${jardir}">
185        <manifest>
186            <attribute name="Built-By" value="Sun Microsystems"/>
187            <attribute name="RegistrationClassName"
188                       value="com.sun.star.script.framework.provider.java.ScriptProviderForJava"/>
189            <attribute name="Class-Path" value="ScriptFramework.jar"/>
190            <attribute name="UNO-Type-Path" value=""/>
191        </manifest>
192        <include name="**/provider/java/*.class"/>
193    </jar>
194  </target>
195
196  <target name="jar.provider.beanshell" depends="compile" if="with_beanshell">
197    <jar jarfile="${jardir}/ScriptProviderForBeanShell.jar"
198         basedir="${jardir}">
199        <manifest>
200            <attribute name="Built-By" value="Sun Microsystems"/>
201            <attribute name="RegistrationClassName"
202                       value="com.sun.star.script.framework.provider.beanshell.ScriptProviderForBeanShell"/>
203            <attribute name="Class-Path" value="ScriptFramework.jar bsh.jar"/>
204            <attribute name="UNO-Type-Path" value=""/>
205        </manifest>
206        <include name="**/provider/beanshell/*.class"/>
207        <fileset dir=".">
208          <include name="**/provider/beanshell/*.bsh"/>
209        </fileset>
210    </jar>
211  </target>
212
213  <target name="jar.provider.javascript" depends="compile" if="with_rhino">
214    <jar jarfile="${jardir}/ScriptProviderForJavaScript.jar"
215         basedir="${jardir}">
216        <manifest>
217            <attribute name="Built-By" value="Sun Microsystems"/>
218            <attribute name="RegistrationClassName"
219                       value="com.sun.star.script.framework.provider.javascript.ScriptProviderForJavaScript"/>
220            <attribute name="Class-Path" value="ScriptFramework.jar js.jar"/>
221            <attribute name="UNO-Type-Path" value=""/>
222        </manifest>
223        <include name="**/provider/javascript/*.class"/>
224        <fileset dir=".">
225          <include name="**/provider/javascript/*.js"/>
226        </fileset>
227    </jar>
228  </target>
229
230  <target name="jar.scriptframework" depends="compile">
231    <jar jarfile="${jardir}/ScriptFramework.jar"
232         basedir="${jardir}">
233        <manifest>
234            <attribute name="Built-By" value="Sun Microsystems"/>
235            <attribute name="RegistrationClassName"
236                       value="com.sun.star.script.framework.security.SecurityDialog"/>
237            <attribute name="UNO-Type-Path" value=""/>
238        </manifest>
239        <include name="**/security/*"/>
240        <include name="**/log/*.class"/>
241        <include name="**/provider/*.class"/>
242        <include name="**/browse/*.class"/>
243        <include name="**/container/*.class"/>
244        <include name="**/io/*.class"/>
245    </jar>
246  </target>
247
248  <target name="jar" depends="jar.provider.java,jar.provider.beanshell,jar.provider.javascript,jar.scriptframework">
249  </target>
250
251  <target name="idesupport.jar" depends="idesupport.compile">
252    <jar jarfile="${jardir}/idesupport.jar">
253      <fileset dir="${jardir}">
254          <include name="${idesupport.dir}/**/*.class"/>
255          <include name="CommandLineTools*"/>
256          <exclude name="${idesupport.dir}/localoffice/*.class"/>
257      </fileset>
258      <fileset dir=".">
259        <include name="${idesupport.dir}/ui/add.gif"/>
260      </fileset>
261    </jar>
262  </target>
263
264  <target name="localoffice.jar" depends="localoffice.compile">
265    <unjar
266      src="${solar.jar}/unoil.jar"
267      dest="${jardir}"/>
268    <jar jarfile="${jardir}/localoffice.jar">
269      <fileset dir="${jardir}">
270        <include name="${idesupport.dir}/localoffice/*.class"/>
271        <include name="drafts/com/sun/star/script/framework/storage/*.class"/>
272      </fileset>
273    </jar>
274  </target>
275
276  <target name="netbeans.jar" depends="netbeans.compile">
277    <jar jarfile="${jardir}/office.jar" manifest="manifest.mf">
278      <fileset dir="${jardir}">
279        <include name="${netbeans.dir}/**/*.class"/>
280        <exclude name="${netbeans.dir}/**/ParcelDescriptorChildren.class"/>
281        <exclude name="${netbeans.dir}/**/ScriptNode.class"/>
282        <include name="${idesupport.dir}/**/*.class"/>
283        <include name="CommandLineTools*"/>
284      </fileset>
285      <fileset dir=".">
286        <include name="${idesupport.dir}/ui/add.gif"/>
287        <include name="${netbeans.dir}/resources/*"/>
288        <include name="${netbeans.dir}/resources/templates/*"/>
289        <include name="${netbeans.dir}/**/Bundle*"/>
290      </fileset>
291    </jar>
292  </target>
293
294  <!-- Uncomment this target when building within NetBeans to reinstall the
295       module.
296  <target name="netbeans.install" depends="netbeans.package">
297    <copy file="${jardir}/localoffice.jar"
298          tofile="${netbeans.home}/modules/ext/localoffice.jar"/>
299    <nbinstaller action="reinstall" module="${jardir}/office.jar"/>
300  </target>
301  -->
302
303  <!-- ====================== Clean Generated Files ===================== -->
304  <target name="clean">
305    <delete file="${jardir}/ScriptProviderForJava.jar"/>
306    <delete file="${jardir}/ScriptProviderForJavaScript.jar"/>
307    <delete file="${jardir}/ScriptProviderForBeanShell.jar"/>
308    <delete file="${jardir}/ScriptFramework.jar"/>
309    <delete file="${jardir}/office.jar"/>
310    <delete file="${jardir}/localoffice.jar"/>
311    <delete file="${jardir}/idesupport.jar"/>
312  </target>
313
314  <!-- ========================= All In One Build ======================= -->
315  <target name="all" depends="jar"/>
316</project>
317