免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6712 | 回复: 14
打印 上一主题 下一主题

为什么ant不能指定target [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2005-05-15 18:22 |只看该作者 |倒序浏览
请教一下,为什么我执行
ant run    总是不起着用,build.xml 里有很多个target,可是不管我执行  ant run 还是 ant clean,它都是重头做到尾

  1. <?xml version="1.0"?>;

  2. <!-- ======================================================================= -->;
  3. <!-- JBoss build file                                                       -->;
  4. <!-- ======================================================================= -->;

  5. <project name="JBossEJB3" default="run" basedir=".">;

  6.    <property environment="env"/>;
  7.    <property name="src.dir" value="${basedir}/src"/>;
  8.    <property name="jboss.home" value="${env.JBOSS_HOME}"/>;
  9.    <property name="build.dir" value="${basedir}/build"/>;
  10.    <property name="build.classes.dir" value="${build.dir}/classes"/>;

  11.    <!-- Build classpath -->;
  12.    <path id="classpath">;
  13.       <fileset dir="${jboss.home}/lib">;
  14.          <include name="**/*.jar"/>;
  15.       </fileset>;
  16.       <fileset dir="${jboss.home}/server/all/lib">;
  17.          <include name="**/*.jar"/>;
  18.       </fileset>;
  19.       <fileset dir="${jboss.home}/server/all/deploy/ejb3.deployer">;
  20.          <include name="*.jar"/>;
  21.       </fileset>;
  22.       <fileset dir="${jboss.home}/server/all/deploy/jboss-aop-jdk50.deployer">;
  23.          <include name="*.jar"/>;
  24.       </fileset>;
  25.       <pathelement location="${build.classes.dir}"/>;
  26.       <!-- So that we can get jndi.properties for InitialContext -->;
  27.       <pathelement location="${basedir}"/>;
  28.    </path>;

  29.    <property name="build.classpath" refid="classpath"/>;

  30.    <!-- =================================================================== -->;
  31.    <!-- Prepares the build directory                                        -->;
  32.    <!-- =================================================================== -->;
  33.    <target name="prepare">;
  34.       <mkdir dir="${build.dir}"/>;
  35.       <mkdir dir="${build.classes.dir}"/>;
  36.    </target>;

  37.    <!-- =================================================================== -->;
  38.    <!-- Compiles the source code                                            -->;
  39.    <!-- =================================================================== -->;
  40.    <target name="compile" depends="prepare">;
  41.       <javac srcdir="${src.dir}"
  42.          destdir="${build.classes.dir}"
  43.          debug="on"
  44.          deprecation="on"
  45.          optimize="off"
  46.          includes="**">;
  47.          <classpath refid="classpath"/>;
  48.       </javac>;
  49.    </target>;

  50.    <target name="ejbjar" depends="compile">;
  51.       <jar jarfile="build/tutorial.ejb3">;
  52.          <fileset dir="${build.classes.dir}">;
  53.             <include name="**/*.class"/>;
  54.          </fileset>;
  55.       </jar>;
  56.       <copy file="build/tutorial.ejb3" todir="${jboss.home}/server/all/deploy"/>;
  57.    </target>;

  58.    <target name="run" depends="ejbjar">;
  59.       <java classname="org.jboss.tutorial.stateless.client.Client" fork="yes" dir=".">;
  60.          <classpath refid="classpath"/>;
  61.       </java>;
  62.    </target>;

  63.    <!-- =================================================================== -->;
  64.    <!-- Cleans up generated stuff                                           -->;
  65.    <!-- =================================================================== -->;
  66.    <target name="clean.db">;
  67.       <delete dir="${jboss.home}/server/all/data/hypersonic"/>;
  68.    </target>;

  69.    <target name="clean">;
  70.       <delete dir="${build.dir}"/>;
  71.       <delete file="${jboss.home}/server/all/deploy/tutorial.ejb3"/>;
  72.    </target>;


  73. </project>;
复制代码

论坛徽章:
0
2 [报告]
发表于 2005-05-15 18:34 |只看该作者

为什么ant不能指定target

build.xml 贴出来看看

论坛徽章:
0
3 [报告]
发表于 2005-05-15 20:16 |只看该作者

为什么ant不能指定target

  1. <?xml version="1.0"?>;

  2. <!-- ======================================================================= -->;
  3. <!-- JBoss build file                                                       -->;
  4. <!-- ======================================================================= -->;

  5. <project name="JBossEJB3" default="run" basedir=".">;

  6.    <property environment="env"/>;
  7.    <property name="src.dir" value="${basedir}/src"/>;
  8.    <property name="jboss.home" value="${env.JBOSS_HOME}"/>;
  9.    <property name="build.dir" value="${basedir}/build"/>;
  10.    <property name="build.classes.dir" value="${build.dir}/classes"/>;

  11.    <!-- Build classpath -->;
  12.    <path id="classpath">;
  13.       <fileset dir="${jboss.home}/lib">;
  14.          <include name="**/*.jar"/>;
  15.       </fileset>;
  16.       <fileset dir="${jboss.home}/server/all/lib">;
  17.          <include name="**/*.jar"/>;
  18.       </fileset>;
  19.       <fileset dir="${jboss.home}/server/all/deploy/ejb3.deployer">;
  20.          <include name="*.jar"/>;
  21.       </fileset>;
  22.       <fileset dir="${jboss.home}/server/all/deploy/jboss-aop-jdk50.deployer">;
  23.          <include name="*.jar"/>;
  24.       </fileset>;
  25.       <pathelement location="${build.classes.dir}"/>;
  26.       <!-- So that we can get jndi.properties for InitialContext -->;
  27.       <pathelement location="${basedir}"/>;
  28.    </path>;

  29.    <property name="build.classpath" refid="classpath"/>;

  30.    <!-- =================================================================== -->;
  31.    <!-- Prepares the build directory                                        -->;
  32.    <!-- =================================================================== -->;
  33.    <target name="prepare">;
  34.       <mkdir dir="${build.dir}"/>;
  35.       <mkdir dir="${build.classes.dir}"/>;
  36.    </target>;

  37.    <!-- =================================================================== -->;
  38.    <!-- Compiles the source code                                            -->;
  39.    <!-- =================================================================== -->;
  40.    <target name="compile" depends="prepare">;
  41.       <javac srcdir="${src.dir}"
  42.          destdir="${build.classes.dir}"
  43.          debug="on"
  44.          deprecation="on"
  45.          optimize="off"
  46.          includes="**">;
  47.          <classpath refid="classpath"/>;
  48.       </javac>;
  49.    </target>;

  50.    <target name="ejbjar" depends="compile">;
  51.       <jar jarfile="build/tutorial.ejb3">;
  52.          <fileset dir="${build.classes.dir}">;
  53.             <include name="**/*.class"/>;
  54.          </fileset>;
  55.       </jar>;
  56.       <copy file="build/tutorial.ejb3" todir="${jboss.home}/server/all/deploy"/>;
  57.    </target>;

  58.    <target name="run" depends="ejbjar">;
  59.       <java classname="org.jboss.tutorial.stateless.client.Client" fork="yes" dir=".">;
  60.          <classpath refid="classpath"/>;
  61.       </java>;
  62.    </target>;

  63.    <!-- =================================================================== -->;
  64.    <!-- Cleans up generated stuff                                           -->;
  65.    <!-- =================================================================== -->;
  66.    <target name="clean.db">;
  67.       <delete dir="${jboss.home}/server/all/data/hypersonic"/>;
  68.    </target>;

  69.    <target name="clean">;
  70.       <delete dir="${build.dir}"/>;
  71.       <delete file="${jboss.home}/server/all/deploy/tutorial.ejb3"/>;
  72.    </target>;


  73. </project>;
复制代码

论坛徽章:
0
4 [报告]
发表于 2005-05-15 20:32 |只看该作者

为什么ant不能指定target

各们请帮忙看一下到底是什么问题好吗

先谢谢了

论坛徽章:
0
5 [报告]
发表于 2005-05-15 20:51 |只看该作者

为什么ant不能指定target

执行target run肯定要按顺序执行prepare、compile和ejbjar,由depends决定

论坛徽章:
0
6 [报告]
发表于 2005-05-15 22:17 |只看该作者

为什么ant不能指定target

我知道执行 ant run 必须先执行前面几个,可是它执行完前面几个后, run 目标不执行,我查了很多资料都不知道到底是为什么,而且 执行 ant clean  也还是从头开始执行到 target ejbjar 后就不执行了,target  clean 并没有依赖其它的,不知道为什么就是不能执行 clean 而是从头开始但又不执行完。

论坛徽章:
0
7 [报告]
发表于 2005-05-15 22:20 |只看该作者

为什么ant不能指定target

有什么信息输出?

论坛徽章:
0
8 [报告]
发表于 2005-05-15 22:26 |只看该作者

为什么ant不能指定target

一种情况是你前面的步骤中有error,导致run停止执行,另一种可能是run里面已经执行了,但是由于环境有问题,没有得到你想要的结果,你可以在run里面放一些echo看看,有没有输出。

论坛徽章:
0
9 [报告]
发表于 2005-05-15 22:58 |只看该作者

为什么ant不能指定target

现在通过实验,把第一行
<project name="JBossEJB3" default="run" basedir=".">;
中的 default 的值改为 run 时可以 执行 ant run, 改成 clean 后可以执行 ant clean, 为什么会这样呢?

没改的情况下在target run 中加 echo 也没有输出,说明没有执行,而且最后显示 build seccessful

论坛徽章:
0
10 [报告]
发表于 2005-05-17 14:29 |只看该作者

为什么ant不能指定target

请各们看一下好吗?
为什么ant 每次都只能执行 default指定的那个target,
不管里面有多少个target,它都只执行default指定的那个,
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP