通过ant构建project.war文件缺少Java-> server文件夹中的文件 [英] Building project.war file Via ant missed the files in java->server folder

查看:89
本文介绍了通过ant构建project.war文件缺少Java-> server文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我正在使用ant和来创建project.war文件 MFP中的worklight-ant-builder.jar文件.
  2. 虽然我的项目是使用mfp或通过eclipse进行构建的,但是.war文件和classes文件夹中的所有内容都包括在我的 server-> java 文件夹中.
  3. 但是当我使用步骤1构建ant文件时,我没有在 server-> java 文件夹中获取文件.
  1. I am creating project.war file using ant and worklight-ant-builder.jar file in the MFP.
  2. 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.
  3. But when i build the ant file using step 1 i dont get the files in my server->java folder.

请注意,我已通过使用7-zip查看.war文件中的内容进行了验证,并且还看到了我使用步骤2时由mobileFirst创建的包含服务器-> java文件夹内容的文件夹类.

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.

包含Java-> server-> com内的 peluk 文件夹的图像(使用 步骤2 构建)

Image Containing the peluk folder which is inside the Java->server->com ( Built using Step 2)

在Java-> server-> com内没有 peluk 文件夹的图像(使用 步骤1 构建) >

Image which dont have the peluk folder which is inside the Java->server->com (Built using Step 1)

我正在使用以下蚂蚁代码.

 <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"/>

推荐答案

如注释中提到的@dhineshsundar:如果您具有自定义Java代码,并且打算使用Ant任务脚本构建项目,则必须首先进行编译将Java代码转换成.class文件,然后在Ant任务脚本中指定其位置.然后,在使用Ant任务脚本构建项目时,它还将拾取.class文件.

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.

上述情况不会像使用MobileFirst Studio时那样自动发生.

The above does not happen automatically like it happens when using 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

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>

<war-builder>元素具有以下属性:

  • projectfolder属性指定项目的路径.
  • destinationfolder属性指定用于保存临时文件的文件夹.
  • warfile属性指定生成的.war文件的目标和文件名
  • classesFolder属性指定一个文件夹,该文件夹包含要编译的Java™类-添加到.war文件. projectfolder \ server \ lib目录中的.jar文件会自动添加
  • 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

这篇关于通过ant构建project.war文件缺少Java-> server文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