1 <?xml version="1.0" encoding="UTF-8"?> 2 <!-- 3 Copyright (c) 2007, 2010, 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 If langtools.tool.name is set, then just build that tool; otherwise 51 build all tools. 52 --> 53 54 <target name="build" depends="-get-tool-if-set,-build-tool,-build-all" 55 description="Build one or all langtools tools" 56 /> 57 58 <target name="-build-tool" if="langtools.tool.name"> 59 <echo level="info" message="Building ${langtools.tool.name}"/> 60 <echo level="verbose" message="(Unset langtools.tool.name to build all tools)"/> 61 <antcall target="build-${langtools.tool.name}"/> 62 </target> 63 64 <target name="-build-all" unless="langtools.tool.name"> 65 <echo level="info" message="Building all tools"/> 66 <echo level="verbose" message="(Set langtools.tool.name to build a single tool)"/> 67 <antcall target="build-all-tools"/> 68 </target> 69 70 <!-- Compile a single file. (action: compile.single; F9) --> 71 72 <target name="compile-single" depends="build-bootstrap-javac"> 73 <fail unless="includes">Must set property 'includes'</fail> 74 <javac fork="true" executable="${build.bootstrap.dir}/bin/javac" 75 srcdir="${src.classes.dir}" 76 destdir="${build.classes.dir}" 77 includes="${includes}" 78 sourcepath="" 79 includeAntRuntime="no" 80 target="${javac.target}" 81 debug="${javac.debug}" 82 debuglevel="${javac.debuglevel}"/> 83 </target> 84 85 <!-- Run tool. (action: run; F6) 86 Use langtools.tool.name and langtools.tool.args properties if set; otherwise prompt 87 the user. 88 --> 89 90 <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args" 91 description="run tool"> 92 <echo level="info" message="Run ${langtools.tool.name} with args ${langtools.tool.args}"/> 93 <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}"/> 94 </target> 95 96 <!-- Run a selected class. (action: run.single; shift-F6) --> 97 98 <target name="run-single" depends="-check-target.java.home,-def-run"> 99 <fail unless="run.classname">Must set property 'run.classname' </fail> 100 <echo level="info" message="run ${run.classname}"/> 101 <run mainclass="${run.classname}" args=""/> 102 </target> 103 104 <!-- Test project, and display results if tests failed. (action: test; Alt-F6) 105 If langtools.tool.name is set, then just test that tool; otherwise 106 test all tools. 107 --> 108 109 <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all" 110 description="Test one or all langtools tools" 111 /> 112 113 <target name="-jtreg-tool" if="langtools.tool.name"> 114 <echo level="info" message="Testing ${langtools.tool.name}"/> 115 <echo level="verbose" message="(Unset langtools.tool.name to test all tools)"/> 116 <antcall> 117 <target name="jtreg-${langtools.tool.name}"/> 118 <target name="-show-jtreg"/> 119 </antcall> 120 </target> 121 122 <target name="-jtreg-all" unless="langtools.tool.name"> 123 <echo level="info" message="Testing all tools"/> 124 <echo level="verbose" message="(Set langtools.tool.name to test a single tool)"/> 125 <antcall> 126 <target name="langtools.jtreg"/> 127 <target name="-show-jtreg"/> 128 </antcall> 129 </target> 130 131 <target name="-show-jtreg" if="netbeans.home" unless="jtreg.passed"> 132 <nbbrowse file="${jtreg.report}/report.html"/> 133 <fail>Some tests failed; see report for details.</fail> 134 </target> 135 136 <!-- Debug tool in NetBeans. --> 137 138 <target name="debug" depends="-check-target.java.home,-def-run,-def-start-debugger,-get-tool-and-args,build" if="netbeans.home"> 139 <echo level="info" message="Debug ${langtools.tool.name} with args ${langtools.tool.args}"/> 140 <start-debugger/> 141 <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/> 142 </target> 143 144 <!-- Debug a selected class . --> 145 <target name="debug-single" depends="-check-target.java.home,-def-start-debugger,-def-run"> 146 <fail unless="debug.classname">Must set property 'debug.classname'</fail> 147 <start-debugger/> 148 <run mainclass="${debug.classname}" default.args="" jpda.jvmargs="${jpda.jvmargs}"/> 149 </target> 150 151 <!-- Debug a jtreg test. --> 152 <target name="debug-jtreg" depends="-check-target.java.home,-def-start-debugger,-def-jtreg"> 153 <fail unless="jtreg.tests">Must set property 'jtreg.tests'</fail> 154 <start-debugger/> 155 <jtreg-tool name="debug" samevm="false" tests="${jtreg.tests}" jpda.jvmargs="${jpda.jvmargs}"/> 156 </target> 157 158 <!-- Update a class being debugged. --> 159 160 <target name="debug-fix" if="langtools.tool.name"> 161 <fail unless="class">Must set property 'class' 162 </fail> 163 <antcall target="compile-single"> 164 <param name="includes" value="${class}.java"/> 165 </antcall> 166 <nbjpdareload> 167 <fileset dir="${build.classes.dir}"> 168 <include name="${class}.class"/> 169 </fileset> 170 </nbjpdareload> 171 </target> 172 173 <!-- Generate javadoc for one or all tools. (action: javadoc; Alt-F6) 174 If langtools.tool.name is set, then just test that tool; otherwise 175 test all tools. 176 --> 177 178 <target name="javadoc" depends="-javadoc-tool,-javadoc-all" 179 description="Generate javadoc for one or all langtools tools" 180 /> 181 182 <target name="-javadoc-tool" if="langtools.tool.name"> 183 <echo level="info" message="Generate javadoc for ${langtools.tool.name}"/> 184 <echo level="verbose" message="(Unset langtools.tool.name to generate javadoc for all tools)"/> 185 <antcall> 186 <target name="javadoc-${langtools.tool.name}"/> 187 <target name="-show-javadoc"/> 188 </antcall> 189 </target> 190 191 <target name="-javadoc-all" unless="langtools.tool.name"> 192 <echo level="info" message="Generate javadoc for all tools"/> 193 <echo level="verbose" message="(Set langtools.tool.name to generate javadoc for a single tool)"/> 194 <antcall> 195 <target name="langtools.javadoc"/> 196 <target name="-show-javadoc"/> 197 </antcall> 198 </target> 199 200 <target name="-show-javadoc" if="netbeans.home"> 201 <!-- what if doing javadoc for all? --> 202 <nbbrowse file="${build.javadoc.dir}/${langtools.tool.name}/index.html"/> 203 </target> 204 205 <!-- Prompt for values. --> 206 207 <target name="-get-tool-if-set" depends="-def-select-tool"> 208 <select-tool 209 toolproperty="langtools.tool.name" 210 propertyfile="${langtools.properties}" 211 askIfUnset="false" 212 /> 213 </target> 214 215 <target name="-get-tool-and-args" depends="-def-select-tool"> 216 <select-tool 217 toolproperty="langtools.tool.name" 218 argsproperty="langtools.tool.args" 219 propertyfile="${langtools.properties}" 220 askIfUnset="true" 221 /> 222 </target> 223 224 <!-- Macro to run a tool or selected class - used by run* and debug* tasks --> 225 <target name="-def-run"> 226 <macrodef name="run"> 227 <attribute name="mainclass"/> 228 <attribute name="args" default=""/> 229 <attribute name="jpda.jvmargs" default=""/> 230 <sequential> 231 <java fork="true" jvm="${target.java}" classname="@{mainclass}"> 232 <jvmarg line="-Xbootclasspath/p:${build.classes.dir}"/> 233 <jvmarg line="@{jpda.jvmargs}"/> 234 <arg line="@{args}"/> 235 </java> 236 </sequential> 237 </macrodef> 238 </target> 239 240 <!-- Macro to start the debugger and set a property containg the args needed by the run task --> 241 <target name="-def-start-debugger" if="netbeans.home"> 242 <macrodef name="start-debugger"> 243 <attribute name="jpda.jvmargs.property" default="jpda.jvmargs"/> 244 <sequential> 245 <nbjpdastart name="${ant.project.name}" addressproperty="jpda.address" transport="dt_socket"> 246 <bootclasspath> 247 <pathelement location="${build.classes.dir}"/> 248 <pathelement location="${target.java.home}/jre/lib/rt.jar"/> 249 </bootclasspath> 250 <sourcepath> 251 <pathelement location="${src.classes.dir}"/> 252 </sourcepath> 253 </nbjpdastart> 254 <property 255 name="@{jpda.jvmargs.property}" 256 value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}" 257 /> 258 </sequential> 259 </macrodef> 260 </target> 261 262 <target name="-def-select-tool"> 263 <mkdir dir="${build.toolclasses.dir}"/> 264 <javac srcdir="${make.tools.dir}/SelectTool" 265 destdir="${build.toolclasses.dir}/" 266 classpath="${ant.core.lib}" 267 includeantruntime="false" 268 debug="${javac.debug}" 269 debuglevel="${javac.debuglevel}"> 270 <compilerarg line="-Xlint"/> 271 </javac> 272 <taskdef name="select-tool" 273 classname="SelectToolTask" 274 classpath="${build.toolclasses.dir}/"/> 275 </target> 276 277 <target name="select-tool" depends="-def-select-tool"> 278 <select-tool propertyfile="${langtools.properties}"/> 279 </target> 280 </project>