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