Back

titanium 入门 6 alloy.jmk: 编译配置文件

发布时间: 2014-12-25 01:22:00

jmk = js MakeFile , 用来在编译 javascript 时做配置。 需要放在 app 目录下。

例子:

task("pre:compile",function(event,logger){
    logger.showTimestamp = true;
    logger.info('building project at '+ event.dir.project);
});
task("post:compile",function(event,logger){
    logger.info('compile finished!');
});

接受两个参数: event, logger.   

可用的event: 

pre:load: called after the project is cleaned and before copying any assets to the Resources folder.
pre:compile: called before the compiler starts.
post:compile: called after the compiler finishes but before it exits.
compile:app.js: called just after the compilation of the main app.js file but before the code is written to disk.

在function(event, logger) 中, event有如下的变量: 

Object/Value

Description

adapters
(Array)

List of adapters.

alloyConfig
(Object)

Contains Alloy compiler configuration information.

  • platform : either android, blackberry, ios, or mobileweb.

  • deploytype : compilation environment type: either development, test or production.

  • beautify : if set to true, the output from UglifyJS will be beautified.

autoStyle
(Boolean)

If set to true, autostyle is enabled for the entire project.

dependencies
(Object)

Value of the dependencies key in the config.json file.

dir
(Object)

Contains directory paths to various resources.

  • home : absolute path to the Alloy project's app directory.

  • project : absolute path to the Alloy project's root directory.

  • resources : absolute path to the Alloy project's Resource directory.

  • resourcesAlloy : absolute path to the Alloy project's Resource/alloy directory.

  • assets : absolute path to the Alloy project's assets.

  • config : absolute path to the Alloy project's config.

  • controllers : absolute path to the Alloy project's controllers.

  • migrations : absolute path to the Alloy project's migrations.

  • models : absolute path to the Alloy project's models.

  • styles : absolute path to the Alloy project's styles.

  • themes : absolute path to the Alloy project's themes.

  • views : absolute path to the Alloy project's views.

  • widgets : absolute path to the Alloy project's widgets.

  • builtins : absolute path to the Alloy tool builtins.

  • template : absolute path to the Alloy tool templates.

sourcemap
(Boolean)

If true, generates the source mapping files for use with the Studio debugger and other functions.
These files maps the generated Titanium files in the Resources directory to the ones in the app directory.

theme
(String)

Name of the theme being used.

code
(String)

Only present for the compile:app.js task. Contains the contents of the app.js file.

appJSFile
(String)

Only present for the compile:app.js task. Contains the the absolute path to the app.js file.

Back