2013-06-25 73 views
0

我有一个多项目sbt编译,我想用https://github.com/softprops/coffeescripted-sbt将我的coffeescript编译为javascript,但它不执行任务。使用coffeescripted-sbt在多项目编译中编译coffeescript

的代码是从https://github.com/jeffmay/angular-play-multimodule-seed/tree/stackoverflow-17289043

采取build.sbt

即使不建议这样做,我为了测试此混在项目目录中build.sbt文件与我的项目对象插件工作。

build.sbt

seq(coffeeSettings: _*) 

当我跑:

$ sbt 
[info] Loading project definition from /Users/jeffmay/code/righttrack/project 
[info] Set current project to root (in build file:/Users/jeffmay/code/righttrack/) 
> coffee 
[success] Total time: 0 s, completed Jun 24, 2013 11:40:37 PM 
> show coffee 
[info] ArrayBuffer() 
[success] Total time: 0 s, completed Jun 24, 2013 11:40:52 PM 
> project web 
[info] Set current project to web (in build file:/Users/jeffmay/code/righttrack/) 
[web] $ coffee 
[error] Not a valid command: coffee 
[error] No such setting/task 
[error] coffee 
[error]  ^
[web] $ 

是什么ArrayBuffer()意思?那是一个无声的故障(CoffeeScript的返回最后一个表达式,否则将是一个的nullreturn;?)

多项目设置

对于某些方面,我打造的是爆发了,像这样......

project/plugins.sbt

// SBT community plugin resolver 
resolvers += Resolver.url("sbt-plugin-releases", 
    new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns) 

// CoffeeScript compiler plugin 
addSbtPlugin("me.lessis" % "coffeescripted-sbt" % "0.2.3") 

project/Modules.scala(我的生成对象):

import sbt._ 

object Modules extends Build { 

    lazy val root = RootModule.project 

    lazy val api = ApiModule.project 

    lazy val web = WebModule.project 
} 

project/WebModule.scala

object WebModule extends BaseModule { 

    // ... libraries dependencies and stuff 

    override def project = play.Project(moduleName, moduleVersion, libraries, file(location), 
    moduleSettings ++ 
    Seq((resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_/"src"/"main"/"coffee")) 
) 
} 

我用project/BaseModule.scala删除每个模块的共同要素的混乱,但它没有做任何幻想。

随着Build.scala

我删除build.sbt的东西,并把它变成Build.scala通过project/WebModule.scala加入:

override def project = play.Project(moduleName, moduleVersion, libraries, file(location), 
    moduleSettings ++ 
    coffeeSettings ++ // With the settings moved from build.sbt 
    Seq((resourceManaged in (Compile, CoffeeKeys.coffee)) <<= (crossTarget in Compile)(_/"src"/"main"/"coffee")) 
) 

然后我给它一个旋转

$ sbt 
[info] Loading project definition from /Users/jeffmay/code/righttrack/project 
[info] Set current project to root (in build file:/Users/jeffmay/code/righttrack/) 
> coffee 
[error] Not a valid command: coffee 
[error] No such setting/task 
[error] coffee 
[error]  ^
> project web 
[info] Set current project to web (in build file:/Users/jeffmay/code/righttrack/) 
[web] $ coffee 
[success] Total time: 0 s, completed Jun 25, 2013 12:08:36 AM 
[web] $ show coffee 
[info] ArrayBuffer() 
[success] Total time: 0 s, completed Jun 25, 2013 12:08:40 AM 

我运行咖啡命令后没有看到任何更改。任何想法是什么问题?

谢谢!

回答

0

看到我的对话框,softprops了解更多详情:https://github.com/softprops/coffeescripted-sbt/issues/17

有三个问题,一个改进上面的代码。

  1. 我没有把我的web项目聚合到根项目中。

  2. 我没有设置在哪里可以找到咖啡脚本文件。

  3. Play使用“./app”作为sourceDirectory,所以当我加入

    sourceDirectory in (Compile, CoffeeKeys.coffee) <<= sourceDirectory { _/"main"/"coffee" } 
    

    看似‘正确’的目录路径它是在“./app/src/main/coffee”搜索,不存在

我能够通过编译器来改善这个例子管理./public目录,以便它可以滴在推荐public/js目录中编译的JavaScript源的角度种子项目。

您可以在这里看到完整的种子项目示例:https://github.com/jeffmay/angular-play-multimodule-seed