1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. 4 5 Redistribution and use in source and binary forms, with or without 6 modification, are permitted provided that the following conditions 7 are met: 8 9 - Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 12 - Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 - Neither the name of Oracle nor the names of its 17 contributors may be used to endorse or promote products derived 18 from this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 --> 32 33 <project name="langtools-netbeans" default="build" basedir="../../.."> 34 35 <property name="langtools.properties" 36 location="make/netbeans/langtools/nbproject/private/langtools.properties"/> 37 38 <!-- 39 Instead of importing the main build file, we could call it when needed. 40 That would reduce the list of Ant targets that get displayed for this 41 file, but it also complicates the interface between the project build 42 file and the main build file. For example, some imported targets 43 would have to be reclared, properties would have to be restructured, 44 and it would be harder to run results (e.g. in properties) from nested 45 targets. 46 --> 47 <import file="../../build.xml"/> 48 49 <!-- Build project. (action: build; F11) --> 50 51 <!-- Compile a single file. (action: compile.single; F9) --> 52 53 <target name="compile-single" depends="-get-tool-if-set,-check-langtools.jdk.home"> 54 <fail unless="includes">Must set property 'includes'</fail> 55 <mkdir dir="${build.dir}/${module.name}/classes" /> 56 <javac fork="true" executable="${java.home}/bin/javac" 57 srcdir="${basedir}/src/${module.name}/share/classes" 58 destdir="${build.dir}/${module.name}/classes" 59 includes="${includes}" 60 sourcepath="" 61 classpath="${langtools.classes}" 62 includeAntRuntime="no" 63 source="${javac.source}" 64 target="${javac.target}" 65 debug="${javac.debug}" 66 debuglevel="${javac.debuglevel}"> 67 </javac> 68 </target> 69 70 <!-- Run tool. (action: run; F6) 71 Use langtools.tool.name and langtools.tool.args properties if set; otherwise prompt 72 the user. 73 --> 74 75 <target name="run" depends="-check-langtools.jdk.home,-build-classes,-def-run,-get-tool-and-args,-def-resolve-main-class" 76 description="run tool"> 77 <echo level="info" message="Run ${langtools.tool.name} with args ${langtools.tool.args}"/> 78 <resolve-main-class tool.name="${langtools.tool.name}" /> 79 <run mainclass="${langtools.main.class}" args="${langtools.tool.args}"/> 80 </target> 81 82 <target name="-def-resolve-main-class"> 83 <macrodef name="resolve-main-class"> 84 <attribute name="tool.name"/> 85 <sequential> 86 <condition property="langtools.main.class" 87 value="jdk.javadoc.internal.tool.Main" 88 else="${tool.@{tool.name}.main.class}"> 89 <equals arg1="${langtools.tool.name}" arg2="javadoc"/> 90 </condition> 91 </sequential> 92 </macrodef> 93 </target> 94 95 <target name="-build-classes" depends="-get-tool-if-set,-build-classes-all" /> 96 <target name="-build-classes-all"> 97 <antcall target="build-all-classes"/> 98 </target> 99 100 <!-- Run a selected class. (action: run.single; shift-F6) --> 101 102 <target name="run-single" depends="-check-langtools.jdk.home,-def-run"> 103 <fail unless="run.classname">Must set property 'run.classname' </fail> 104 <echo level="info" message="run ${run.classname}"/> 105 <run mainclass="${run.classname}" args=""/> 106 </target> 107 108 <!-- Test project, and display results if tests failed. (action: test; Alt-F6) 109 If langtools.tool.name is set, then just test that tool; otherwise 110 test all tools. 111 --> 112 113 <target name="jtreg" depends="-get-tool-if-set,-jtreg-all" 114 description="Test langtools tools" 115 /> 116 117 <target name="-jtreg-all"> 118 <echo level="info" message="Testing all tools"/> 119 <antcall> 120 <target name="langtools.jtreg"/> 121 <target name="-show-jtreg"/> 122 </antcall> 123 </target> 124 125 <target name="-show-jtreg-single-detect" if="netbeans.home" unless="jtreg.passed"> 126 <dirname property="netbeans.jtreg.tests.dir.temp" file="${jtreg.report}/../work/${jtreg.tests}"/> 127 <basename property="netbeans.jtreg.tests.basename.temp" file="${jtreg.tests}" suffix=".java"/> 128 <property name="netbeans.jtreg.single.jtr" value="${netbeans.jtreg.tests.dir.temp}/${netbeans.jtreg.tests.basename.temp}.jtr"/> 129 <condition property="netbeans.jtreg.single"> 130 <available file="${netbeans.jtreg.single.jtr}" /> 131 </condition> 132 <condition property="netbeans.jtreg.multiple"> 133 <not> 134 <available file="${netbeans.jtreg.single.jtr}" /> 135 </not> 136 </condition> 137 </target> 138 139 <target name="-show-jtreg-single" if="netbeans.jtreg.single" depends="-show-jtreg-single-detect"> 140 <nbbrowse file="${netbeans.jtreg.single.jtr}"/> 141 <fail>Some tests failed; see report for details.</fail> 142 </target> 143 144 <target name="-show-jtreg-multiple" if="netbeans.jtreg.multiple" depends="-show-jtreg-single-detect"> 145 <nbbrowse url="file://${jtreg.report}/html/report.html#Results"/> 146 <fail>Some tests failed; see report for details.</fail> 147 </target> 148 149 <target name="-show-jtreg" depends="-show-jtreg-single-detect,-show-jtreg-single,-show-jtreg-multiple" /> 150 151 <!-- Debug tool in NetBeans. --> 152 153 <target name="debug" depends="-check-langtools.jdk.home,-def-run,-def-start-debugger,-get-tool-and-args,-build-classes,-def-resolve-main-class" if="netbeans.home"> 154 <echo level="info" message="Debug ${langtools.tool.name} with args ${langtools.tool.args}"/> 155 <start-debugger/> 156 <resolve-main-class tool.name="${langtools.tool.name}" /> 157 <run mainclass="${langtools.main.class}" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/> 158 </target> 159 160 <!-- Debug a selected class . --> 161 <target name="debug-single" depends="-check-langtools.jdk.home,-def-start-debugger,-def-run"> 162 <fail unless="debug.classname">Must set property 'debug.classname'</fail> 163 <start-debugger/> 164 <run mainclass="${debug.classname}" args="" jpda.jvmargs="${jpda.jvmargs}"/> 165 </target> 166 167 <!-- Debug a jtreg test. --> 168 <target name="debug-jtreg" depends="-check-langtools.jdk.home,-def-start-debugger,-def-jtreg,-get-tool-if-set"> 169 <fail unless="jtreg.tests">Must set property 'jtreg.tests'</fail> 170 <start-debugger/> 171 <jtreg-tool name="debug" 172 tests="${jtreg.tests}" 173 jpda.jvmargs="${jpda.jvmargs}"/> 174 </target> 175 176 <!-- Update a class being debugged. --> 177 178 <target name="debug-fix" depends="-get-tool-if-set"> 179 <fail unless="class">Must set property 'class' 180 </fail> 181 <antcall target="compile-single"> 182 <param name="includes" value="${class}.java"/> 183 </antcall> 184 <property name="build.classes.dir" value="${build.dir}/${module.name}/classes" /> 185 <nbjpdareload> 186 <fileset dir="${build.classes.dir}"> 187 <include name="${class}.class"/> 188 </fileset> 189 </nbjpdareload> 190 </target> 191 192 <!-- Prompt for values. --> 193 194 <target name="-get-tool-if-set" depends="-def-select-tool"> 195 <select-tool 196 toolproperty="langtools.tool.name" 197 propertyfile="${langtools.properties}" 198 askIfUnset="false" 199 /> 200 </target> 201 202 <target name="-get-tool-and-args" depends="-def-select-tool"> 203 <select-tool 204 toolproperty="langtools.tool.name" 205 argsproperty="langtools.tool.args" 206 propertyfile="${langtools.properties}" 207 askIfUnset="true" 208 /> 209 </target> 210 211 <!-- Macro to run a tool or selected class - used by run* and debug* tasks --> 212 <target name="-def-run"> 213 <macrodef name="run"> 214 <attribute name="mainclass"/> 215 <attribute name="args" default=""/> 216 <attribute name="build.modules" default="${build.modules}"/> 217 <attribute name="jpda.jvmargs" default=""/> 218 219 <sequential> 220 <java fork="true" jvm="${langtools.jdk.home}/bin/java" classname="@{mainclass}"> 221 <jvmarg line="--patch-module=java.compiler=@{build.modules}/java.compiler"/> 222 <jvmarg line="--patch-module=jdk.compiler=@{build.modules}/jdk.compiler"/> 223 <jvmarg line="--patch-module=jdk.javadoc=@{build.modules}/jdk.javadoc"/> 224 <jvmarg line="--patch-module=jdk.jdeps=@{build.modules}/jdk.jdeps"/> 225 <jvmarg line="--patch-module=jdk.jshell=@{build.modules}/jdk.jshell"/> 226 <jvmarg line="@{jpda.jvmargs}"/> 227 <arg line="@{args}"/> 228 </java> 229 </sequential> 230 </macrodef> 231 </target> 232 233 <!-- Macro to start the debugger and set a property containg the args needed by the run task --> 234 <target name="-def-start-debugger" if="netbeans.home"> 235 <macrodef name="start-debugger"> 236 <attribute name="jpda.jvmargs.property" default="jpda.jvmargs"/> 237 <sequential> 238 <nbjpdastart name="${ant.project.name}" addressproperty="jpda.address" transport="dt_socket"> 239 <bootclasspath> 240 <pathelement path="${langtools.classes}"/> 241 </bootclasspath> 242 </nbjpdastart> 243 <property 244 name="@{jpda.jvmargs.property}" 245 value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}" 246 /> 247 </sequential> 248 </macrodef> 249 </target> 250 251 <target name="-def-select-tool"> 252 <property name="build.toolclasses.dir" location="${build.dir}/toolclasses"/> 253 <mkdir dir="${build.toolclasses.dir}"/> 254 <javac srcdir="${make.tools.dir}" 255 includes="anttasks/SelectTool*" 256 destdir="${build.toolclasses.dir}/" 257 classpath="${ant.core.lib}" 258 includeantruntime="false" 259 debug="${javac.debug}" 260 debuglevel="${javac.debuglevel}"> 261 <compilerarg line="-Xlint"/> 262 </javac> 263 <taskdef name="select-tool" 264 classname="anttasks.SelectToolTask" 265 classpath="${build.toolclasses.dir}/"/> 266 </target> 267 268 <target name="select-tool" depends="-def-select-tool"> 269 <select-tool propertyfile="${langtools.properties}"/> 270 </target> 271 </project>