在eclipse中调试ant任务

如果要在gameGarden下开发游戏的话,因为游戏会运行在sandbox中,服务端和客户端都将用ant任务来启动,这给开发调试带来了很多的困难。下面介绍一种可以在eclipse中调试ant任务的方法。

 

首先在build.xml中复制server任务到一个新的任务,比如叫做server-debug,在启动虚拟机的时候加入下面的这条语句。

 

<jvmarg value="-Xrunjdwp:transport=dt_socket,address=5005,server=y"/>

 

  <!-- a target for running the game server in debug mode -->
  <target name="server-debug" depends="compile" description="Runs a test server.">
    <propertyfile file="${deploy.dir}/classes/toybox.properties">
      <entry key="resource_dir" value="${deploy.dir}"/>
      <entry key="resource_url" value="file://${deploy.dir}"/>
    </propertyfile>
    <!-- we have to convert basedir to forward slashes to make it work as a URL -->
    <path id="codedir"><pathelement location="${basedir}/../lib"/></path>
    <pathconvert targetos="unix" property="basedir.unix" refid="codedir"/>
    <!-- we also have to stick an extra / in front of basedir.unix to make -->
    <!-- things work on windows, fortunately it does not booch things on unix -->
    <echo file="${deploy.dir}/server.policy">
      grant codeBase "file:///${basedir.unix}/../lib/-" {
          permission java.security.AllPermission;
      };
    </echo>
    <java classname="com.threerings.toybox.server.ToyBoxServer" fork="true">
      <classpath refid="classpath"/>
      <sysproperty key="java.security.manager" value=""/>
      <sysproperty key="java.security.policy" value="${deploy.dir}/server.policy"/>
      <sysproperty key="game_conf" value="${app.name}.xml"/>
      <jvmarg value="-Xrunjdwp:transport=dt_socket,address=5005,server=y"/>
    </java>
    <delete file="${deploy.dir}/classes/toybox.properties"/>
    <delete file="${deploy.dir}/server.policy"/>
  </target>  

 

这时候在eclipse中调出ant视图,运行该server-debug任务,这会儿只会在控制台会输出

 

Buildfile: D:\Java\threerings\gardens\projects\games\five\build.xml
prepare:
compile:
server-debug:
[propertyfile] Updating property file: D:\Java\threerings\gardens\projects\games\five\dist\classes\toybox.properties
     [java] Listening for transport dt_socket at address: 5005

 

 

然后在菜单中选择run-->debug configurations...选择remote java application,在port这一栏里填入前面加到jvm参数中的5005,再点击apply和debug,这时候在控制台就会正常输出,并且可以加入断点调试了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值