代码之家  ›  专栏  ›  技术社区  ›  Jonas Byström

如何确定蚂蚁目标?

ant
  •  1
  • Jonas Byström  · 技术社区  · 16 年前

    我想让不同的目标做几乎相同的事情,因此:

    ant build   <- this would be a normal (default) build
    ant safari  <- building the safari target.
    

    目标如下所示:

    <target name="build" depends="javac" description="GWT compile to JavaScript">
      <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
        <classpath>
          <pathelement location="src"/>
          <path refid="project.class.path"/>
        </classpath>
        <jvmarg value="-Xmx256M"/>
        <arg value="${lhs.target}"/>
      </java>
    </target>
    
    <target name="safari" depends="javac" description="GWT compile to Safari/JavaScript">
      <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
        <classpath>
          <pathelement location="src"/>
          <path refid="project.class.path"/>
        </classpath>
        <jvmarg value="-Xmx256M"/>
        <arg value="${lhs.safari.target}"/>
      </java>
    </target>
    

    ant -Dwhatever=nevermind . 有什么想法吗?

    1 回复  |  直到 16 年前
        1
  •  3
  •   Mnementh    16 年前

    <target name="build" depends="javac, create.mymacro" description="GWT compile to JavaScript">
      <mymacro target="${lhs.target}"/>
    </target>
    
    <target name="safari" depends="javac, create.mymacro" description="GWT compile to Safari/JavaScript">
      <mymacro target="${lhs.safari.target}"/>
    </target
    
    <target name="create.mymacro">
      <macrodef name="mymacro">
        <attribute name="target" default="${lhs.target}"/>
        <sequential>
          <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
            <classpath>
              <pathelement location="src"/>
              <path refid="project.class.path"/>
            </classpath>
            <jvmarg value="-Xmx256M"/>
            <arg value="@{target}"/>
         </java>
        </sequential>
      </macrodef>
    </target>
    
    推荐文章