Sbt 0.11 port #3

Closed
wants to merge 2 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+323 −892
Split
View
@@ -1,4 +1,2 @@
target/
-lib_managed/
-src_managed/
-/project/boot
+project/
View
@@ -1,7 +1,7 @@
SBT Closure Plugin
==================
-[Simple Build Tool] plugin for compiling Javascript filesfrom multiple sources using Google's [Closure compiler].
+[Simple Build Tool] plugin for compiling Javascript files from multiple sources using Google's [Closure compiler].
Copyright (c) 2011 [Dave Gurnell] of [Untyped].
@@ -10,63 +10,70 @@ Copyright (c) 2011 [Dave Gurnell] of [Untyped].
[Dave Gurnell]: http://boxandarrow.com
[Untyped]: http://untyped.com
-Usage
-=====
+Installation
+============
+
+For SBT 0.11:
+
+Create a `project/plugins.sbt` file and paste the following content into it:
+
+ resolvers += "Untyped Public Repo" at "http://repo.untyped.com"
+
+ addSbtPlugin("untyped" % "sbt-closure" % "0.6-SNAPSHOT")
+
+Then, in your build.sbt file, put:
+
+ seq(closureSettings:_*)
+
+If you're using [xsbt-web-plugin](https://github.com/siasia/xsbt-web-plugin "xsbt-web-plugin"), add the output files to the webapp with:
-First, create a `project/plugins/Plugins.scala` file and paste the following
-content into it:
+ // add managed resources to the webapp
+ (webappResources in Compile) <+= (resourceManaged in Compile)
- import sbt._
+To change the directory that is scanned, use:
- class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
- val untypedRepo = "Untyped Repo" at "http://repo.untyped.com"
- val closureCompiler = "untyped" % "sbt-closure" % "0.4"
- }
+ (sourceDirectory in (Compile, ClosureKeys.closure)) <<= (sourceDirectory in Compile)(_ / "path" / "to" / "jsmfiles")
-This will give you the ability to use the plugin in your project file. For example:
+To make the closure task run with compile:
- import sbt._
-
- class MyProject(info: ProjectInfo) extends DefaultWebProject(info)
- with untyped.ClosureCompilerPlugin {
-
- // and so on...
-
- }
+ // make compile depend on closure
+ (compile in Compile) <<= compile in Compile dependsOn (ClosureKeys.closure in Compile)
-The default behaviour of the plugin is to scan your `src/main/webapp` directory
+The plugin is currently untested under SBT 0.10. If you manage to get it to work,
+let me know and I'll update these docs.
+
+Usage
+=====
+
+The default behaviour of the plugin is to scan your `src/main` directory
and look for files of extension `.jsmanifest`, or `.jsm` for short. These files
should contain ordered lists of JavaScript source locations. For example:
# You can specify remote files using URLs...
http://code.jquery.com/jquery-1.5.1.js
-
+
# ...and local files using regular paths
# (relative to the location of the manifest):
lib/foo.js
bar.js
-
+
# Blank lines and bash-style comments are also supported.
# These may be swapped for JS-style comments in the future.
The plugin compiles this in two phases: first, it downloads and caches any
remote scripts. Second, it feeds all of the specified scripts into the Closure
compiler. The compiler outputs a file of the same name and relative path
of the manifest, but with a `.js` extension. For example, if your manifest
-file is at `webapps/static/js/kitchen-sink.jsm` in the source tree, the final
-path would be `webapps/static/js/kitchen-sink.js` in the target tree.
+file is at `src/main/javascript/static/js/kitchen-sink.jsm` in the source tree, the final
+path would be `resource_managed/main/static/js/kitchen-sink.js` in the target tree.
If, on compilation, the plugin finds remote scripts already cached on your
filesystem, it won't try to download them again. Running `sbt clean` will
delete the cache.
-You can change the compiler options by overriding the `closureCompilerOptions`
-method. See the source for details.
+To execute the plugin's compilation step use `sbt closure`. See above on how to make it depend on compile.
-Finally, you can execute the plugin's compilation step independently of
-`prepare-webapp` using `sbt compile-js`.
-
-Templating
+Templating - NOT IMPLEMENTED FOR SBT 0.11
================
It is sometime useful to template Javascript files. For example, you might want
@@ -100,13 +107,16 @@ Parameters controlling templating are:
Acknowledgements
================
-Based on the [Coffee Script SBT plugin], Copyright (c) 2010 Luke Amdor.
+v0.6+ for SBT 0.11 based on [less-sbt](https://github.com/softprops/less-sbt), Copyright (c) 2011 Doug Tangren.
+v0.1-v0.5 for SBT 0.7 based on [Coffee Script SBT plugin], Copyright (c) 2010 Luke Amdor.
Heavily influenced by the [YUI Compressor SBT plugin] by Jon Hoffman.
[Coffee Script SBT plugin]: https://github.com/rubbish/coffee-script-sbt-plugin
[YUI Compressor SBT plugin]: https://github.com/hoffrocket/sbt-yui
+SBT 0.11 migration done by [Tim Nelson](https://github.com/eltimn)
+
Licence
=======
View
@@ -0,0 +1,18 @@
+sbtPlugin := true
+
+name := "sbt-closure"
+
+organization := "untyped"
+
+version <<= sbtVersion(v =>
+ if(v.startsWith("0.11")) "0.6-SNAPSHOT"
+ else error("unsupported sbt version %s" format v)
+)
+
+libraryDependencies += "com.google.javascript" % "closure-compiler" % "r1459"
+
+libraryDependencies += "org.scalatest" %% "scalatest" % "1.6.1" % "test"
+
+seq(scriptedSettings:_*)
+
+scalacOptions ++= Seq("-deprecation", "-unchecked")
View
@@ -1,8 +0,0 @@
-#Project properties
-#Sun Aug 15 11:35:30 CDT 2010
-project.organization=untyped
-project.name=sbt-closure
-sbt.version=0.7.4
-project.version=0.5-SNAPSHOT
-build.scala.versions=2.7.7
-project.initialize=false
@@ -1,40 +0,0 @@
-import sbt._
-
-import java.io.File
-
-class Project(info: ProjectInfo) extends PluginProject(info) with test.ScalaScripted {
-
- val closure = "com.google.javascript" % "closure-compiler" % "r706"
- val jtache = "com.samskivert" % "jmustache" % "1.3"
- val testing = "org.scalatest" % "scalatest" % "1.1"
-
- override def scriptedSbt = "0.7.4"
- override def scriptedBufferLog = false
-
- override def testAction = testNoScripted
-
- lazy val default = scripted dependsOn(publishLocal) describedAs("Publishes locally and tests against example projects")
-
- // This doesn't work for inexplicable reasons
- // lazy val untypedResolver = {
- // def OptionOf[T](v: T): Option[T] = {
- // if (v == null)
- // None
- // else
- // Some(v)
- // }
-
- // for { host <- OptionOf(System.getenv("DEFAULT_REPO_HOST"))
- // path <- OptionOf(System.getenv("DEFAULT_REPO_PATH"))
- // user <- OptionOf(System.getenv("DEFAULT_REPO_USER"))
- // keyfile <- OptionOf(System.getenv("DEFAULT_REPO_KEYFILE"))
- // } yield Resolver.sftp("Default Repo", host, path).as(user, new java.io.File(keyfile))
- // }
-
- lazy val publishTo = Resolver.sftp("Default",
- System.getenv("DEFAULT_REPO_HOST"),
- System.getenv("DEFAULT_REPO_PATH")).
- as(System.getenv("DEFAULT_REPO_USER"),
- new File(System.getenv("DEFAULT_REPO_KEYFILE")))
-
-}
@@ -1,7 +0,0 @@
-import sbt._
-
-class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
- val scriptedDep = "org.scala-tools.sbt" % "scripted" % "0.7.4"
- val databinder_repo = Resolver.url("Databinder Repository", new java.net.URL("http://databinder.net/repo"))(Resolver.ivyStylePatterns)
- val jtache = "com.samskivert" % "jmustache" % "1.3"
-}
@@ -0,0 +1,3 @@
+libraryDependencies <+= sbtVersion(v=>
+ "org.scala-tools.sbt" %% "scripted-plugin" % v
+)
@@ -1,49 +0,0 @@
-package untyped
-
-import com.google.javascript.jscomp._
-
-import sbt._
-
-trait ClosureCompilerConfig extends MavenStyleWebScalaPaths {
-
- // Configuration ------------------------------
-
- // This is a convenience method from Project.
- def descendents(parent: PathFinder, include: FileFilter): PathFinder
-
- /**
- * Returns true if the path refers to a file that should be templated
- *
- * It is templated if the file name contains .template. E.g. foo.template.js
- */
- def closureJsIsTemplated(path: Path): Boolean = path.name.contains(".template")
-
- /**
- * Where we should look to find properties files that supply values we use when templating
- */
- def closurePropertiesPath: Path = mainResourcesPath
-
- def closureSourcePath: Path = webappPath
-
- def closureJsSourceFilter: NameFilter = GlobFilter("*.js")
- def closureJsSources: PathFinder = descendents(closureSourcePath, closureJsSourceFilter)
-
- def closureManifestSourceFilter: NameFilter = GlobFilter("*.jsm") | "*.jsmanifest"
- def closureManifestSources: PathFinder = descendents(closureSourcePath, closureManifestSourceFilter)
-
- def closureOutputPath: Path = (outputPath / "sbt-closure-temp") ##
-
- var _closurePrettyPrint = false
- def closurePrettyPrint = _closurePrettyPrint
-
- var _closureVariableRenamingPolicy = VariableRenamingPolicy.LOCAL
- def closureVariableRenamingPolicy = _closureVariableRenamingPolicy
-
- def closureCompilerOptions = {
- val options = new CompilerOptions
- options.variableRenaming = closureVariableRenamingPolicy
- options.prettyPrint = closurePrettyPrint
- options
- }
-
-}
Oops, something went wrong.