ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

java – ant build.xml不存在.构建失败

2019-08-23 17:03:22  阅读:443  来源: 互联网

标签:build-xml java gwt command-prompt ant


我是Ant和GWT的初学者,我正在GWT中创建一个新的Ant项目,遵循GWT页面上提到的步骤:创建一个Ant项目部分下的webAppCreator.我能够成功创建这个项目,但我得到错误build.xml不存在!在命令提示符日志中.即使遵循此处提到的所有步骤,我也无法解决此问题:ant build.xml file doesn’t exist.

这是我的命令提示符日志:

C:\Users\TEST>webAppCreator -junit D:\SELENIUM\junit-4.10.jar -out foo com.example.foo.Foo
Generating from templates: [sample, eclipse, readme, _eclipse-test, _sample-test, ant]
Created directory foo
Created directory foo\src
Created directory foo\src\com\example\foo
Created directory foo\src\com\example\foo\client
Created directory foo\src\com\example\foo\server
Created directory foo\src\com\example\foo\shared
Created directory foo\test
Created directory foo\test\com\example\foo
Created directory foo\war
Created directory foo\war\WEB-INF
Created directory foo\test\com\example\foo\client
Created file foo\src\com\example\foo\Foo.gwt.xml
Created file foo\src\com\example\foo\client\GreetingService.java
Created file foo\src\com\example\foo\client\GreetingServiceAsync.java
Created file foo\src\com\example\foo\client\Foo.java
Created file foo\src\com\example\foo\server\GreetingServiceImpl.java
Created file foo\src\com\example\foo\shared\FieldVerifier.java
Created file foo\war\WEB-INF\web.xml
Created file foo\war\Foo.css
Created file foo\war\Foo.html
Created file foo\war\favicon.ico
Created file foo\.classpath
Created file foo\.project
Created file foo\Foo.launch
Created file foo\README.txt
Created file foo\FooSuite-dev.launch
Created file foo\FooSuite-prod.launch
Created file foo\test\com\example\foo\FooJUnit.gwt.xml
Created file foo\test\com\example\foo\FooSuite.java
Created file foo\test\com\example\foo\client\FooTest.java
Created file foo\build.xml

C:\Users\TEST>ant build
Buildfile: build.xml does not exist!
Build failed

C:\Users\TEST>ant devmode
Buildfile: build.xml does not exist!
Build failed

这是我的build.xml文件:

