我正在使用以下蚂蚁代码. <pathelement location="${res.location}\Resources\worklight-ant-builder.jar"/></classpath></taskdef><war-builder projectfolder="bin"warfile="bin\${proj.brcname}.war"classesFolder="classes-folder"/> 解决方案 正如@dhineshsundar 在评论中提到的:如果您有自定义 Java 代码并且您计划使用 Ant 任务脚本构建项目,那么您必须首先编译将 Java 代码转换为 .class 文件并在 Ant 任务脚本中指定其位置.然后,在使用 Ant 任务脚本构建项目时,它还会选取 .class 文件.上述情况不会像使用 MobileFirst Studio 时那样自动发生.请参阅此用户文档主题:http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.deploy.doc/devref/r_ant_tasks_deploy_projects.html<pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/></classpath></taskdef><目标名称="所有"><war-builder projectfolder="."目标文件夹=bin/war"战争文件=bin/project.war"classesFolder="classes-folder"/></目标></项目> 元素具有以下属性:projectfolder 属性指定项目的路径.destinationfolder 属性指定用于保存临时文件的文件夹.warfile 属性指定生成的 .war 文件的目的地和文件名classesFolder 属性指定一个文件夹,其中包含要添加到 .war 文件中的已编译 Java™ 类. 添加了 projectfolder\server\lib 目录中的 .jar 文件自动I am creating project.war file using ant andworklight-ant-builder.jar file in the MFP.While my project is build using mfp or via eclipse in the bin the .war file and classes folder have all the things including content in my server->java folder.But when i build the ant file using step 1 i dont get the files in my server->java folder. I am using the following ant code. <taskdef resource="com/worklight/ant/defaults.properties"> <classpath> <pathelement location="${res.location}\Resources\worklight-ant-builder.jar"/> </classpath> </taskdef> <war-builder projectfolder="bin" warfile="bin\${proj.brcname}.war" classesFolder="classes-folder"/> 解决方案 As @dhineshsundar mentioned in the comments: If you have custom Java code and you're planning on building a project using the Ant task script then you must first compile the Java code into a .class file and specify its location in the Ant task script. Then when building the project using the Ant task script it will also pick up the .class file.The above does not happen automatically like it happens when using MobileFirst Studio.See this user documentation topic: http://www-01.ibm.com/support/knowledgecenter/SSHS8R_7.0.0/com.ibm.worklight.deploy.doc/devref/r_ant_tasks_deploy_projects.html<?xml version="1.0" encoding="UTF-8"?><project name="myProject" default="all"> <taskdef resource="com/worklight/ant/defaults.properties"> <classpath> <pathelement location="cli_install_dir/public/worklight-ant-builder.jar"/> </classpath> </taskdef> <target name="all"> <war-builder projectfolder="." destinationfolder="bin/war" warfile="bin/project.war" classesFolder="classes-folder"/> </target></project>The <war-builder> element has the following attributes:The projectfolder attribute specifies the path to your project.The destinationfolder attribute specifies a folder for holding temporary files.The warfile attribute specifies the destination and file name of the generated .war fileThe classesFolder attribute specifies a folder with compiled Java™ classes to - add to the .war file. .jar files in the projectfolder\server\lib directory are added automatically 这篇关于构建project.war文件通过ant错过了java->server文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!