`

JSBuilder2(extjs.com/products/jsbuilder )是配合Ext 3新发布的AJAX打包工具

 
阅读更多

摘自:http://extjs.org.cn/node/547

 

JSBuilder2(extjs.com/products/jsbuilder )是配合Ext 3新发布的AJAX打包工具,用Java语言编写,制成JAR格式执行文件发布。作为一个方便开发者的打包工具,它内含有几种开源项目在内,包括 Rhino Project(著名的JavaScript编译器)、YUI Compressor(压缩JS/CSS)和Java环境下JSON的编码器(来自www.json.org),方便在JavaScript和CSS项目 中使用。

 

下载地址:

http://dev.sencha.com/deploy/JSBuilder2.zip

 

JSBuilder2具有特性如下:

跨平台的Java应用程序
用法简单
以JSON为配置文件的结构
采用YUI Compressor来进行文件的压缩
在开发阶段到部署阶段之间,资源文件都可以轻松迁移
与第一版不同,JSBuilder2是纯命令行的工具,因此我们必须了解一下它的参数如何。首先运行JAR包的执行文件必须要有java.exe。 通常我们将该命令加入“环境变量”中,然后加入-jar参数即可以运行这个JSBuilder2.jar文件。关于JSBuilder的参数列表,可见:

--projectFile -p (必填的)jsb2文件,该文件定义了打包的具体任务。 Location of a jsb2 project file
--homeDir -d (必填的)生成的主目录,通常就是项目部署的目录。
--verbose -v (可选的参数)输出正在生产的详细过程。
--debugSuffix -s (可选的参数)为便于调试,生产JS调试文件的后续名称,默认为“debug”,以表示这是调试用的JS文件。
--help -h (可选的参数)显示帮助。
Windows平台上的用法:

java -jar JSBuilder2.jar --projectFile C:/Apps/www/ext3svn/ext.jsb2 --homeDir C:/Apps/www/deploy/

Linux或OS X平台上的用法:

java -jar JSBuilder2.jar --projectFile /home/aaron/www/trunk/ext.jsb2 --homeDir /home/aaron/www/deploy/

上面提到JSBuilder的jsb2文件,很明显的是为第二版所服务的配置文件,以区别于旧版。在第一版的时候,*.jsb是采用XML文件作为配置其 配置文件的,那时还是.Net WinForm写好的程序。而在这次Java写的版本中,却是使用了JSON作为其配置文件的格式。我们说到JSBuilder既有Moliza的 Rhino JS引擎也有JSON.org的包同时存在,它既可以让JS引擎以eval()函数获得JSON对象,也可以让Java的代码获得这个JSON对象,都是 比较方便的方法。那么使用XML是不是较为不便呢?也不一定的,因为我们可以从Rhino的开源信息得到了解,较新版的Rhino是升级到 JavaScript 1.8,也就正式支持EXA的标准。在EXA的支持下XML转为JS对象轻而易举。当然这又是另外一件事了。

下面我们说一下这个JSON格式的清单。

The top-level keys are:
- projectName: String 说明该项目。
- deployDir: String specifying directory to create within the homeDir 
specified on the commandline
- licenseText: String specifying the header of all .js and .css, use /n for
newlines.
- pkgs: An array of package descriptors
- resources: An array of resource descriptors

Package Descriptors:
- name: String describing the package 
- file: String specifying the file to create
- isDebug: Boolean describing whether to generate debug builds
This configuration is currently UNUSED. Debug and compressed
versions will ALWAYS be generated.
- fileIncludes: An array of files descriptors which need to be included in this
package.
- pkgDeps: An array of the package descriptor file strings that this 
package depends on. The behavior of this configuration relies 
on the includeDeps configuration.
- includeDeps: Boolean describing whether or not to include dependencies in the
outputted file. Defaults to false.

File Descriptors:
- text: String describing the file to be included
- path: String describing the directory of file to be included

Resource Descriptors:
- src: String describing the folder to move resources from
- dest: String describing the folder to move resources to
- filters: String to create a RegEx which specifies how to filter the 
files which are copied from src to dest. All .svn and hidden 
files will automatically be excluded. Note that all /'s must
be encoded //.

Filter Examples:
- ".*" A filter to copy all files
- ".*[//.js|//.css]" A filter to copy all js and css files.

从清单中可以看出,JSON格式仍然是以Key/Value,键/键值列出。我们定义好我们自己的配置后,保存为一份*.jsb2文件让JSBuilder读取。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics