您的位置:首页 > Web前端

jfinal-coffeescript使用java实现coffeescript的动态编译

2014-09-12 12:16 501 查看
https://github.com/Dreampie/jfinal-coffeescript jfinal-coffeescript是一款java下的coffeescript实时编译插件:

<dependency>
<groupId>cn.dreampie</groupId>
<artifactId>jfinal-coffeescript</artifactId>
<version>${jfinal-coffeescript.version}</version>
</dependency>


目前刚刚发布第一个版本0.1:

<jfinal-coffeescript.version>0.1</jfinal-coffeescript.version>


使用方法:

在jfinal config里configPlugin方法加入

plugins.add(new CoffeeScriptPlugin("/coffeescript/", "/javascript/"));//第一个参数是coffee的文件目录,第二个是输出的js目录


只有这么一句

如果你没有使用jfinal,你可以这么用

setCoffeeScriptCompiler("/coffeescript/", "/javascript/", false, "--bare", true);

private void setCoffeeScriptCompiler(String in, String out, boolean compress, String args, boolean watch) {
coffeeScriptCompiler = new CoffeeScriptCompiler();
coffeeScriptCompiler.setBuildContext(ThreadBuildContext.getContext());//js运行环境
coffeeScriptCompiler.setSourceDirectory(new File(PathKit.getWebRootPath() + in));//输入目录
coffeeScriptCompiler.setOutputDirectory(new File(PathKit.getWebRootPath() + out));//输出目录
//        coffeeScriptCompiler.setForce(true);
coffeeScriptCompiler.setCompress(compress);//压缩  暂时不支持
coffeeScriptCompiler.setArgs(args);//参数
coffeeScriptCompiler.setWatch(watch); 是否动态监听文件改动
}

//上面的代码是初始化插件的参数  使用双线程一个执行,一个监听执行线程 如果执行线程出现错误  监听线程会重启执行线程
CoffeeExecuteThread run = new CoffeeExecuteThread(coffeeScriptCompiler, restartInterval);
CoffeeExecuteListener listen = new CoffeeExecuteListener(run);
run.addObserver(listen);
new Thread(run).start();


https://github.com/Dreampie?tab=repositories 目录下有多款插件:
cn.dreampie.jfinal-shiro https://github.com/Dreampie/jfinal-shiro shiro插件
cn.dreampie.jfinal-shiro-freemarker https://github.com/Dreampie/jfinal-shiro-freemarker shiro插件实现的freemarker标签库
cn.dreampie.jfinal-web https://github.com/Dreampie/jfinal-web 相关web插件,简洁model实现
cn.dreampie.jfinal-utils https://github.com/Dreampie/jfinal-utils 部分jfinal工具
cn.dreampie.jfinal-tablebind https://github.com/Dreampie/jfinal-tablebind jfinal的table自动绑定插件,支持多数据源
cn.dreampie.jfinal-flyway https://github.com/Dreampie/jfinal-flyway 数据库脚本升级插件,开发中升级应用时,使用脚本同步升级数据库或者回滚
cn.dreampie.jfinal-captcha https://github.com/Dreampie/jfinal-captcha 基于jfinal render的超简单验证吗插件
cn.dreampie.jfinal-quartz https://github.com/Dreampie/jfinal-quartz 基于jfinal 的quartz管理器
cn.dreampie.jfinal-sqlinxml https://github.com/Dreampie/jfinal-sqlinxml 基于jfinal 的类似ibatis的sql语句管理方案
cn.dreampie.jfinal-lesscss https://github.com/Dreampie/jfinal-lesscss java实现的lesscsss实时编译插件,可以由于jfinal
cn.dreampie.jfinal-coffeescript https://github.com/Dreampie/jfinal-coffeescript java实现的coffeescript实时编译插件,可以由于jfinal
cn.dreampie.jfinal-akka https://github.com/Dreampie/jfinal-akka java使用akka执行异步任务
cn.dreampie.jfinal-mailer https://github.com/Dreampie/jfinal-mailer 使用akka发布邮件的jfinal插件
cn.dreampie.jfinal-slf4j https://github.com/Dreampie/jfinal-slf4j 让jfinal使用slf4j的日志api

部分内容借鉴了网络资料
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jfinal java coffeescript