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