diags-examples.xml revision 3618:64182008b2d0
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3  ~ Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
4  ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  ~
6  ~ This code is free software; you can redistribute it and/or modify it
7  ~ under the terms of the GNU General Public License version 2 only, as
8  ~ published by the Free Software Foundation.  Oracle designates this
9  ~ particular file as subject to the "Classpath" exception as provided
10  ~ by Oracle in the LICENSE file that accompanied this code.
11  ~
12  ~ This code is distributed in the hope that it will be useful, but WITHOUT
13  ~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  ~ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  ~ version 2 for more details (a copy is included in the LICENSE file that
16  ~ accompanied this code).
17  ~
18  ~ You should have received a copy of the GNU General Public License version
19  ~ 2 along with this work; if not, write to the Free Software Foundation,
20  ~ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21  ~
22  ~ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23  ~ or visit www.oracle.com if you need additional information or have any
24  ~ questions.
25  -->
26
27<!--
28This is an extension to the langtools make/build.xml file,
29that provides targets to run the examples that generate
30example diagnostics in different locales.
31
32Usage:
33    ant -f langtools/make/run-examples.xml -Dlangtools.jdk.home=<JDK>
34
35By default, the reports will be generated in langtools/build/diags-examples/report/.
36-->
37
38<project name="diags-examples" default="diags-examples" basedir="..">
39    <import file="build.xml"/>
40
41    <!-- specify working directory for the tool -->
42    <property name="diags.examples.dir" location="${build.dir}/diag-examples"/>
43
44    <!-- compiled classes for the tool -->
45    <property name="diags.examples.classes" location="${diags.examples.dir}/classes}"/>
46
47    <!-- directory for generated reports -->
48    <property name="diags.examples.report" location="${diags.examples.dir}/report"/>
49
50    <!-- default target, generates reports for all available locales -->
51    <target name="diags-examples" depends="run-en_US,run-ja,run-zh_CN"/>
52
53    <!-- generate report for US English locale -->
54    <target name="run-en_US" depends="-build-runner,-def-runner">
55        <mkdir dir="${diags.examples.report}"/>
56        <runner lang="en" country="US" outfile="${diags.examples.report}/en_US.html"/>
57    </target>
58
59    <!-- generate report for Japanese locale -->
60    <target name="run-ja" depends="-build-runner,-def-runner">
61        <mkdir dir="${diags.examples.report}"/>
62        <runner lang="ja" outfile="${diags.examples.report}/ja.html"/>
63    </target>
64
65    <!-- generate report for Mandarin Chinese locale -->
66    <target name="run-zh_CN" depends="-build-runner,-def-runner">
67        <mkdir dir="${diags.examples.report}"/>
68        <runner lang="zh" country="CN" outfile="${diags.examples.report}/zh_CN.html"/>
69    </target>
70
71    <!-- compile the tool that runs the examples -->
72    <target name="-build-runner" depends="build">
73        <mkdir dir="${diags.examples.classes}"/>
74        <javac fork="true"
75            executable="${build.bin}/javac"
76            srcdir="test/tools/javac/diags"
77            destdir="${diags.examples.classes}"
78            includes="ArgTypeCompilerFactory.java,Example.java,FileManager.java,HTMLWriter.java,RunExamples.java,DocCommentProcessor.java"
79            sourcepath=""
80            includeAntRuntime="no"
81            debug="${javac.debug}"
82            debuglevel="${javac.debuglevel}">
83            <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/>
84            <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/>
85            <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/>
86            <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/>
87            <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/>
88            <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/>
89        </javac>
90    </target>
91
92    <!-- define a task to run the tool that runs the examples -->
93    <target name="-def-runner">
94        <macrodef name="runner">
95            <attribute name="lang"/>
96            <attribute name="country" default=""/>
97            <attribute name="outfile"/>
98            <sequential>
99            <java fork="true"
100                  jvm="${langtools.jdk.home}/bin/java"
101                  dir="test/tools/javac/diags"
102                  classpath="${diags.examples.classes};${dist.lib.dir}/javac.jar;${dist.lib.dir}/javap.jar"
103                  classname="RunExamples">
104                <jvmarg value="-Duser.language=@{lang}"/>
105                <jvmarg value="-Duser.country=@{country}"/>
106                <jvmarg value="-Dtest.classes=${diags.examples.classes}"/>
107                <arg value="-examples"/>
108                <arg value="examples"/>
109                <arg value="-o"/>
110                <arg file="@{outfile}"/>
111                <arg value="-showFiles"/>
112                <arg value="-title"/>
113                <arg value="Examples of javac diagnostics"/>
114                <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/>
115                <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/>
116                <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/>
117                <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/>
118                <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/>
119                <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/>
120            </java>
121            </sequential>
122        </macrodef>
123    </target>
124</project>
125