1

我们正在使用 IBM Worklgiht 6.0(下面的确切版本)并且在使用 ANT 任务构建 Worklight 项目时看到构建错误,但相同的代码在 Eclipse 中构建得很好。

这是 ANT 构建错误:

构建失败 C:\Users\Administrator\workspace-techcon3\MyProject\build.xml:44:构建应用程序失败:com.worklight.builder.exception.WorklightBuildRuntimeException:资源管理器 - 读取 info.plist 文件时出现问题 C:\Users \Administrator\workspace-techcon3\MyProject\apps\MyApp\iphone\native\MyAppIphone-Info.plist(系统找不到指定的文件)嵌套异常:C:\Users\Administrator\works pace-techcon3\MyProject\ apps\MyApp\iphone\native\MyAppIphone-Info.plist(系统找不到指定的文件)

以下是详细信息:

  1. Worklight 项目是使用 Eclipse Juno SR2 中的 WorklightStudio 插件 v6.0.0.20130926-1933 创建的。
  2. Worklight 项目名称为 MyProject,它包含一个名为 MyApp 的混合应用程序。它包含 iphone 和 android 的环境。

  3. 在 Eclipse 中一切都很好(构建、部署等),但在通过 ANT 在我们的 CI 服务器上构建相同的代码时失败(参见上面的错误和下面的 build.xml 片段)。

  4. ANT 构建正在寻找一个名为 iphone\native\MyAppIphone-Info.plist的文件,但驻留在文件系统上的 Eclipse 中的 Worklight 插件生成的实际文件是iphone\native\MyProjectMyAppIphone-Info.plist,因此它失败了:
  5. build.xml 如下。

简而言之,在使用 ANT 构建相同的代码时,Worklight Eclipse 插件创建的 Worklight 项目属性似乎不兼容——但这似乎应该有效,或者没有办法在 Eclipse 中为开发人员构建并进行无头构建在 CI 环境中通过 ANT。

build.xml is below:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="MyTask" basedir="." default="build">
    <property file="build.properties"/>

    <target name="init">
        <delete dir="${build.dir}"/>
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${build.dir}/classes"/>
        <echo message="Loading ANT Tool"/>
        <echo message="Basedir is ${basedir}"/>
        <echo message="Antlib is ${ant.library.dir}"/>

<taskdef resource="com/worklight/ant/defaults.properties">
            <classpath>
            <pathelement location="${ant.library.dir}/worklight-   ant.jar"/>
            </classpath>
        </taskdef>
    </target>


    <target name="build" depends="init, warBuilder,appBuilder">
        <echo message="Build Target Complete"/>
    </target>

    <target name="warBuilder">
        <echo message="Building the war file"/>
<war-builder projectfolder="${basedir}" destinationfolder="${build.dir}"
<warfile="${build.dir}/${war.file.name}" classesFolder="${build.classes.dir}"/>

<echo message="Updating the war file with worklight server configurations"/>
        <war destfile="${build.dir}/${war.file.name}" update="true">
            <webinf dir="${build.files.dir}" includes="i*.xml"/>
        </war>
    </target>

<target name='appBuilder' >
        <echo message="Building the App"/>
<app-builder applicationFolder="${apps.dir}" outputfolder="${build.dir}"
worklightServerHost="${WLSERVERHOST}"/>
            </target>


<target name='buildAllAdapters'>
        <taskdef resource="net/sf/antcontrib/antlib.xml">
            <classpath>
            <pathelement location="${ant.library.dir}/ant-contrib-0.6.jar"/>
            </classpath>
        </taskdef>

        <echo message="Building all adpaters"/>
    <foreach target="adapterBuilder" param="adapterDirectory" inheritall="true">
            <path>
                <dirset dir="${adapters.dir}">
                    <include name="*"/>
                </dirset>
            </path>
        </foreach>
    </target>
    <target name="adapterBuilder">
        <echo message="Building adapters in folder ${adapterDirectory}"/>
    <adapter-builder folder="${adapterDirectory}" destinationfolder="${build.dir}"/>
    </target>

    <target name="appDeployer">
        <echo message="Deploying app ${appFile}"/>
    <app-deployer worklightServerHost="${WLSERVERHOST}" deployable="${appFile}"/>
    </target>
    <target name='deployAllAdapters'>
        <taskdef resource="net/sf/antcontrib/antlib.xml">
            <classpath>
        <pathelement location="${ant.library.dir}/ant-contrib-0.6.jar"/>
            </classpath>
        </taskdef>

        <echo message="Deploying all adpaters"/>
        <foreach target="adapterDeployer" param="adapterFile" inheritall="true">
            <path>
                <fileset dir="${build.dir}">
                    <include name="*.adapter"/>
                </fileset>
            </path>
        </foreach>
    </target>

</project>
4

1 回答 1

2

在您的 build.xml 中,您缺少 app-builder 标记中的 nativeProjectPrefix 属性。这是一个具有不同属性的应用程序构建器示例。

<app-builder
    worklightServerHost="http://server-address:port"
    applicationFolder="adapter-source-files-folder"
    environments="list-of-environments"
    nativeProjectPrefix="project-name"
    outputFolder="output-folder"/>
于 2013-12-05T09:08:13.597 回答