如何使用单个ANT脚本Worklight 6.1构建和部署适配器

时间:2014-02-28 21:11:40

标签: deployment ant build adapter ibm-mobilefirst

在6.1,蚂蚁罐被分成两个罐子:worklight-ant-builder.jar和worklight-ant-deployer.jar。我可以自己运行构建或部署任务,但我必须更改文件集。我想运行构建适配器并从单个ant脚本部署适配器。

我尝试了几种方法在taskdef文件集中包含两个jar:

include name="*.jar"

或     filename name =“*。jar” 要么     include name =“worklight-ant-builder.jar”     include name =“worklight-ant-deployer.jar”

它几乎就像任务不会接受多个罐子。构建总是有效,但只有当deployer.jar本身是“include name =”worklight-ant-deployer.jar时才进行部署。

<taskdef resource="com/worklight/ant/defaults.properties">
    <classpath>
      <fileset dir="${worklight.server.install.dir}/WorklightServer">
        <include name="*.jar"/> 
         <!--   <filename name="*.jar"/> -->
       <!-- <include name="worklight-ant-builder.jar"/>  -->
       <!-- <include name="worklight-ant-deployer.jar"/>  -->           
      </fileset>
    </classpath>
  </taskdef>

我理解多脚本答案,但我认为我不应该这样做。这是我的完整脚本:

<?xml version="1.0" encoding="UTF-8"?>

<project name="BuildDeployAdapter" basedir="." default="help">

  <property name="worklight.server.install.dir" value="C:/IBM/Worklight61/"/>
  <property name="adapter-source-files-folder" value="C:/Worklight/workspaces/base61p/HelloWorklight/adapters/HTTPAdapter"/>
  <property name="destination-folder" value="C:/Worklight/workspaces/base61p/HelloWorklight/binANT"/>
  <property name="myAdapter.adapter" value="${destination-folder}/HTTPAdapter.adapter"/>
  <property name="http.server.port.context" value="http://mydomain:9080/worklight"/>

  <taskdef resource="com/worklight/ant/defaults.properties">
    <classpath>
      <fileset dir="${worklight.server.install.dir}/WorklightServer">
        <include name="*.jar"/>
       <!-- <filename name="*.jar"/> -->
       <!-- <include name="worklight-ant-builder.jar"/>  -->
       <!-- <include name="worklight-ant-deployer.jar"/>  -->           
      </fileset>
    </classpath>
  </taskdef>

  <target name="buildAdapter">
    <adapter-builder
        folder="${adapter-source-files-folder}"
        destinationfolder="${destination-folder}"/>
  </target>     

  <target name="deployAdapter"> 
    <adapter-deployer deployable="${myAdapter.adapter}"
                      worklightserverhost="${http.server.port.context}" 
                      userName="username" password="password" />
  </target>

</project>

现在我必须为每个任务切换包含的jar,当我想使用蒙面包含时 - 包括name =“ .jar”或filename name =“ .jar”。这似乎是对不接受多个罐子的特定任务的限制。我不在这里吗?

1 个答案:

答案 0 :(得分:1)

鉴于您提供的信息,似乎解决方案可能是创建一个单独的脚本,该脚本将按顺序调用构建和部署脚本,如下所示:

<project name="Adapter Stuff" default="do.all" basedir=".">
  <target name="do.all">
    <ant antfile="path/to/worklight-build-adapter.xml"
         target="build-target" inheritall="false"/>
    <ant antfile="path/to/worklight-deploy-adapter.xml"
         target="deploy-target" inheritall="false"/>
  </target>
</project>