langtools/make/netbeans/common/shared.xml
changeset 1944 34c52e8a097b
parent 1943 d3de53b2070d
parent 1879 04b2620edc72
child 1951 17ae6ba5de7a
equal deleted inserted replaced
1943:d3de53b2070d 1944:34c52e8a097b
     1 <?xml version="1.0" encoding="UTF-8"?>
       
     2 <!--
       
     3  Copyright 2007 Sun Microsystems, Inc.  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 Sun Microsystems 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 <!--
       
    34  The file contains targets for NetBeans action that are shared across
       
    35  all langtools projects.
       
    36 -->
       
    37 
       
    38 <project name="shared" default="build" basedir="../../..">
       
    39     <!-- 
       
    40        Instead of importing the main build file, we could call it when needed.
       
    41        That would reduce the list of Ant targets that get displayed for this
       
    42        file, but it also complicates the interface between the project build 
       
    43        file and the main build file. For example, some imported targets
       
    44        would have to be reclared, properties would have to be restructured,
       
    45        and it would be harder to run results (e.g. in properties) from nested 
       
    46        targets.
       
    47      -->
       
    48     <import file="../../build.xml"/> 
       
    49     
       
    50     <property name="tool.mainclass" value="com.sun.tools.${tool.name}.Main"/>
       
    51     <property name="tool.default.args" value="-version"/>
       
    52     
       
    53     <!-- compile a single file -->
       
    54  
       
    55     <!-- for compile-single, etc, we might want different targets for 
       
    56          javac and not javac, because of bootstrap issues -->
       
    57     <target name="compile-single" depends="build-bootstrap-javac">
       
    58         <fail unless="includes">Must set property 'includes'</fail>
       
    59         <javac fork="true" executable="${build.bootstrap.dir}/bin/javac"
       
    60                srcdir="${src.classes.dir}"
       
    61                destdir="${build.classes.dir}"
       
    62                includes="${includes}"
       
    63                sourcepath=""
       
    64                includeAntRuntime="no"
       
    65                target="${target}"
       
    66                debug="${javac.debug}" 
       
    67                debuglevel="${javac.debuglevel}"/>
       
    68     </target>
       
    69     
       
    70     <!-- run tool -->
       
    71     
       
    72     <target name="run" depends="build,-def-run" description="run ${tool.description}">
       
    73         <run/>
       
    74     </target>
       
    75     
       
    76     <!-- run a selected class -->
       
    77     
       
    78     <target name="run-single" depends="-def-run">
       
    79         <fail unless="run.classname">Must set property 'run.classname'</fail>
       
    80         <run name="${run.classname}" mainclass="${run.classname}" default.args=""/>
       
    81     </target>
       
    82     
       
    83     <!-- run jtreg tests, and display results in NetBeans -->
       
    84     
       
    85     <target name="-jtreg-nb" depends="-jtreg" if="netbeans.home" unless="jtreg.passed">
       
    86         <nbbrowse file="${jtreg.report}/report.html"/>
       
    87         <fail>Some tests failed; see report for details.</fail>
       
    88     </target>
       
    89     
       
    90     <!-- debug tool in NetBeans -->
       
    91     
       
    92     <target name="-debug-nb" depends="build,-def-run,-def-start-debugger" if="netbeans.home">
       
    93         <start-debugger/>
       
    94         <run jpda.jvmargs="${jpda.jvmargs}"/>
       
    95     </target>
       
    96     
       
    97     <!-- debug a selected class -->
       
    98     
       
    99     <target name="debug-single-nb" depends="-def-start-debugger,-def-run">
       
   100         <fail unless="debug.classname">Must set property 'debug.classname'</fail>
       
   101         <start-debugger/>
       
   102         <run name="${debug.classname}" mainclass="${debug.classname}" default.args=""
       
   103              jpda.jvmargs="${jpda.jvmargs}"/>
       
   104     </target>
       
   105     
       
   106     <!-- debug a jtreg test -->
       
   107     
       
   108     <target name="debug-jtreg-nb" depends="-def-start-debugger,-def-jtreg"> 
       
   109         <fail unless="jtreg.tests">Must set property 'jtreg.tests'</fail>
       
   110         <start-debugger/>
       
   111         <jtreg-tool name="${tool.name}" samevm="false" tests="${jtreg.tests}" 
       
   112                     jpda.jvmargs="${jpda.jvmargs}"/>
       
   113     </target>
       
   114     
       
   115     <!-- update a class being debugged -->
       
   116     
       
   117     <target name="debug-fix">
       
   118         <fail unless="class">Must set property 'class'</fail>
       
   119         <antcall target="compile-single">
       
   120             <param name="includes" value="${class}.java"/>
       
   121         </antcall>
       
   122         <nbjpdareload>
       
   123             <fileset dir="${build.classes.dir}">
       
   124                 <include name="${class}.class"/>
       
   125             </fileset>
       
   126         </nbjpdareload>
       
   127     </target>
       
   128     
       
   129     
       
   130     <!-- create javadoc documentation -->
       
   131     
       
   132     <target name="-javadoc-nb" depends="-javadoc" if="netbeans.home">
       
   133         <nbbrowse file="${build.javadoc.dir}/${tool.name}/index.html"/>
       
   134     </target>
       
   135     
       
   136     <!-- default target for those projects that don't have public API docs;
       
   137          override as needed for projects with public API docs.-->
       
   138     <target name="-javadoc"/>
       
   139     
       
   140     <!-- macro to run a tool or selected class - used by run* and debug* tasks -->
       
   141     
       
   142     <target name="-def-run">
       
   143         <macrodef name="run">
       
   144             <attribute name="name" default="${tool.name}"/>
       
   145             <attribute name="mainclass" default="${tool.mainclass}"/>
       
   146             <attribute name="default.args" default="${tool.default.args}"/>
       
   147             <attribute name="jpda.jvmargs" default=""/>
       
   148             <sequential>
       
   149                 <input addproperty="run.args" message="Run @{name} with options" defaultvalue="@{default.args}"/>
       
   150                 <java fork="true" jvm="${target.java}" classname="@{mainclass}">
       
   151                     <bootclasspath>
       
   152                         <pathelement location="${build.classes.dir}"/>
       
   153                         <pathelement location="${target.java.home}/jre/lib/rt.jar"/>
       
   154                     </bootclasspath>
       
   155                     <jvmarg line="@{jpda.jvmargs}"/> 
       
   156                     <arg line="${run.args}"/>
       
   157                 </java>
       
   158             </sequential>
       
   159         </macrodef>
       
   160     </target>
       
   161     
       
   162     <!-- macro to start the debugger and set a property containg the args needed by the run task -->
       
   163     
       
   164     <target name="-def-start-debugger" if="netbeans.home">
       
   165         <macrodef name="start-debugger">
       
   166             <attribute name="jpda.jvmargs.property" default="jpda.jvmargs"/>
       
   167             <sequential>
       
   168                 <nbjpdastart name="${ant.project.name}" addressproperty="jpda.address" transport="dt_socket">
       
   169                     <bootclasspath>
       
   170                         <pathelement location="${build.classes.dir}"/>
       
   171                         <pathelement location="${target.java.home}/jre/lib/rt.jar"/>
       
   172                     </bootclasspath>
       
   173                     <sourcepath>
       
   174                         <pathelement location="${src.classes.dir}"/>
       
   175                     </sourcepath>
       
   176                 </nbjpdastart>
       
   177                 <property 
       
   178                     name="@{jpda.jvmargs.property}" 
       
   179                     value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}"
       
   180                 />
       
   181             </sequential>
       
   182         </macrodef>
       
   183     </target>
       
   184     
       
   185     
       
   186 </project>