简体   繁体   中英

Build IBM MobileFirst project using Ant builder (for native code generation)

I'm trying to automate the App development process with IBM MobileFirst (code generation and deployment) and I am wondering if I can automate the code generation from hybrid to native code. I wanted to use Ant for that as it appears to be an elegant and platform independent solution. I have seen [1] which however appears to contradict [2].

Consider a simple MobileFirst Project having a MobileFirst Hybrid Application. I can write hybrid code and generate native code using the context menu of the app: a) Run As > Build All Environments, or for example b) Run As > Build Android Environment. Is it possible to do this with Ant?

I have tried to adapt [2] to my problem (result looked something like [3]), but all I get are .wlapp files and not the generated files. I also tried using the Eclipse auto-generated build file, but it appears not to do the trick. What appeared to work was to execute the command line interface to achieve this, in Windows using a .bat file containing:

cd %~dp0  
mfp build 

My goal is to realize the same with Ant.

--

[1] Building And deploying app to MobileFirst using ANT script

[2] Build and deploy IBM MobileFirst Platform 6.3 adapters using Ant Builder

[3]

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="target-name"> 
  <taskdef resource="com/worklight/ant/defaults.properties"> 
    <classpath> 
      <pathelement location="C:/Program Files/IBM/MobileFirst-CLI/mobilefirst-cli/node_modules/generator-worklight-server/ant-tools/worklight-ant-builder.jar"/> 
    </classpath> 
  </taskdef>
  <target name="target-name"> 
    <app-builder 
      worklightserverhost="http://localhost:10080" 
      applicationFolder="C:/Users/ADMIN/Desktop/MobileFirst/workspace/HelloWorld/apps/HelloWorld" 
      environments="common,android"
      nativeProjectPrefix="HelloWorld"
      outputFolder="C:/Users/ADMIN/Desktop/HelloWorldHelloWorldAndroid"/> 
  </target> 
</project>

MobileFirt ant tasks will build only the server side artifacts like .war and .wlapp

For the native device artifacts like .apk and .ipa you need to use native build tools. When you use MFP Studio you are also using the native tools for that purpose like ADT for android and XCode for iPhone.

These links may help you to automate your native builds

Android http://developer.android.com/tools/building/building-cmdline.html

iPhone https://developer.apple.com/library/ios/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-HOW_DO_I_BUILD_MY_PROJECTS_FROM_THE_COMMAND_LINE_

The MobileFirst <app-builder> ANT task will generate the .wlapp file for you (and this is a crucial step as you will need to deploy this to your MobileFirst Server - you also need to use <war-builder> to build the WAR file also). However, it does not concern itself with generating an .ipa or .apk file, which is the mobile application component that is deployed to a phone/emulator - for that, you need to look at the standard platform-native tools for iOS/Android/etc. - there a lot of subtleties involved in signing the application package and so on which MobileFirst doesn't involve itself with. This is consistent with how the MobileFirst Studio acts - it will not build an .ipa or .apk for you either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM