构建project.war文件通过ant错过了java->server文件夹中的文件 [英] Building project.war file Via ant missed the files in java->server folder
问题描述
- 我正在使用 ant 和MFP 中的 worklight-ant-builder.jar 文件.
- 虽然我的项目是使用 mfp 或通过 eclipse 在 bin 中构建的,但 .war 文件和 classes 文件夹包含所有内容,包括我的 server->java 文件夹中的内容.
- 但是当我使用第 1 步构建 ant 文件时,我的 server->java 文件夹中没有这些文件.
<块引用>
注意,我已经通过使用 7-zip 查看 .war 文件中的内容验证了这一点,并且还看到了由 mobileFirst 创建的文件夹类,其中包含服务器->java 文件夹内容,当我使用第 2 步时.
<块引用>
包含 Java->server->com 内的 peluk 文件夹的图像(使用 Step 2 构建)
<块引用>
Java->server->com 中没有 peluk 文件夹的图像(使用 步骤 1 构建)>
我正在使用以下蚂蚁代码.
<类路径><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 时那样自动发生.
<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 and worklight-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.
Note i have verified this by using 7-zip to see the contents in the .war file and also seen the folder classes created by the mobileFirst which contains server->java folder content when i use step 2.
Image Containing the peluk folder which is inside the Java->server->com ( Built using Step 2)
Image which dont have the peluk folder which is inside the Java->server->com (Built using Step 1)
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 file - The
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文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!