<?xml version="1.0" encoding="utf-8" ?>
<project name="Foo" default="build" basedir=".">
  <!-- Arguments to gwtc and devmode targets -->
  <property name="gwt.args" value="" />

  <!-- Configure path to GWT SDK -->
  <property name="gwt.sdk" location="D:/GWT/gwt-2.8.1/gwt-2.8.1" />

  <path id="project.class.path">
    <pathelement location="war/WEB-INF/classes"/>
    <pathelement location="${gwt.sdk}/gwt-user.jar"/>
    <pathelement location="${gwt.sdk}/gwt-dev.jar"/>
    <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar"/>
    <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar"/>
    <fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
    <!-- Add any additional non-server libs (such as JUnit) here -->
  </path>

  <target name="libs" description="Copy libs to WEB-INF/lib">
    <mkdir dir="war/WEB-INF/lib" />
    <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
    <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
    <!-- Add any additional server libs that need to be copied -->
  </target>

  <target name="javac" depends="libs" description="Compile java source to bytecode">
    <mkdir dir="war/WEB-INF/classes"/>
    <javac srcdir="src" includes="**" encoding="utf-8"
        destdir="war/WEB-INF/classes"
        source="1.7" target="1.7" nowarn="true"
        debug="true" debuglevel="lines,vars,source">
      <classpath refid="project.class.path"/>
    </javac>
    <copy todir="war/WEB-INF/classes">
      <fileset dir="src" excludes="**/*.java"/>
    </copy>
  </target>

  <target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="512m">
      <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
      </classpath>
      <arg line="-war"/>
      <arg value="war"/>
      <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
      <arg line="${gwt.args}"/>
      <arg value="com.example.foo.Foo"/>
    </java>
  </target>

  <target name="devmode" depends="javac" description="Run development mode (pass -Dgwt.args=-nosuperDevMode to fallback to classic DevMode)">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode" maxmemory="1g">
      <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
        <pathelement location="${gwt.sdk}/gwt-codeserver.jar"/>
      </classpath>
      <arg value="-startupUrl"/>
      <arg value="Foo.html"/>
      <arg line="-war"/>
      <arg value="war"/>
      <!-- Additional arguments like -style PRETTY, -logLevel DEBUG or -nosuperDevMode -->
      <arg line="${gwt.args}"/>
      <arg value="com.example.foo.Foo"/>
      <arg value="com.example.foo.Foo"/>
    </java>
  </target>

  <target name="javac.tests" depends="javac" description="Compiles test code">
    <javac srcdir="test" includes="**" encoding="utf-8"
      source="1.7" target="1.7" nowarn="true"
      destdir="war/WEB-INF/classes"
      debug="true" debuglevel="lines,vars,source">
      <classpath location="D:\SELENIUM\junit-4.10.jar"/>
      <classpath refid="project.class.path"/>
    </javac>
  </target>

  <target name="test.dev" depends="javac.tests" description="Run development mode tests">
    <mkdir dir="reports/htmlunit.dev" />
    <junit fork="yes" printsummary="yes" haltonfailure="yes" maxmemory="256m">
      <sysproperty key="gwt.args" value="-devMode -logLevel WARN -war www-test" />
      <sysproperty key="java.awt.headless" value="true" />
      <classpath>
        <pathelement location="src" />
        <pathelement location="test" />
        <path refid="project.class.path" />
        <pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA.jar" />
        <pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA-sources.jar" />
        <pathelement location="D:\SELENIUM\junit-4.10.jar" />
      </classpath>
      <batchtest todir="reports/htmlunit.dev" >
        <fileset dir="test" >
          <include name="**/*Suite.java" />
        </fileset>
      </batchtest>
      <formatter type="plain" />
      <formatter type="xml" />
    </junit>
  </target>

  <target name="test.prod" depends="javac.tests" description="Run production mode tests">
    <mkdir dir="reports/htmlunit.prod" />
    <junit fork="yes" printsummary="yes" haltonfailure="yes" maxmemory="256m">
      <sysproperty key="gwt.args" value="-logLevel WARN -war www-test" />
      <sysproperty key="java.awt.headless" value="true" />
      <classpath>
        <pathelement location="src" />
        <pathelement location="test" />
        <path refid="project.class.path" />
        <pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA.jar" />
        <pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA-sources.jar" />
        <pathelement location="D:\SELENIUM\junit-4.10.jar" />
      </classpath>
      <batchtest todir="reports/htmlunit.prod" >
        <fileset dir="test" >
          <include name="**/*Suite.java" />
        </fileset>
      </batchtest>
      <formatter type="plain" />
      <formatter type="xml" />
    </junit>
  </target>

  <target name="test" description="Run development and production mode tests">
    <antcall target="test.dev" />
    <antcall target="test.prod" />
  </target>

  <target name="build" depends="gwtc" description="Build this project" />

  <target name="war" depends="build" description="Create a war file">
    <zip destfile="Foo.war" basedir="war"/>
  </target>

  <target name="clean" description="Cleans this project">
    <delete dir="war/WEB-INF/classes" failonerror="false" />
    <delete dir="war/foo" failonerror="false" />
  </target>

</project>

有人可以帮我解决这个问题吗?

解决方法:

看来你的build.xml是在foo文件夹中创建的.
看到这个输出:

Created file foo\build.xml

转到foo目录然后运行ant.

标签:build-xml,java,gwt,command-prompt,ant
来源: https://codeday.me/bug/20190823/1699223.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有